views:

110

answers:

2

Hi, I just want to ask whether I am right or not about .NET. So, .NET is new framework that enables you to easily implement new and old windows functions. It is similar to java in the way that its also compiled into "bytecode", but its name is Common Language Infrastructure, or CLI. This language is interpreted by .NET Framework, so code generated by programming using .NET cannot be executed directly by CPU. Now, few languages can be compiled to CLI. First, it was Microsoft-developed C#, than J#, C++ others. I suspect that this is in general right, at least I hope I understand it right.

But, what I am still missing is, can you write to machine code compiled code in C#? And, if using Visual Studio 2005, when I select Win32 project, it is compiled into machine code, so only thing you need to run this apps are windows dynamic-link libraries, since static libraries code is implemented into app during linking phase. And those dynamic-link libraries are implemented in every windows installation, or provided by DirectX installations.

But when I select CLR in Visual Studio 2005, than app is compiled into CLI code, and it first executes .NET framework, and than .NET framework executes that program, since its not in machine code.

So, I am right? I ask because you can read these infos on the internet, but I have no one to tell me whether I understand it right or not. Thanks.

+2  A: 

.NET's first IDE came 2002, so .NET is eight years old. A whole eternity ;)

.NET started with C#, Basic and J# as well as C++. Many other languages followed, for example in the field of dynamic languages IronRuby. With C# and Basic there is no option to generate code that does not require the .NET framework, with C++ you have that option. So no, with the standard tools you can't compile C# to machine code.

There are things to optimizes runtime (pre JITting the assembly, have a look at ngen). It's jitted and not always interpreted, so it's a way faster than a VB script for example. This isn't usually done each time but the first time executing one assembly or with ngen while installing an application.

HTH, -sa

Sascha
You can NGen a .NET assembly. It generates a native image (=machine code) of it. Still, it is impossible to run this native image without the .NET framework. So in a sense it is not really plain old machine code.
Steven
I thought NGen had options to inline all dependencies so you could generate native images which did not need the .net framework to run... EDIT: Ahh.. not with NGen but with RemoteSoft from salamander you can produce executables which do not require the .net framework to be installed. Pricey though: http://www.remotesoft.com/linker/intro.html
Sam Holder
+2  A: 
  • CLI is not interpreted by the .NET framework, but normally compiled. Pure interpretation wold be too slow.
  • C#, J# etc. came at the same time. In fact, J# originates in Microsoft J++.... so one can say it was there earlier. C++ was also there before, you possibly mean Managed C++ (NOW: C++/CLI). I think that was done same time - in parallel. There are more than 2-3 people working at microosft ;)
  • You can not write C# to machine code. A win32 project is native C++ (i.e. the version not using the .NET runtime).
TomTom