Compilers and platforms
By tdw on Nov 19, 2004
I was reading a blog the other day about Solaris on x86 and SPARC and the benefits to customers of being able to simply recompile their source to get it to run on the other platform, and it got me thinking that there must be an easier way.
On an internal mail alias here at Sun, I read something a couple of weeks ago which talked about how much better the Sun compilers are than GCC (or perhaps, how much faster the code produced is), and that one of the advantages the Sun compilers have is the generation of an intermediate code representation (ILF?) prior to (IIRC) the final code generation step.
So what I'm thinking is why can't users simply compile their code using the Sun compilers and have it leave the result in this intermediate form? We could then have an interpreter/translator/code-generator on each platform which when called to run the "binary" converts to platform specific assembler and runs it.
I'm reliably informed by a colleague that this is pretty much what .NET does, with the CLR providing the actual platform implementation, and the idea has been around much longer than that (probably even longer than I've been in computing).
It just strikes me that it would make life a lot easier for customers and ISV's and Sun could then write the CLR's for the various platforms and OS's. In fact, if Sun were really keen on OpenSource, they could even publish the ILF spec and allow people to write their own runtime environments.
I'm sure that there are some pretty substantial downsides to this idea, otherwise people in Sun with far bigger brains than me would have already put this into production, but it's food for thought for any of you compiler bods out there.