实施C#的JVM

问题描述:

时的任何人试图实施C#的JVM?作为一个Java开发人员,我已经盯上了C#嫉妒,但我不愿意放弃JVM的便携性和成熟度,更何况它的工具多元化。

Is anyone attempting to implement C# for the JVM? As a Java developer, I've been eyeing C# with envy, but am unwilling to give up the portability and maturity of the JVM, not to mention the diverse range of tools for it.

我知道有JVM和CLR之间的重要差别,但有什么这是一个搅局者?

I know there are some important differences between the JVM and CLR but is there anything that is a showstopper?

有CLR和JVM之间非常显著差异。

There are very significant differences between the CLR and the JVM.

举几个例子:


  • Java没有用户定义的值类型

  • 的Java仿制药是的完全的不同到.NET泛型

  • C#的许多方面取决于框架的要素 - 代表等你需要的端口图书馆以及,甚至的语言的方面。

  • Java没有在JVM级别支持之类的属性和事件。你可以伪造一些,但它不会是相同的。

  • 我不相信Java有任何等同于传递通过定位参数,即使是在JVM级

  • 细微之处做的不同的内存模型将很可能咬,虽然我不知道有多少是在C#规范。

  • 不安全的代码一般可能是不可能的Java

  • 互操作性本机代码是JNI和P /调用之间有很大不同。这可能不是太大的问题,给你。

  • 您不得不假的操作符重载和用户定义的转换

  • Java doesn't have user-defined value types
  • Java generics is completely different to .NET generics
  • Many aspects of C# depend on elements of the framework - delegates etc. You'd need to port the library as well, even for language aspects.
  • Java doesn't support things like properties and events at a JVM level. You could fake some of this, but it wouldn't be the same.
  • I don't believe Java has any equivalent to pass-by-reference parameters, even at the JVM level
  • Subtleties to do with the different memory models would quite possibly bite, although I'm not sure how much is in the C# spec.
  • Unsafe code in general probably isn't possible in Java
  • Interoperability with native code is very different between JNI and P/Invoke. This probably isn't much of a problem for you.
  • You'd have to fake operator overloading and user-defined conversions

你很可能端口的很多的C#的 - 但你会留下一个漂亮的不满意体验,IMO

You could probably port a lot of C# - but you'd be left with a pretty unsatisfactory experience, IMO.

走另一条路,你知道 IKVM ?它允许您运行.NET Java代码。

Going the other way, are you aware of IKVM? It allows you to run Java code in .NET.