可以同时支持编译出机器码和.NET托管代码的C++/CLI,前身是Managed C++,基本相当于一个C++和一个C++风格的.NET语言合并成一个语言。程序员喜欢强大的语言可以理解,不少人学用C++也是因为C++很强大。但强大并不一定各方面都擅长,有所得必有所失。其至今的最主要用途,仍然是用于托管和非托管程序的交互,包装非托管代码成托管类库。而用其写.NET应用,并无长处,也不是Visual Studio支持的重点,例如WPF编辑器就不支持C++/CLI。
除包装之外,C++/CLI的另一个作用是将旧C++程序以最小的改动编译成.NET平台代码。目前的CPU硬件在走向异构,32位、64位,ARM兴起,各种嵌入式处理器,一次编译多处运行变得日益重要。.NET运行库为C++提供了编译后跨硬件平台的能力。但这更多的是保护遗留的C++代码资产。
最近几年VC的重点回归到native code上,很大程度上也是因为C++用户群对托管平台缺乏足够的兴趣。
What is the future of C++/CLI?
Posted by
Pavel Minaev [MSFT] on 11/15/2008 at 12:31 PM
IMO, it was second-class from the very beginning (e.g. it didn't support ASP.NET, etc). It's still a great tool to integrate native libs into managed apps, and that seems to be its primary niche.
Thanks,
Ayman Shoukry
Visual C++ Team