为什么公共语言运行时不能支持Java [英] Why the Common Language Runtime Cannot Support Java

查看:121
本文介绍了为什么公共语言运行时不能支持Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,公共语言运行时支持多种语言,包括Iron Python和Iron Ruby。我们同样可以在Java Run Time环境中使用J Ruby和J Python。如果是这样的话。为什么.net框架工作的公共语言运行时间不能支持Java?你只是好奇地知道你可能会认为这是一个愚蠢的问题。

Today the Common Language Run Time Supports Many Languages including Iron Python and Iron Ruby. We can similarly can use J Ruby and J Python in Java Run Time environments . If so why the .net frame work common language run time cannot support for Java? Um just curious to know though u may see this as a dumb question .

推荐答案

CLR的实际设计是为了让可以完成运行Java所需的一切。 (实际上,定义IL的方式有一些瑕疵,它们专门用于与Java兼容。)您只需要一种将字节码转换为IL,或者从Java源代码编译为IL的方法。 J#是这样做的一种方式,但使用Java 1.1.4的限制是非常大的。

The CLR was actually designed so that it could do everything required to run Java. (Indeed, there are some warts in the way IL is defined which are there specifically for compatibility with Java.) You just need a way of converting bytecode to IL, or compiling from Java source code to IL. J# was one way of doing this, but the limitation of using Java 1.1.4 was a pretty huge one.

我怀疑不进一步的原因不是将Java作为语言运行的问题,但系统库需要移植的事实。如果您愿意编写类似Java的源代码但是目标是.NET框架库(以及 .NET框架库),那么使用JLS版本切换 java.lang .String System.String 等,这是可行的。我不认为当C#在几乎所有方面都是一种更好的语言时会有很多好处。

I suspect the reason for not going further wasn't an issue with running Java as a language, but the fact that system libraries would need porting. If you were willing to write Java-like source code but target .NET framework libraries (and only .NET framework libraries), with a version of the JLS which switched java.lang.String to System.String etc, it would be doable. I don't think there'd be much benefit though, when C# is simply a nicer language in almost all ways.

你可能有兴趣看一下 IKVM.NET - 在CLI上运行的Java实现。

You may be interested in looking at IKVM.NET though - an implementation of Java running on the CLI.

这篇关于为什么公共语言运行时不能支持Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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