Windows 开发人员中心-桌面-入门-选择技术

Windows 开发人员中心-桌面-入门-选择技术

翻译开始时间:2014-05-17T20:05

翻译结束时间:2014-05-18T20:34

译者:hoxily@qq.com

欢迎指出错误与不足之处。

原文版权归微软所有,本译文版权采用GPL。

----

Choose Your Technology

选择适合你的技术

http://msdn.microsoft.com/library/windows/desktop/dn614993.aspx


When you want to create a new desktop app, the first decision you make is whether to use the Win32 and COM API or .NET. Both options let you create desktop apps like Word, Excel, and Photoshop that run in the classic Windows desktop and take full advantage of that environment's specific features.

当你想要创建新的桌面应用时,你首先面临的选择就是到底是采用Win32加COM API还是.NET。这两个选项都能让你创建像Word、Excel以及Photoshop那样运行于经典的Windows桌面的应用并且充分利用那种环境的特有的特性。

Here are a few of the major differences between Wind32 and .NET technologies and when they are appropriate to use:

下面是一些关于Win32与.NET技术之间的主要差异以及什么时候适合使用:

NET/XAML:

.NET/XAML:

  • Languages: C#, C++, F#, VB

  • 语言:C#、C++、F#、VB

  • Best if you need to have a higher level of coding and productivity, or to use a less complex language for which it might be easier to hire talent.

  • 适用于当你需要上层编码和高生产效率,或者使用一种较少复杂度的语言来达到较容易地雇拥到人才时。

  • You can also share some .NET Framework code and libraries between Windows Store, Windows Phone, Windows desktop applications, and other Microsoft platforms by using portable class libraries.

  • 同时你也能通过使用可移植的类库来做到在Windows Store、Windows Phone、Windows桌面应用以及微软其他平台之间共享某些.NET框架代码和库。

C++ and Win32:

C++和Win32:

  • Languages: C++ with COM

  • 语言:C++加COM

  • Best if you need to achieve the highest levels of performance or efficiency, access native OS features, or want to target DirectX technologies.

  • 适用于当你追求高执行性能或者效率、访问本地操作系统特性或者针对DirectX技术。

  • C++ and Win32 gets you "closer to the metal," and lets you achieve the best performance for your app by taking direct control over memory allocation and performance-oriented CPU features like SSE or AVX instructions. It is the best way to target DirectX technologies for low-level, high-performance graphics access.

  • C++和Win32让你接近本质,让你为你的应用获得最佳执行性能,借助直接控制内存分配管理和以性能为导向的CPU特性,比如SSE或者AVX指令。它是针对DirectX技术适用于底层、高性能图像利用的最好方法。

  • You can share C++ code between Windows, Windows Phone, and Windows Store, as well as with non-Windows platforms.

  • 你可以在Windows、Windows Phone以及Windows Store之间共享C++代码,和Windows之外的平台一样。

Choose .NET

选择.NET

.NET provides a consistent, first-class development experience across the desktop, Windows Phone, and Windows Store. It offers a higher level of coding and productivity. .NET allows you to keep developing foundational apps on the desktop and add exciting new experiences, all while using your existing skills and reusing code between devices. If you are looking to create more tailored, platform-appropriate experiences on any device, Visual Studio Industry Partners (VSIP) provide solutions that enable re-using C# skills and code with non-Windows devices.

.NET提供了一致的、优秀的横跨桌面、Windows Phone以及Windows Store的开发体验。它提供了上层编码和高产生率。.NET允许你保持开发基本的桌面应用的同时,还能让你使用已有的技能与代码在各种设备之间增加新体验。如果你想在任何设备上创造更加定制的、适合平台的经验,那么Visual Studio Industry Partners(VSIP)将会提供能在非Windows设备上重用C#技能和代码的解决方案。

In addition to features you expect such as files/streams and network communication, here are a few highlights of what .NET offers to make building applications very productive:

除了你希望的特性,比如文件/流以及网络通讯,下面还列出了一些.NET提供的能使得创建应用更加富有成效的精彩之处:

  • *Runtime productivity and safety such as automatic memory management, type safety, exception handling, and thread management

  • *运期时生产率和安全,比如自动的内存管理、类型安全、异常处理以及线程管理

  • *GUI technologies – see below

  • *GUI技术-见下

  • *Rich collection data types

  • *丰富的集合数据类型

  • *Data modeling (ADO, LINQ, WCF data services)

  • *数据建模(ADO、LINQ、WCF数据服务)

  • *Language Integrated Query (LINQ)

  • *语言集成查询(LINQ)

  • *Date and time library

  • *日期和时间处理库

  • *Serialization

  • *序列化

  • *Web services

  • *Web服务

  • *Security and cryptography

  • *安全和加密

  • *Parallel programming library

  • *并行编程库

