C ++,C#和JavaScript上的WinRT [英] C++, C# and JavaScript on WinRT

查看:213
本文介绍了C ++,C#和JavaScript上的WinRT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从下面的图片,Windows 8的平台和工具。我知道这意味着我可以使用C ++,C#或JavaScript的Metro风格应用。我也看一些版本的主题演讲中,我有几个问题在这里。


  1. 请他们在C ++,C#和JavaScript在WinRT的,例如有什么区别性能,功能,性能等。

  2. 如何创建的本地地铁应用程序使用JavaScript,我是否需要使用JS库从MS或者我可以使用任何JS我熟悉的,例如jQuery的。

  3. 在Metro风格应用程序,系统服务只有WinRT的,这是否意味着我不能使用低级别的dll了吗?这将配备性能成本?


解决方案

关于#1,阵容将大致如下:

JavaScript的 - 最高级别,动态类型,GC。您只能使用HTML5 / CSS为你的用户界面,在XAML框架( Windows.UI.XAML 命名空间)不可用。提供了一些标准的JS的API(由HTML5指定)除的Win​​RT,可用表面,如本地存储或索引资料。而动态类型,CPU的大量绑定的处理很可能是比任何.NET或C ++慢一些,但JS引擎仍然是非常快的,由于是JIT编译和重优化。你可以消耗C ++和.NET WinRT的组成部分,但不是写自己的JS。语言投影的一些方面似乎要相应地限制 - 例如到目前为止,我所看到的,有没有办法实现的JS WinRT的接口,例如。现有的JS库通常可以没有或极少的努力重用,只要他们IE10工作。

.NET(C#/ VB) - 中等水平,具有可选的动态类型(动态关键字等)和GC静态类型。 XAML UI框架是UI默认的,但你也可以使用的WebView 控制使用HTML。提供完全访问的WinRT库,但也有一些自身最重要的是,它们有时使用起来更方便(如 VS IInputStream / IOutputStream )。此外,唯一一个包括异步操作的特殊的语言级支持(异步等待关键字),这是大量使用WinRT的使用API​​时,由于其高度异步设计。一般来说,提供了大部分的语法糖 - 除了异步的东西,你得到的LINQ to对象(其中工程超过WinRT的集合)。可以编写自己的WinRT的组件,然后可以从JS或C ++ / CX使用。现有的.NET库可能会或可能不容易重用,这取决于他们依靠哪些类在.NET框架上; Silverlight的或WP7写入部件最有可能是可重复使用的,没有或最小的变化,而组件写入用于.NET 4全或客户端配置文件可能需要显著变化来运行。

C ++ / CX(的Visual C ++组件扩展) - 低/中等水平,静态类型,没有GC - 只引用计数。最接近金属,在它的对象模型的设计直接与无阻抗失配映射到的WinRT - 因此引用计数 - 但仍然高层次足以避免样板,并普遍安全的使用(如例外,而不是的HRESULT,串见过作为对象,而不是把手,的dynamic_cast ,而不是的QueryInterface 等)。无需额外的图层,代理对象你和WinRT的间等,所有来电都是直接。在大多数情况下,最快的全部三个,虽然确切的差别而变化显著取决于具体的任务,并且可以是微不足道对于一些(没有或很少的计算如事件驱动的应用程序),以及相当的其他人(例如,解析或重数学)。 UI故事是相同的.NET。此外,你提供给你整个C ++标准库,以及A​​TL的一个子集。可以编写自己的WinRT的组件,然后可以从JS或.NET使用。现有的C ++库可能会或可能不容易重用,这取决于它们使用哪些API;那些严格依赖于标准的C / C ++通常会在不改变工作,而那些调用Win32 API的,如果他们依靠地铁的应用程序容器不可用的API可能会带来问题。


关于#3,此视频 - <一个href=\"http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-789C\">http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-789C - 应该回答有关使用的Win32(我presume什么是低层次DLL的意思),从地铁的应用程序大部分的问题。请注意,虽然视频是关于C ++的,这也完全适用于C#,为的P / Invoke和COM互操作仍然存在。所以,如果你可以从C ++调用它,你可以从C#调用它。

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.

  1. Do they have any difference in C++, C# and JavaScript on WinRT, e.g. performance, feature, capability etc.
  2. 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.
  3. 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?

解决方案

Regarding #1, the line-up would be roughly as follows:

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) - 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++ 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.


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#.

这篇关于C ++,C#和JavaScript上的WinRT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