Posted By: Charles | Jun 9th @ 9:18 AM | 37,899 Views | 16 Comments
Ian Carmichael has been working on the CLR team since before Microsoft came up with the .NET branding for our managed platform and the virtual machine that powers it all, the Common Language Runtime. Well, we're getting close to the third major release of the CLR, CLR 4 (V3 was really a service or minor release, but who's counting?).

Back in the good old days prior to V1, Ian was an engineer and a peer of Chris Brumme, Vance Morrison and other top of the line engineers working through the architecture, design and implementation of the CLR. Now, Ian is the GM of CLR and he's at the helm plotting out the course for CLR's future. Necessarily, we had to sit down with him to pick his brain about CLR then, now and tomorrow. Tune in. Get a glimpse into the past and future of the CLR from somebody who's been deeply involved with the advent and evolution of Microsoft's now ubiquitous managed runtime.
Rating:
2
0
aL_
aL_
Rx ftw

i agree with stevo_ on this one, but it seems that everyone is pretty much in agreement here but dont realize it Smiley 
IL is good for a runtime that supports lots of languages, source to native is good for a language that only supports one runtime. Lars is correct in the context of V8 but perhaps not so much in the context of .net [of witch he presumably has far less experience] nothing wrong with that.

stevo does make a great point though, IL is faster to compile than source. and charles, while it is true that IL is source, you must agree that its optimized for jitters more than humans Smiley by the same token, assembly code is source too Smiley i mean, technically it is, but not really in practice for most people. human readable is a relative term i suppose Smiley

il is really bare bones as far as lexing and parsing goes, its bacically just higher order instructions right? c#, vb  js and pretty much all "normal" languages are more optimized for humans so they wont compile as fast i think.

also, consider tooling, if one is to write a tool for .net one only really have to understand IL, not a bunch of native code for various platforms.. thats a huge advantage Smiley

Lars had pretty good experience in VMs, and he had worked on JVMs which are quite similar to CLR in general, I'm sure he's knows enough about bytecodes/IL. I wonder if Charles read my reply in the other thread (CLR4 debugging and profiling API). I was trying to say, when Charles started the topic on IL, Lars was probably still in the context of V8/JavaScript, so he said what he said, and it made perfect sense. Having bytecodes in V8 wouldn't have helped much in keeping the VM fast and simple. And that you'll have to "check twice" if you had bytecodes as a wire format for JavaScript. Charles was in the context of CLR or a more general VMs, the two guys really weren't arguing about the same thing...

Going from source to bytecodes is much easier than getting straight to native code. A lot of JavaScript VMs are imlemented as interpreters, because interpreters are easier to build. So they would interpret bytecodes, and that's the only execution mode they have. V8 also has only one execution mode, and that's compiling straight to native code.

But there are VMs, like TraceMonkey, that use adaptive compilation system, and use bytecode for startup and profiling/tracing, and hot spots get compiled/optimized into native code. That's having two execution modes (or more) in the same system, which leads to complications in design and implementation. Lars had worked on such adaptive compilation systems before, so he knows why it's not suitable for the goal of V8 -- build a fast and simple JavaScript VM in short amount of time.

littleguru
littleguru
<3 Seattle

In my eyes IL isn't similar to C#. It's true that you can execute methods and that everything is organized in classes, namespaces, methods, etc. - but that's more a property of OOP. IL is organized as a stack machine (you clearly see that if you do something with it) and C# is not exposing that at all.

Thanks for clarifying the misunderstanding, Charles Smiley

Well...Walter Bright of Digital Mars doesn't seem to like the idea of having a VM/IL, either. And he designed the D language to have GC without a VM. The interview on CLR4 security changes mentioned you can do unsafe things with native code anyway, so VMs doesn't really buy you that last bit of security; that's OS' job.

My take is that IL is just like what would have been an intermediate representation in between front-ends and back-ends of a conventional compiler; in other words, you're just splitting a compiler into two parts, with some of the machine independent parts packed into a "compiler from source to IL", and machine independent parts with machine dependent parts packed into the VM. Then of course you can interpret IL, but in systems like the CLR, the JIT compiler is what would have been a back end of a conventional compiler, with time-consumption taken into account -- time-costly optimizations can't be performed because it'd hurt startup perf.

So deploying a managed app sounds like...distributing the sources (MSIL), and making sure a compiler (CLR) for the platform is installed. And when the user runs the managed app, CLR compiles the app and runs it. So for M source languages with N target platforms, you'd only have to write M compiler that target MSIL, and N CLR implementations for each platform, that's M+N instead of M*N in a traditional compiler architecture without a standard intermediate representation. JITting has this advantage of being able to dynamically linking libraries, and generating calls into the libraries with less indirection, because the JITter has knowledge of all methods' entry points; NGEN can't do that, so it's throughput is a bit worse than JITted code. That's why they had the troublesome hardbinding in NGEN before CLR4.

And generally bytecodes are easier to verify than native code. That buys you verifiablity, for JVM and CLR, that's important. But bytecodes are actually "harder to verify" than source code, because source languages tend to have more restrictions than their corresponding bytecodes.

Ah, and speaking of compilers...NGEN uses the JIT compilers as CLR does, but used in ahead-of-time compilation mode. NGEN is slow because it compiles everything, while JITting just compiles what's been invoked, so the compilation time is amortized and affordable. If you add up the total time to JIT everything used in a managed program, it'll probably take the same amount of time as NGEN does...

If there's one thing I want to see in the CLR, it's SIMD. If mono can do it, I'm sure Microsoft can too Wink

That's my greatest wish ... for now.

 

Charles please make sure Ian will read this

Ian - wanna happy your customers? Add virtual static Methods/Properties support to CLR as soon as possible.
See links below for details:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=90732
http://msmvps.com/blogs/jon_skeet/archive/2008/08/29/lessons-learned-from-protocol-buffers-part-4-static-interfaces.aspx
and listen one point (from 10) about virtual static methods from Miguel Castro
http://www.dotnetrocks.com/default.aspx?showNum=448

Dynamic features are nice, but don't forget that CLR is mainly static and we are mainly static languages developers if we are using it - right.

Personally such feature will be more usable for me then dynamic keyword in C#.

Microsoft Communities