Choose a UI stack: Desktop applications can choose between two UI stacks. Data-centric applications benefit from data binding features in both for displaying data. The following provides guidance on choosing between the two UI stacks:

选择一种UI框架:桌面应用程序可以在两种UI框架间选择。在这两种框架下数据集中型应用展示数据都能从数据绑定特性中获益。下面提供了有关两种UI框架选择的指导:

  • *.NET Windows Presentation Foundation (WPF): This is the preferred technology for Windows-based desktop applications that require UI complexity, styles customization, and graphics-intensive scenarios for the desktop. WPF also takes advantage of XAML views. You can leverage the new simplified asynchronous capabilities (async/await) in .NET 4.5. WPF development skills are similar to Windows Store development skills, so migration from WPF to Windows Store apps is easier than migration from Windows Forms.

  • *.NET Windows Presentation Foundation(WPF):这个框架技术针对于基于Windows的,需要复杂UI、定制化样式以及图形图像集中型的桌面应用。WPF同样具有XAML视图的优势。你可以利用.NET4.5中新的简化的异步能力(async/await)。因为WPF开发技能与Windows Store开发技能相似,所以从WPF迁移到Windows Store应用要比从Windows Forms迁移容易一些。

  • *.NET Windows Forms: This was the first UI technology in the .NET Framework for building desktop applications. It is still a good fit for many business desktop applications. Windows Forms is easier to use and lighter weight than WPF for simple scenarios. Windows Forms does not use XAML, so deciding later to extend your application to Windows Phone or Windows Store entails a complete re-write of your UI.

  • *.NET Windows Forms:这个框架是.NET Framework中第一个用于创建桌面应用的UI技术。它依然适用于许多商业桌面应用。相比WPF,对于一些简单的场景,Windows Forms更易于使用和轻量。Windows Forms不使用XAML,所以如果以后决定扩展你的应用到Windows Phone或者Windows Store你得自己承担完全重写UI的重任。

Other capabilities .NET provides multiple innovations to you to extend your app to new platforms without changes in the architecture. You can often re-use code, and the following .NET features make that easier:

其他能力:.NET提供了多种创造性的新方法,让你能在不改变架构的情况下扩展你的应用到新平台。你能经常重用代码,以下是一些让移植与重用更容易的.NET特性:

  • *Model-View-ViewModel design pattern (MVVM): Microsoft client platforms (including WPF) make it easy to build applications using the MVVM pattern. With this pattern you get a strong separation of display from application state, logic, and behaviors, which will help you to create clean and maintainable code that can be easily shared between multiple devices.

  • *模型-视图-视图模型设计模式(MVVM):微软客户端平台(包括WPF)借助MVVM模式让创建应用更容易。借助这个模式你可以比较彻底地将展示与应用状态、逻辑和行为分开,帮助你创建干净且可维护的代码,从而在多种设备之间容易地分享使用代码。

  • *Portable class libraries: .NET portable libraries allow binaries to be shared between multiple platforms such as the desktop, Windows Store, Windows Phone, and other applications. Implementing your client logic with .NET portable libraries will greatly simplify the creation of multiple experiences on multiple platforms.

  • *可移植的类库:.NET可移植库允许二进制文件在多个平台间共享,比如桌面、Windows Store、Windows Phone以及其他应用平台。用.NET可移植库来实现你的客户端逻辑将会大大简化多平台多体验的创建。

  • *Modernize your user experience: Concepts that are demanded by today’s users can be implemented with the latest innovations on .NET for the desktop. Design principles such as “fast and fluid,” “authentically digital,” or “do more with less” can be applied to your existing desktop application by employing a modern UI for your XAML design, carefully using animations, and implementing .NET asynchronous programming extensively.

  • *使你的用户体验现代化:如今的用户要求的概念能用最新的.NET创新方法在桌面实现。设计原则比如“快速和灵活”、“真正的数字化”或者“用更少的花费做更多的事”可以被应用到你现有的桌面应用,通过为你的XAML设计部署现代UI、小心地使用动画和扩展性地实现.NET异步编程。

For further reading and more depth, there is a description of .NET technologies and guidance for various applications in .NET Technology Guide for Business Applications for which there is a summary.

针对深入阅读和更深入研究,可以阅读关于.NET技术和指导的描述总结——《关于商业应用的.NET技术指导》。


