C++, C# and JavaScript on WinRT(WinRT 上的 C++、C# 和 JavaScript)
问题描述
从下图中,Windows 8 平台和工具.我知道这意味着我可以将 C++、C# 或 JavaScript 用于 Metro 风格的应用程序.我还观看了一些构建的主题演讲,在这里我有几个问题.
From image below, Windows 8 Platform and tools. I know this mean I can use C++, C# or JavaScript for Metro style App. I also watch some build's keynote and I have couple of questions here.
Windows 8 平台和工具 http://www.windowsitpro.com/content/内容/140554/windows8-platform-tools_2.jpg
- 他们在 WinRT 上的 C++、C# 和 JavaScript 有什么区别吗?性能、特性、能力等.
- 如何使用 JavaScript 创建 native Metro App,我需要使用 MS 的 js 库还是可以使用我熟悉的任何 js,例如 jQuery.
- 在 Metro 风格的 App 中,系统服务只有 WinRT,这是否意味着我不能再使用低级 dll 了?这会带来性能成本吗?
- Do they have any difference in C++, C# and JavaScript on WinRT, e.g. performance, feature, capability etc.
- How can I create native Metro App using JavaScript, do I need to use js library from MS or I can use whatever js that I familiar with, for example jQuery.
- In Metro style App, System Services is only WinRT, does this mean I can't use low-level dll anymore? Will this come with performance cost?
推荐答案
关于#1,阵容大致如下:
Regarding #1, the line-up would be roughly as follows:
JavaScript - 最高级别、动态类型、GC.您的 UI 只能使用 HTML5/CSS,XAML 框架(Windows.UI.XAML
命名空间)不可用.除了 WinRT 的可用表面之外,还提供一些标准的 JS API(由 HTML5 指定),例如本地存储或 IndexedDB.作为动态类型,繁重的 CPU 密集型处理可能比 .NET 或 C++ 慢,尽管由于 JIT 编译和高度优化,JS 引擎仍然非常快.您可以使用 C++ 和 .NET WinRT 组件,但不能用 JS 编写自己的组件.语言投射的某些方面似乎相应地受到限制 - 例如.据我所知,例如,没有办法在 JS 中实现 WinRT 接口.现有的 JS 库通常可以毫不费力地重用,只要它们在 IE10 中工作即可.
JavaScript - highest-level, dynamically typed, GC. You can only use HTML5/CSS for your UI, the XAML framework (Windows.UI.XAML
namespace) is not available. Provides some standard JS APIs (specified by HTML5) in addition to the available surface of WinRT, such as local storage or IndexedDB. Being dynamically typed, heavy CPU-bound processing is likely to be slower than either .NET or C++, though the JS engine is still very fast due to being JIT-compiled and heavily optimized. You can consume C++ and .NET WinRT components, but not write your own in JS. Some aspects of language projection seem to be limited correspondingly - e.g. so far as I can see, there's no way to implement a WinRT interface in JS, for example. Existing JS libraries can usually be reused with no or minimal effort, so long as they work in IE10.
.NET (C#/VB) - 中级,静态类型,可选动态类型(dynamic
关键字等)和 GC.XAML UI 框架是 UI 的默认框架,但您也可以通过 WebView
控件使用 HTML.提供对 WinRT 库的完全访问,此外还提供一些自己的库,有时使用起来更方便(例如 Stream
与 IInputStream
/IOutputStream代码>).此外,唯一一个包括对异步操作(
async
和 await
关键字)的特殊语言级别支持,由于其高度异步设计,在使用 WinRT API 时会大量使用这些操作.一般来说,它提供了大多数语法糖——除了异步的东西,你可以得到 LINQ 到对象(它在 WinRT 集合上工作).可以编写自己的 WinRT 组件,然后可以从 JS 或 C++/CX 中使用.现有的 .NET 库可能会或可能不会很容易地重用,这取决于它们所依赖的 .NET Framework 中的类;为 Silverlight 或 WP7 编写的组件最有可能无需更改或只需很少更改即可重用,而为 .NET 4 Full 或 Client Profile 编写的组件可能需要进行重大更改才能运行.
.NET (C#/VB) - mid-level, statically typed with optional dynamic typing (dynamic
keyword etc) and GC. XAML UI framework is the default one for UI, but you can also use HTML by using WebView
control. Provides full access to WinRT libraries, but also some of its own on top of that, which are sometimes more convenient to use (e.g. Stream
vs IInputStream
/IOutputStream
). Also, the only one that includes special language-level support for asynchronous operations (async
and await
keywords), which are used heavily when using WinRT APIs due to their highly asynchronous design. Generally speaking, provides most syntactic sugar - aside from async stuff, you get LINQ to objects (which works over WinRT collections). Can write your own WinRT components, which can then be used from JS or C++/CX. Existing .NET libraries may or may not be readily reusable, depending on what classes in .NET Framework they rely on; components written for Silverlight or WP7 are most likely to be reusable with no or minimal changes, while components written for .NET 4 Full or Client Profile may require significant changes to run.
C++/CX(Visual C++ 组件扩展) - 低/中级,静态类型,无 GC - 仅引用计数.最接近金属",因为它的对象模型被设计为直接映射到 WinRT,没有阻抗不匹配——因此是引用计数——但仍然足够高级,可以避免样板文件并且通常可以安全使用(例如,异常而不是 HRESULT,看到的字符串作为对象而不是句柄,dynamic_cast
而不是 QueryInterface
等).您和 WinRT 之间没有额外的层、代理对象等,所有调用都是直接的.在大多数情况下,这三者中最快的,尽管确切的差异取决于具体任务而有很大差异,并且对于某些(例如,没有或很少计算的事件驱动应用程序)来说可能是微不足道的,而对于其他人(例如解析或繁重的数学)来说可能是相当大的).UI 故事与 .NET 相同.此外,您还可以获得整个 C++ 标准库,以及 ATL 的一个子集.可以编写自己的 WinRT 组件,然后可以从 JS 或 .NET 中使用.现有的 C++ 库可能容易重用,也可能不容易重用,这取决于它们使用的 API;那些严格依赖标准 C/C++ 的应用程序通常无需更改即可工作,而那些调用 Win32 API 的应用程序如果依赖于 Metro 应用容器中不可用的 API,则可能会出现问题.
C++/CX (Visual C++ Component Extensions) - low/mid-level, statically typed, no GC - refcounting only. Closest "to the metal" in that its object model is designed to map directly to WinRT with no impedance mismatch - hence refcounting - but still high-level enough to avoid boilerplate and be generally safe to use (e.g. exceptions rather than HRESULTs, strings seen as objects and not handles, dynamic_cast
rather than QueryInterface
etc). No additional layers, proxy objects etc between you and WinRT, all calls are direct. In most cases, fastest of all three, though the exact difference varies significantly depending on the specific task, and can be minuscule for some (e.g. event-driven app with no or little computation), and considerable for others (e.g. parsing or heavy math). UI story is same as for .NET. In addition, you get the entire C++ standard library available to you, as well as a subset of ATL. Can write your own WinRT components, which can then be used from JS or .NET. Existing C++ libraries may or may not be readily reusable, depending on which APIs they use; those that relies strictly on Standard C/C++ will usually work with no changes, while those that call Win32 APIs may pose a problem if they rely on APIs not available in Metro app container.
关于#3,这个视频 - http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-789C - 应该回答您关于 Metro 应用程序中使用 Win32(我认为是低级 DLL"的意思)的大部分问题.请注意,虽然视频是关于 C++ 的,但这也完全适用于 C#,因为 P/Invoke 和 COM 互操作仍然存在.因此,如果您可以从 C++ 调用它,那么您可以从 C# 调用它.
Regarding #3, this video - http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-789C - should answer most of your questions regarding the use of Win32 (which I presume what "low-level DLL" means) from Metro apps. Note that while the video is about C++, this also fully applies to C#, as P/Invoke and COM Interop are still there. So if you can call it from C++, you can call it from C#.
这篇关于WinRT 上的 C++、C# 和 JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:WinRT 上的 C++、C# 和 JavaScript
基础教程推荐
- SSE 浮点算术是否可重现? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01