Well i couldn't resist the temptation of trying to program directly in ILassembly
to be honnest it's not that ugly language(if it weren't managed it would be kewl)

well here's my first attempt (whatever you think it's assembly) :)
to run/assemble you need .net framework offcourse

.assembly extern mscorlib
{// never change these values
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 1:0:5000:0
.assembly extern System.Windows.Forms
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 1:0:5000:0
.assembly helloworld
.namespace Hello_world
.class public Hello_world
.method static void Main()
ldstr "Hello everybody"
ldstr "Developed in IL"
call value class [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]
System.Windows.Forms.MessageBox::Show(class System.String, class System.String)
Posted on 2004-06-12 09:15:59 by czubin
What makes you think you could write different/better code than the compiler will, using IL? :)
Posted on 2004-06-12 10:41:19 by Scali
Sergie lind <hope I spelled name right creator of ilasm for Microsoft said you can do things in ilasm that C# does not support. So perhaps you can do better than the compiler. But thats the fault of the C# compiler.
Posted on 2004-06-12 11:20:21 by ThoughtCriminal
yup, you can do things in ILAsm that you can't do in the various lenguages that creates IL, which is used for obfuscators.

But with regards to making more efficient IL than a compiler? Ho humm, it's going to be JIT'ed anyway.
Posted on 2004-06-12 11:25:53 by f0dder
yes, you can do a lot of things not avaible in the .net language
there are some special vb.net assemblies that C# can't acces but C# can do so much more then vb.net

and all of the three language compilers outputs are different
and most of these outputs aren't optimized ,there are some (not free)programs out there wich allows optimizing
the one I made was assembled to only 2KB a similar one compiled in C# is 16KB size

it's not impressive nor needed to program directly in IL assembly but
that goes the same for native assembly, it's just having some controll or how the program works :)

One mayor disavantage it's compiled at runtime wich looses speed
on the other hand , i can run it on linux , mac os and the java platform

well .net compilers are for me as HLL compilers are to you

hope that wasen't boring ;)
Posted on 2004-06-12 12:55:34 by czubin
Managed C++ can also do things that C# can't do. I don't see why people think C# == .NET.

One mayor disavantage it's compiled at runtime wich looses speed

Not quite. Firstly, the compiled code is cached, so the code is only compiled once for the lifetime of the program, so the compilation time gets negligible.
Secondly, you can also opt to compile on installation.
Posted on 2004-06-12 13:02:35 by Scali

only 2KB a similar one compiled in C# is 16KB size

Who cares about so small size differences, as long as the size is some runtime lib overhead, and not linear 2x growth? :)

One mayor disavantage it's compiled at runtime wich looses speed

Well, not necessarily... JIT has the theoretical advantage that the IL can be optimized for the CPU it's run on. Like, there's "some" difference in how to optimize, depending on whether you target Athlon or P4. Also, a JITer could theoretically profile the execution path of the code, and generate more optimal code. So... JITed IL can, if implemented properly, actually beat natively compiled code.

But that's all theory - I dunno how well MS's JITter is. I assume it's "pretty good", but that there's also a lot of room for improvement.
Posted on 2004-06-12 13:07:12 by f0dder

the one I made was assembled to only 2KB a similar one compiled in C# is 16KB size

Which has probably only to do with padding and the version resource the C# compiler includes by default.

If you compile this code manually:

using System.Windows.Forms;

namespace HelloWorld
class HelloWorld
static void Main(string[] args)
MessageBox.Show("Hello everybody", "Developed in C#");

csc /o small.cs

The output will be 3kb. The extra kb is because the executable has a .rsrc section which czubin's version doesn't. I couldn't find a compiler switch to prevent a version resource from being included but if you disassemble the output and assemble it again (ildasm->ilasm) without the resource, the executable will be 2kb. Also, if you look at the disassembly you will find it to be nearly the same as czubin's code, except for that the C# compiler also built a constructor for the HelloWorld class.

Posted on 2004-06-12 13:24:35 by Thomas
oh well before anyone makes a quote about the size again ,
I wasn't impressed too, I was just wanting to say C# compiler makes a different output ;)
Posted on 2004-06-12 13:46:40 by czubin