Difference between C# and C++ or Java
Hi,
I am not sure when C# came into existence or when and who in microsoft started it but i do not understand the difference between c# or Java or C++ as they are all object oriented languages or in fact they are used to write object oriented programs.
Can anybody suggest me about this doubt.
Re: Difference between C# and C++ or Java
Quote:
Originally Posted by arnabsom
I am not sure when C# came into existence
I came to existence somewhere around year 2000 and was standarized by ECMA in 2003.
Quote:
Originally Posted by arnabsom
and who in microsoft started it
AFAIK it was a project by Microsoft, HP and Intel.
Quote:
Originally Posted by arnabsom
but i do not understand the difference between c# or Java or C++ as they are all object oriented languages or in fact they are used to write object oriented programs.
Well, the are all OO languages with somewhat similar syntax, but they're all different flavours. There are many more OO languages as well. One notable difference between C#/Java and C++ is that C# and Java was designed for running on virtual machines, whereas C++ (build somewhat on top of C) is compiled into platform dependent machine code.
- petter
Re: Difference between C# and C++ or Java
except C# doesnt run on a virtual machine.
Re: Difference between C# and C++ or Java
Quote:
except C# doesnt run on a virtual machine.
... its uses the "Common Language Runtime" (CLR) instead, which has more or less the same purpose as the virtual machines used by for example Smalltalk and Java.
http://en.wikipedia.org/wiki/Common_Language_Runtime
Re: Difference between C# and C++ or Java
except that it is compiled to a native image before execution. The IL is not interpreted during runtime.
Re: Difference between C# and C++ or Java
Quote:
except that it is compiled to a native image before execution. The IL is not interpreted during runtime.
Are you using NGen?
http://www.codeguru.com/Csharp/.NET/...cle.php/c4651/
Re: Difference between C# and C++ or Java
ngen creates a "permanent" (albeit a very fragile) version of what gets generated at runtime.
Re: Difference between C# and C++ or Java
Quote:
Originally Posted by MadHatter
except that it is compiled to a native image before execution. The IL is not interpreted during runtime.
Known as JIT (Just-in-time) compilations... Java does that aswell.
- petter
Re: Difference between C# and C++ or Java
I was under the impression that their jitc still included dynamic translation durning runtime.
Re: Difference between C# and C++ or Java
Quote:
Originally Posted by MadHatter
I was under the impression that their jitc still included dynamic translation durning runtime.
I'm sure it's a mix of both, but how does that differ from a C# application containing a mix of Early-Bound, Late-Bound and Lightweight Code Generation?
- petter
Re: Difference between C# and C++ or Java
one interprets byte code and the other doesnt. afaik .net does not use the concept of a "virtual machine" in the same sence as early java apps do. code generation, compilation of an assembly and execution of that image is different than dynamic translation of bytecode to cpu instruction. personally I wouldnt call .net's bootstrap executable that loads up the .net assembly and compiles it a virtual machine, because it doesnt emulate hardware at runtime, but instead compiles source code to a native instruction set.
Re: Difference between C# and C++ or Java
Quote:
Originally Posted by MadHatter
one interprets byte code and the other doesnt. afaik .net does not use the concept of a "virtual machine" in the same sence as early java apps do.
I agree if were talking pre-JIT, but it's a long time since JIT was introduced.
Quote:
Originally Posted by MadHatter
personally I wouldnt call .net's bootstrap executable that loads up the .net assembly and compiles it a virtual machine, because it doesnt emulate hardware at runtime, but instead compiles source code to a native instruction set.
But it doesn't do that with late-bound code. AFAIK that is 'translated' on the fly. Or am I totally wrong here?
- petter
Re: Difference between C# and C++ or Java
I have never seen a single document to suggest that il is ever interpreted.
I have however read documentation on how assemblies are loaded (whether bound at application start up or later on) as well as changes in .net architecture between .net 1.1 to 2.0 in matters of reflection. for instance under 1.1 reflection info was laid out in unmanaged space. When you'd call GetMethod("Foo") that it loaded every single method of that type in to unmanaged memory and would do so at every request. in 2.0 thats been pulled into the managed heap and lazily initialized (and privy to the GC). that would suggest to me that even late bound code--while assembly meta data is used for inspection--is fully compiled and loaded / executed like any other native library compiled to a native image.
if there is any documentation (or somebody can show that this is the case) on the matter, I'd love to see it, but everything I've ever read on .net said that assemblies are completely compiled at start up, and are executed as any other non-.net assembly after that.
Re: Difference between C# and C++ or Java
Is there a online source available (preferably an independent source) that compares the speed between C# and Java (preferably a late model JDK) when they run the same programs?
Re: Difference between C# and C++ or Java
Quote:
Originally Posted by MadHatter
except C# doesnt run on a virtual machine.
of course it does.. all apps run in a virtual machine. take your thinking out of the box for a moment, and consider what electrons, the cpu, bios, hal, operating system, .net framework actually are..