Compiling to .net with Smart Mobile Studio
You are probably thinking this is too good to be true, but it’s not. In fact, I have a working prototype already (although it needs a hell of a lot of work). But since people seem to think this is either a blatant lie, or that I’m doing black magic to get this working, I’m going to explain how I do it!
In fact, I have provided links to all the parts you need on this post, so you can download, compile and play around with the tech yourself. But first, some context 🙂
Since Smart Mobile Studio has been in sale for a couple of years I don’t think I need to explain or prove that point as well.
But .net is a completely different beast. But only when you are looking at .net from the outside. I am also a C# developer so I also look at Delphi and Smart from inside C#.
In short: The .net framework has one huge advantage over native languages, and that is something called reflection. Reflection is not just RTTI, like some people have voiced. It’s also the ability to hot-swap code modules in a living program, because bytecodes are just that – byte codes. Since .net is a “virtual language” you can do all sorts of cool stuff with it, like changing a program at runtime.
But the one feature that sets .net apart from Java, which works pretty much along the same lines, is the ability to also emit code. Thats right, you can take a class and emit it to disk from you program. But it doesn’t stop there.
You can also compile new code from within your own program, by building something called expression-trees. This is pretty much what all compilers does (including smart mobile studio), because an expression-tree is a fancy way of saying “AST”.
So you can programmatically build up a full expression tree from within your C# program.
Any bells ring yet?
He he. What you do is of-course to construct an expression-tree and then use the emitter to dump that as an assembly, and voila — you have in fact generated a separate, self-sustaining assembly! It’s a bit more complex than that, but essentially that’s how you do it.
The other kids are doing it
Pretty cool right? The speed benefits alone are phenomenal, because the assembly is compiled to highly optimized machine code when it’s loaded the first time.
What about Smart Mobile Studio?
Will this become a part of Smart Mobile Studio?
Time will tell. We have more than enough work on our plates to start throwing .net into the mix right now, but I do find the route interesting. It would represent a much better way than the one Borland started ages ago, since the Smart Pascal dialect would be 100% retained. We have already gotten rid of pointers, so Smart Pascal is perfectly suited for the .net framework. You wouldn’t even need to think about .net, just write ordinary Smart Pascal.
Why should this be cool?
It opens up XBOX development first and foremost, followed by native Mono and Desktop development. This means you can write games that targets both HTML5, Mobile and XBOX with the same codebase. That should make developers happy I think.
And then there is ASP.net to think about. Thats probably one of the most important technologies in my view.
Well — fun thing to play with!