编译另一种语言到Javascript的实用性? [英] Practicality of compiling another language to Javascript?

查看:106
本文介绍了编译另一种语言到Javascript的实用性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近发布了几个工具,例如睡衣 Scheme2js 允许人们使用Python或Scheme等语言编写代码,并将其编译为Javascript。

Recently several tools have been released such as pyjamas and Scheme2js that allow one to take code in a language such as Python or Scheme and compile it to Javascript.

但这种工具有多实用?

But how practical is such a tool?

我可以看到调试是非常痛苦的,因为你必须调试编译的JavaScript代码本身,并将该代码中的任何错误与原始python / scheme / etc源代码。即使有一个智能的堆栈跟踪,如pajamas -d选项提供,这仍然似乎乏味。

I could see debugging being quite painful as you would have to debug the compiled javascript code itself, and correlate any bugs in that code with the corresponding lines in the original python/scheme/etc source code. Even with an intelligent stack trace such as the pyjamas -d option provides, this still seems tedious.

此外,像jQuery这样的库使编写Javascript更有趣和高效。但对许多开发人员来说,Javascript仍然是一种新的学习语言。

Also, libraries such as jQuery make writing Javascript much more fun and productive. But for many developers Javascript is still a new language to learn.

有人在生产环境中使用编译的Javascript吗?

Has anyone worked with compiled Javascript in a production environment? Any recommendations or comments on the practicality of compiling to Javascript instead of writing your code directly in Javascript?

推荐答案

我相信 GWT (基于Java)可能是此类最受欢迎的产品,但我不会将其描述为将Java编译为JS,而是生成JS代码。虽然我个人分享你的一些疑问,并希望直接代码JS,我不得不承认,它确实是一个非常实用,以及流行的工具,完全生产准备:我观察到,在内部,许多web应用程序是丰富的并且足够复杂以保证前端/后端拆分越来越多地结束为一个Python后端和一个Java前端 - 后者专门允许GWT(当然还有很多Python前端和大量的Python后端,但我认为这是一个趋势)。

I believe GWT, based on Java, may be the most popular product of this kind, though I wouldn't describing it as "compiling Java to JS" but rather as "generating JS code". While I personally share some of your doubts, and would rather code JS directly, I have to admit that it is indeed an extremely practical as well as popular tool, entirely production-ready: I observe that, internally, many web apps that are rich and complex enough to warrant a front-end / back-end split are more and more often ending up as a Python back-end and a Java front-end -- the latter specifically to allow GWT (of course there are also plenty of Python front-ends, and plenty of Python back-ends, but I think this is a trend).

Google Wave使用GWT,可能是最讨厌的网络应用程序使用它到目前为止;以及此处列出的GWT使用网络应用程序的数量巨大,我认为毫无疑问,方法是实用(以及流行的;-)。是否最佳(与在支持中使用良好的框架编写实际的JavaScript)是一个更难回答的问题。

Google Wave uses GWT and is probably the most talked-about web app using it so far; together with the huge number of GWT-using web apps listed here, I think it establishes beyond any doubt that the approach is practical (as well as popular;-). Whether it's optimal (vs. writing actual javascript with a good framework in support) is a harder question to answer.

这篇关于编译另一种语言到Javascript的实用性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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