javascript 什么是 Microsoft 的 .NET GWT 解决方案?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5698649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is Microsoft's GWT solution for .NET?
提问by orad
I like GWT but I prefer to use ASP.NET MVC for my projects, however, these two are not integrated and require me to write my code in two different platforms and two languages. Does Microsoft have any solutions comparable to GWT for compiling C# into JavaScript? I know there is Script# which is not supported by MS and the Volta project which was killed after its preview, but I was wondering if there is any good solutions available now or at least some good open source project that can integrate ASP.NET with GWT. Thanks.
我喜欢 GWT,但我更喜欢在我的项目中使用 ASP.NET MVC,但是,这两者没有集成,需要我用两种不同的平台和两种语言编写代码。Microsoft 是否有任何可与 GWT 相媲美的将 C# 编译为 JavaScript 的解决方案?我知道有 Script# 不受 MS 支持,Volta 项目在预览后被终止,但我想知道现在是否有任何好的解决方案,或者至少有一些好的开源项目可以将 ASP.NET 与GWT。谢谢。
采纳答案by Yishai
Bridge.NETis in this space. It describes itself as:
Bridge.NET就在这个领域。它把自己描述为:
Open Source C# to JavaScript Compiler and Frameworks. Run Your App On Any Device Using JavaScript.
将 C# 开源到 JavaScript 编译器和框架。使用 JavaScript 在任何设备上运行您的应用程序。
The Microsoft driven solution is TypeScriptwhich is a separate language made with input from the lead architect of C#, Anders Hejlsberg. It is also open source.
Microsoft 驱动的解决方案是TypeScript,它是一种独立的语言,由 C# 的首席架构师 Anders Hejlsberg 提供。它也是开源的。
回答by DuckMaestro
Well, I can tell you what my preferred stack looks like these days. To me it is a nice balance of established tech with flexibility, though keep in mind I use this mostly to build single-page ajax "apps", not for the traditional collection of pages.
好吧,我可以告诉你我最近喜欢的堆栈是什么样的。对我来说,这是既定技术与灵活性的良好平衡,但请记住,我主要使用它来构建单页 ajax“应用程序”,而不是用于传统的页面集合。
- Sharp UI(full disclosure: this is one of my open source projects)
- Script#
- jQuery
- I use a tool I wrote internally for generating "packet" classes shared by WCF and Script#.
- WCF (in JSON)
- ASP.NET (either Webforms or MVC)
- Sharp UI(完全披露:这是我的开源项目之一)
- 脚本#
- jQuery
- 我使用我在内部编写的工具来生成 WCF 和 Script# 共享的“数据包”类。
- WCF(在 JSON 中)
- ASP.NET(Webforms 或 MVC)
I get compile-time type checking from Script#, UI control encapsulation from Sharp UI, fairly easy to maintain JSON service endpoints through WCF and my code generation tool, and ASP.NET for misc or traditional web pages. I'm firing on all 8 cylinders with this setup.
我从 Script# 获得编译时类型检查,从 Sharp UI 获得 UI 控件封装,通过 WCF 和我的代码生成工具相当容易维护 JSON 服务端点,以及用于其他或传统网页的 ASP.NET。我用这个设置在所有 8 个气缸上开火。
回答by ianmayo
Good suggestion, but as AFAIK there is absolutely nothing like GWT in the .Net world.
好的建议,但作为 AFAIK,在 .Net 世界中绝对没有像 GWT 这样的东西。
I'm a Java and .Net programmer. I've battled infrequently with javascript for about 3 years, and never become comfortable with it. Since adopting GWT I'm producing Javascript=based web pages but coding in Java - I absolutely adore it ;-)
我是一名 Java 和 .Net 程序员。大约 3 年以来,我很少与 javascript 作斗争,但从未适应过它。自从采用 GWT 以来,我正在制作基于 Javascript 的网页,但使用 Java 进行编码 - 我非常喜欢它 ;-)
There's no great reason why there can't be a .Net equivalant of GWT. GWT doesn't do a 'literal copy' of Java to produce the Javascript - so it doesn't rely on the two languages having a 'similar' grammer. Any language could be converted. Mind you, it would take a lot of effort to duplicate the analysis and optimisation performed by the GWT compiler in producing it's js files.
没有很好的理由说明为什么不能有 GWT 的 .Net 等效项。GWT 不做 Java 的“文字副本”来生成 Javascript - 因此它不依赖于具有“相似”语法的两种语言。任何语言都可以转换。请注意,复制 GWT 编译器在生成其 js 文件时执行的分析和优化需要付出很多努力。
A more effective route may be to find a C# to Java converter, and then pass the output to GWT.
更有效的途径可能是找到一个 C# 到 Java 的转换器,然后将输出传递给 GWT。
回答by user1618323
SharpKit for C# .NET is like GWT but actually does much more. They even have a CLR written entirely in Javascript that provides Reflection, Generics, etc. on the client.
C# .NET 的 SharpKit 类似于 GWT,但实际上做得更多。他们甚至有一个完全用 Javascript 编写的 CLR,可以在客户端提供反射、泛型等。