Choosing C++ and Win32

选择C++和Win32

C++ provides a first-class development experience across a wide range of platforms, both Windows and non-Windows, without depending on a high-level runtime environment like .NET. This makes C++ the language of choice for portable applications when such runtimes are unavailable or too heavyweight for certain target platforms.

C++提供了一流的横跨大多数平台的开发体验,包括Windows和非Windows平台,不依赖于像.NET这样的高层运行时环境。这使得C++语言成为移植应用的一种选择,当这样的运行时不可用或者对目标平台太过重量级。

Using C++ and the Win32 API makes it possible to achieve the highest levels of performance and efficiency by taking tighter control of the target platform than the .NET runtime allows. However, exercising such a level of control over your application's execution requires greater care and attention to get right, and trades development productivity for runtime performance.

使用C++和Win32 API使得通过相比.NET运行时所允许的更加紧密地控制目标平台达到最高的执行性能和效率成为可能。然而,在你的应用运行中行使这样层级的控制要求更加关心和注意来弄清楚,并且这是用开发的生产效率与运行时性能作交易。

Here are a few highlights of what C++ offers to enable you to build high-performance applications.

下面是一些C++提供的能让你创建高性能应用的优势。

  • *Hardware-level optimizations, including tight control over resource allocation, object lifetimes, data layout, alignment, byte packing, and more.

  • *硬件级别的优化,包括对资源分配、对象生命周期、数据布局、对齐、字节封装以及更多。

  • *Access to performance-oriented instruction sets like SSE and AVX through intrinsic functions.

  • *使用面向性能的指令集,比如内在函数(intrinsic functions)中的SSE(流式SIMD扩展指令集)和AVX(高级矢量扩展指令集)。

  • *Efficient, type-safe generic programming by using templates.

  • *高效率,基于模板的类型安全的范型编程。

  • *Efficient and safe containers and algorithms.

  • *高效率且安全的容器与算法。

  • *DirectX—in particular Direct3D and DirectCompute.

  • *含DirectX特别是Direct3D和DirectCompute。

  • *C++ AMP

  • *C++ AMP(C++大规模并行加速)

C++ for games and graphics-rich applications

C++被用于游戏和图形图像丰富的应用

If there's one domain where C++ is the clear winner, games is it -- or apps that demand similar levels of graphics and processing performance. C++ is ideally suited to these kinds of apps because it enables the programmer to manage resources and object lifetimes explicitly; it provides access to hardware-level optimization opportunities; it can access DirectX and other performance-oriented Win32 libraries more directly than a managed language; and it makes available a number of quality game development libraries.

如果要说在哪个领域C++是无可争辩的赢家,那正是游戏——或者说那些对图形图像等级和处理性能需求与此相当的应用。C++是理想的适合于这些类型的应用,这是因为它让程序员能明确地管理资源与对象生命周期;它提供了使用硬件层次优化的机会;相比其他托管语言,它能更加直接地使用DirectX以及其他面向性能的Win32库;它让大量高质量游戏开发库可用。

Even while there are great technologies available for making games that are less performance intensive in managed languages like C#, the managed environment makes it difficult or impossible to match the level of performance that can be achieved by C++ developers. When absolute performance is the goal or when any overhead is too much--as when bringing big experiences to small devices--C++ is the go-to language.

尽管还有许多技术用于创建游戏,比如性能集中稍低的托管语言中的C#,托管的环境使得难以甚至不可能匹配C++开发人员所能达到的性能等级。当绝对性能成为目标或者当任意开销都显得太多——像是将巨大的体验带到小型设备上——C++就是首选的语言。

C++ for traditional desktop applications

C++被用于传统的桌面应用

Writing a traditional, UI-heavy desktop application—like a spreadsheet, word processor, or line-of-business application—in C++ makes the most sense when the application is computationally intensive, or when there is a substantial amount of existing C++ code that you can use to build it. Otherwise, managed languages have adequate performance and the .NET ecosystem offers increased productivity due to its more-modern application and UI frameworks, and its more-capable standard library.

用C++编写一个传统的、大量UI的桌面应用——像是电子表格、字处理或者行业软件——非常有意义,当应用是计算密集型或者当可以用已有的大量数量的现有的C++代码来创建应用时。否则,托管的语言拥有足够的性能并且.NET生态系统提供了大大增强的生产效率,因为.NET的更现代化应用与UI框架以及.NET更加能干的标准库。

When writing a desktop application in C++, you can choose MFC or Win32 for the UI, or a host of third-party application frameworks that also support non-Windows platforms.

