Jump to content
  • Advertisement
Sign in to follow this  
Ancient Spirit

A question about .NET

This topic is 4657 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Neither .NET nor Java are interpreted (anymore). Both are just-in-time compiled to native code. A significant advantage of .NET is that it was designed to be language-agnostic, so compilers for many different languages have been written for it (C#, VB.NET, PERL.NET, FORTRAN.NET, F#, COBOL.NET, IronPython, C++/CLI, etc). Java bytecode ops can be generated by any language, too (Jython, Processing), but options are relatively few and far between, and those that exist are sometimes limited (Processing, for example).

Currently, Java bytecode is more portable (Solaris, Linux, OS X, Windows), so if that's a primary consideration then go with Java.

Share this post


Link to post
Share on other sites
I know basic Java, and now i also know basic C# (wich is about the same)

It wasnt a question of me trying to choose a lang, I just wanted to know, btw you said that the java code isnt interprated anymore? how so? i mean it does not make an executable file and stuff... no?

Share this post


Link to post
Share on other sites
JVM was designed specifically for the Java language. While it is certainly possible to build a compiler for almost any language that creates Java language binaries, it would pose some challenges and the resulting code might not be as effecient (the JVM bytecode isn't a generic set of CPU like instructions - it contains many language specific opcodes for dealing with Java objects and arrays among other things). By comparison .NET was designed to be language neutral - it provides a mechanism so that most any language can communicate effecient code.

The other major difference is that the JVM was originally designed with bytecode emulation in mind (as stated, most JVM implimentations now compile to native code using Just In Time compiling), while the .NET standard was designed specifically for just in time compiling. This creates a problem as the Java opcodes are optimized for the best emulated execution speed, rather then to preserve high level constructs to provide the best just in time compiling, both for actual binary execution, and for the creation of those binaries (aka the slower then a 486 startup time of even a simple notepad in Java).

Share this post


Link to post
Share on other sites
Quote:
Original post by Ancient Spirit
I know basic Java, and now i also know basic C# (wich is about the same)

It wasnt a question of me trying to choose a lang, I just wanted to know, btw you said that the java code isnt interprated anymore? how so? i mean it does not make an executable file and stuff... no?


Both Java and .NET use a process called Just in Time compiling to generate binary (platform specific) code.

Think of compiling as a two step process.

In the first step, the compiler takes apart your semi-english language code (i = 1;) and turns it into something it can understand. So instead of a bunch of ASCII characters, it now has a set of information it can understand that says you want to set a variable to a specific value.

In the second step, the compiler, now understanding exactly what you want to do, expresses that in machine specific instructions. Often the compiler will optimize for the instruction set it is using, for example doing some math using MMX opcodes (optimization can also come in step 1 by removing redundent instructions).

Both the Java and .NET compilers can be thought of as a half way compiler, one that completes step 1, but leaves step 2 for the Just in Time compiler to do. However the Java compiler, because it was originally designed with interpretation in mind, does a little bit of step 2 as well. The result of this is that not only does the Java JIT have to backtrack a little (decompile some of the Java bytecodes), there is also a "lossy" effect - some of the high level information can be lost in the step 1 process, reducing the effectiveness of the step 2 optimizer.

If you have access through a university (or want to pay), here is a in depth comparison Stacking them up: a Comparison of Virtual Machines. The paper creates a compiler designed to generate both Java bytecode and .NET IL code (Intermediate Language) from the same source file. The main finding is that while .NET is the more optimal solution, some platforms benefit more from Java's legacy ability to be interpretted - specifically very memory limited devices like cellphones that would not be able to JIT compiler Java or .NET in a reasonable amount of time due to the need for complex swapping operations.

Edit: Link to the article if you have an ACM login.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!