Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between the inner workings of Java's JVM and .NET's CLR?

Tags:

java

c#

.net

jvm

clr

What's the difference between the inner workings of Java's JVM and .NET's CLR?

Perhaps a starting point would be, are they basically the same thing in their respective environments (Java > JVM > Machine code) (C# > CLR > IL).


Update: Several people have alluded to the points I was trying to cover:

  1. Garbage Collection
  2. Boxing/Unboxing
  3. JIT debugging
  4. Generics/Templates
  5. Please feel free to suggest other good topics that differentiate the two.

@George Mauer - this sounds very interesting:

Already posted this once but here is a series of interviews with c# chief language designer Anders Hejlsberg.

like image 365
Steve Duitsman Avatar asked Sep 12 '08 14:09

Steve Duitsman


People also ask

Is .NET core similar to JVM?

Net is better than JVM, as JVM simply converts the code into bytecode for underlying operating systems. This is not directed for computing machines and is a bit slower than CLR. Java has many IDEs for its programming like Eclipse, NetBeans, etc.Net, on the other hand, has a Visual Studio.

How does CLR work in C#?

Role of CLR in the execution of a C# program MSIL is machine-independent code. Now CLR comes into existence. CLR provides the services and runtime environment to the MSIL code. Internally CLR includes the JIT(Just-In-Time) compiler which converts the MSIL code to machine code which further executed by CPU.

What is the equivalent to the CLR in Java?

NET CLR is equivalent to JVM (Java Virtual Machine).

Is CLR virtual machine?

The Common Language Runtime (CLR), the virtual machine component of Microsoft . NET Framework, manages the execution of . NET programs. Just-in-time compilation converts the managed code (compiled intermediate language code) into machine instructions which are then executed on the CPU of the computer.


2 Answers

This should be a great thread.

One of the biggest differences is between the CLR and JVM is the CLR"s native integration of generics.

Java instead removes the generic types and the JVM can only work with objects by autoboxing the objects it appears to be pseudo generics.

like image 148
FlySwat Avatar answered Oct 29 '22 18:10

FlySwat


From here. I couldn't have said it better (Well, with the exception of a flame war, this is a flameless place :-) ).

Hello,

Responding to your question seems fraught with peril by starting a flame war, so I'll proceed cautiously.

There are a number of fundamental technical similarities between the Java Runtime and the Common Language Runtime, including garbage collected memory, an intermediate language (Microsoft IL versus Java ByteCode), core system libraries, and support for fairly high level languages, code security, and deployment.

However, each of these 'similar' areas also have a number of sizable and small differences, and it's beyond the scope of a simple Forum post to describe most of them.

I would suggest asking a more targetted question about any of the various runtime features and component areas (e.g. memory management, compilation, system libraries, security, etc.) and then we can provide a more targetted response (e.g. a blog, a technical article, or some books).

like image 27
Vinko Vrsalovic Avatar answered Oct 29 '22 17:10

Vinko Vrsalovic