当你使用C++写桌面应用时,你可以选择MFC或者Win32来创建UI,或者同时能支持非Windows平台的第三方应用框架宿主。

  • *MFC (Microsoft Foundation Class Library): This is the venerable application framework and UI library that has served Windows developers since 1992. It's a thin C++ wrapper over the handle-based, C-language Win32 API and provides object-oriented interfaces for many of the predefined windows, common controls, and other Windows objects. Although many modern UI frameworks in the .NET ecosystem surpass MFC in convenience, it is still the native UI framework of choice for many C++ developers creating applications for the Windows desktop.

  • *MFC(微软基础类库<sup>[1]</sup>):这是珍贵的应用框架和UI库,它从1992年开始就为Windows开发者服务。它是一个瘦小的C++封装,将基于句柄的C语言Win32 API封装起来,并且为许多预定义的窗体、通用控件以及其他Windows对象提供了面向对象的接口。尽管.NET生态系统中的许多现代UI框架在便捷性上超越了MFC,MFC依然是许多C++开发人员选择的本地UI框架,用于创建Windows桌面应用。

  • *Win32: This is the handle-based, C-language API of the Windows platform, including but not limited to UI functionality such as windowing, drawing, and UI controls. Because it is a low-level, C-language API based on handles, it's an infrequent choice for creating modern, UI-intensive apps. However, it supplies the basic APIs necessary to interact with the Windows platform, and is a suitable choice for apps that have simple UI requirements or that just want the Windows UI to stay out of the way as much as possible—for example, games.

  • *Win32:这是Windows平台的基于句柄的C语言API,包括但不限于UI功能,例如开窗口、绘制以及UI控件。因为它是一个低层次的基于句柄的C语言API,所以它不是一个常见的用于创建现代的、重UI应用的选择。然而它提供了必要的基本的API,用于与Windows平台交互。它是一个合适的选择,用于创建简单UI需求或者仅仅想要Windows UI尽可能滚一边儿去的游戏项目。

  • *Third-party application frameworks: Because C++ can run on a wide variety of platforms and isn't tied to Windows or the .NET runtime, third-parties have developed new application and UI frameworks for C++ to ease development of cross-platform applications with rich user interfaces. Some of these frameworks provide their own look & feel, while others—such as wxWidgets or Qt—use or emulate the native control set of the platform. Using these libraries, it's possible to share nearly all of an application's source code between versions of the application that run on Windows or other platforms, such as OSX or Linux.

  • *第三方应用框架:因为C++能够运行在一个很大范围的平台上,并且并没有绑死在Windows或者.NET运行时上,所以第三方为C++开发了新的应用与UI框架,让丰富用户界面的跨平台应用开发更加轻松。其中的某些框架提供了他们独有的视觉和感觉;另一些则是尽可能直接使用或者模拟本地平台的控件集的视觉和感觉,比如wxWidgets和Qt。通过使用这些UI库,在Windows或者其他平台间分享一个程序的几乎全部源码成为可能,比如OSX与Linux平台。


Conclusion

结论

You may have a strong affinity to C++ or C#/Visual Basic, and that may determine how you choose to write desktop applications. Use .NET/C# (or Visual Basic) for high level coding, more productivity, rich frameworks and services, support for modern customer experiences, and cross platform maintenance of assets (Windows Store apps, Windows Phone apps, Windows desktop apps, and others). Use native C++ for games and other graphics-intensive applications, when you need to achieve the highest levels of performance, to manage resources or memory layout explicitly, to access hardware-level optimization opportunities, when you want your application to be portable to platforms without the .NET runtime, or to more readily take advantage of freely available, high-quality C and C++ libraries that exists.

你可能对C++或者C#/VisualBasic特别的情有独钟,这会影响你选择何种框架来编写桌面应用。使用.NET/C#(或者Visual Basic)的优势有高层次的编码、高生产效率、丰富的框架和服务、对现代客户体验的支持、跨平台的资源维护(Windows Store应用、Windows Phone应用、Windows桌面应用以及其他)。为游戏和其他图形图像集中型应用使用本地的C++,当你需要达到最高级别的性能时,当你想要明确地管理资源或者内存布局时,当你想要使用硬件级别的优化机会时,当你想要你的应用移植到没有.NET运行时的平台时,当你想要更容易地利用现有的自由可用的、高质量的C和C++库时。

译者注

[1] 微软基础类库听起来像微软的内裤!MFC是没饭吃的拼音首字母,来自肖东爽。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值