Is there a Coffeescript for Java? In other words X gets compiled to Java [closed]

两盒软妹~` 提交于 2020-01-01 01:30:50

问题


Is there a language that gets compiled to Java code (not Byte code but Java .. so no Groovy, Scala, Jython, JRuby etc.)?

In other words is there a CoffeeScript for Java?

One of the major flaws I have against Java is that its so damn verbose and that it doesn't have multiple inheritance. It seems reasonably that one could just clean up the syntax add mixins/traits and closures through code generation.

Yeah its not elegant but coffeescript does it.


回答1:


Yep, Xtend. It's a new language brought to you by the Eclipse folks: http://www.eclipse.org/xtend/

No multiple inheritance (that would be a fundamental change to Java semantics), but lots of syntactic sugar, just like CoffeeScript.

Also take a look at Mirah: http://www.mirah.org/




回答2:


If you think about it, CoffeeScript compiling to Javascript means you can use coffeescript itself as a Java language. With the latest CoffeeScript (1.1.3) you might need to use Rhino directly because it triggers a JS implementation bug in the current jdk, but outside of that, you should be good to use the compiled js files to interact with Java code. :)




回答3:


I wrote a pre-processor for text files that introduces {s and }s where there was indentation. I called it:

  • Significant-White-Space (SWS)

It is nowhere near stable, and it doesn't address some of the other shortcuts you point out that Coffeescript offers, but it does work as a proof-of-concept.




回答4:


I wrote a transcompiler (just like CoffeeScript) to Java that supports multiple inheritance. It is very buggy and limited and does not allow many flexible formatting options, but it is still there and I would be more than happy if you checked it out or made a branch from it to improve it. I will probably add more features and fix many of the bugs, but for now, it at least works.

https://github.com/Philoprogrammer/Java-With-Multiple-Inheritance



来源:https://stackoverflow.com/questions/8246132/is-there-a-coffeescript-for-java-in-other-words-x-gets-compiled-to-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!