开发者

any higher-level language that writes out javascript?

I'm looking for a higher-level language that writes out javascript. in other words the relation of this language to javascript is similar to the relation C++ have with assembly code.

The requirements of this higher-level language is type-safety, easy refactoring, able to have classes, inheritance etc (abit like java/C#/vb.net).

The advantage is tha开发者_如何学编程t I can code at this higher level language without having to rely on "hacks" to bring inheritance over to javascript. Moreover i do not have to do any runtime type/duck checks since the higher level language will impose the type-safety limit and the generated javascript will just "do the job".

Additional advantages would be any of the advantages we could have when we code in C++ compared to coding in assembly.

I'm actually going to try and write this higher-level language myself but its too much work and I was wondering if anyone had actually already did something like it.


CoffeeScript.

CoffeeScripts aim is not to have an already existing high level language compile down to JavaScript but to create a new language as a "Better JavaScript than JavaScript".

This is similar to using C++ as a "better C than C".

Of course since it's closer to JavaScript it fully supports all JavaScript features. The compiler is also written in CoffeeScript (JavaScript) itself.


There's Script#, which compiles C# code into JavaScript. Not sure about any limitations it might have, though. There's also jsc, which converts a .NET assembly to JavaScript through decompilation.

Neither, AFK, compile to make use of the new features in ECMAScript 5th edition.


Google Web Toolkit (GWT) Java code to JavaScript as parter of a broader scope. Here's a snippet from the adjacent link:

The GWT SDK provides a set of core Java APIs and Widgets. These allow you to write AJAX applications in Java and then compile the source to highly optimized JavaScript that runs across all browsers, including mobile browsers for Android and the iPhone.

You can, of course compile JavaScript from JavaScript itself with the Google Closure Compiler.

Also checkout this Scott Mitchell's blog article regarding Script#

But, as @Andy E states - nothing claiming to work for ECMAScript5


You should consider having a look at LLVM in combination with emscripten. It will allow you to compile a great deal of languages (including C and C++) into LLVM bitcode and then to JavaScript. This is from their projects page:

Emscripten compiles LLVM bitcode into JavaScript, which makes it possible to compile C and C++ source code to JavaScript (by first compiling it into LLVM bitcode using Clang), which can be run on the web. Emscripten has been used to port large existing C and C++ codebases, for example Python (the standard CPython implementation), the Bullet physics engine, and the eSpeak speech synthesizer, among many others.

One particularly amazing port using this technique is the box2d.js project, which takes the great box2d library and turns it into this amazing demo.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