Why doesn't Sun do a C# to Java byte code compiler?

后端 未结 18 1862
清酒与你
清酒与你 2021-02-01 01:20

We Want to Run Our C# Code on the JVM

My company has a large C# code base. Well over half of this code is our core engine for creating, reading, modifying, calculating

相关标签:
18条回答
  • 2021-02-01 01:48

    I know this might not be what your looking for, but here are some possible alternatives that (if not to you) could be useful to others.

    1. C: You could port as much as possible to C. Now you can make a wrapper in C# and Java (and any other language that can communicate with C) that makes it feel native to their language while programming. The problem now is that you (or them, depending your license) has to build the C part for each platform.

    2. Fantom*: A programming language that according to their home page, is:

      • Portable: Write code portable to the Java VM, .NET CLR, and JavaScript in the browser.
      • Familiar: Syntax Java and C# programmers will feel at home with Fantom's evolutionary syntax.
      • Object Oriented: Everything subclasses from Obj. Value types when you need the performance.
      • Functional: Functions and closures are baked in.
      • Static and Dynamically Typed: Don't like the extremes - take the middle of the road.
    3. Haxe*: (pronounced hex) is cross platform language that compiles to other languages. Soon C# and Java will be supported. It currently supports:

      • Javascript: You can compile a Haxe program to a single .js file. You can access the typed browser DOM APIs with autocompletion support, and all the dependencies will be resolved at compilation time.

      • Flash: You can compile a Haxe program to a .swf file. Haxe is compatible with Flash Players 6 to 10, with either "old" Flash 8 API or newest AS3/Flash9+ API. Haxe offers very good performance and language features to develop Flash content.

      • NekoVM: You can compile a Haxe program to NekoVM bytecode. This can be used for server-side programming such as dynamic webpages (using mod_neko for Apache) and also for command-line or desktop applications, since NekoVM can be embedded and extended with some other DLL.

      • PHP: You can compile a Haxe program to .php files. This will enable you to use a high level strictly-typed language such as haXe while keeping full compatibility with your existing server platform and libraries.

      • C++: You can now generate C++ code from your Haxe source code, with the required Makefiles. This is very useful for creating native applications, for instance in iPhone development.

      Haxe Community. (2011, March 11). Haxe Introduction. Retrieved January 29, 2011, from http://old.haxe.org/doc/intro

      You can learn more about why Haxe is useful here.

    *I have never used this language and I don't know how well this would work.

    0 讨论(0)
  • 2021-02-01 01:49

    I made a comment that should really have been an answer:

    It is just not technically possible at this point to implement the C# spec on the JVM. C# supports pointers, unsigned types, user defined value types, true generics, passing by reference, and loads of other things. For a very C#-like JVM language, check out Stab.

    Mainsoft fakes it. I am sure it takes enormous effort on their part.

    0 讨论(0)
  • 2021-02-01 01:52

    http://jsc.sourceforge.net/ is a c# cross compiler that can convert .NET code to Java (amongst other things).

    0 讨论(0)
  • 2021-02-01 01:55

    Joe Erickson wrote:

    Making it easier to run C# code on the Java platform means more developers and more software for the platform.

    This is an untrue statement. Running C# code on the JVM does not create Java programmers, it creates C# programmers who can execute on a JVM. It only expands the reach of C#, assuming the JVM also translates any microsoft specific calls (i.e. win32) into something that is platform neutral. So if Sun translates IL to Java Bytecode, the only group it helps is: Microsoft. And, given Sun's history with Microsoft during the original C#-Java schism/Visual J++ lawsuits...

    Plus, you have to face the technical infeasibility, whether you want to or not. There are fundamental differences in the way the bytecodes are executed that are far more important issues than whether or not there's an unsigned long datatype.

    If you must have C# on a non-Microsoft platform, use Mono

    0 讨论(0)
  • 2021-02-01 01:56

    There must be a good reason. I just cannot for the life of me figure out what it is...

    It is easy to believe that companies are non-profit organisations which have your interests at heart. It is easy to forget that the only purpose for a listed company is to make money for it share holders. This is a legal obligation and directors/executives have been sacked/sued if share holders don't believe they have failed to do this.

    Sun makes Java free because it helps sell their hardware which how it makes money from Java. IBM makes Java free because it helps them make more money on their consulting.

    If Sun were to spend money on a C# converter how would it make that money back and make a profit. Imagine you have to convince Sun's share holders. If you can, Sun will make a C# converter.

    0 讨论(0)
  • 2021-02-01 01:56

    Simple. Because Sun would rather not be sued by Microsoft. And while we as programmers might see no viable reason for a suit, keep in mind that Microsoft is quite a bigger company than Sun and has the power to boss them around.

    Sun fortunately is in the position of being quite more open than Microsoft however. If such a demand exists, either open source or a third-party could make this compiler for Java and Sun wouldn't have to take the heat.

    0 讨论(0)
提交回复
热议问题