First Stop: VMs, Compilers, and Modularity
In April 2007, I embarked on a long journey. A journey on which I already met a lot of interesting people, learned many fascinating things, and had a lot of fun implementing programming languages. It all started on this day in 2007. At least if I can trust the date of my first commit on CSOM to my SVN server back then. A lot has happened in the last 10 years, and, perhaps mostly for myself, I wanted to recount some of the projects I was involved in.
It all started with me wanting to know more about the low-level things that I kind of avoided during my bachelor studies. I have been programming since a long time, but never really knew how it all actually worked. So, I inscribed in the excellent Virtual Machines (VMs) course, which was taught by Michael Haupt at the time. I also took a course on Software Design, in which I studied Traits.
Why do I mention traits? Well, I had been using PHP since 2000 or so. It was my language of choice. And to understand Traits better, I decided the best way would be to implement them for PHP. So, more work on language implementations. I have to admit, the main reason I didn’t just study them in Squeak Smalltalk was because Squeak looked silly and I didn’t like it. I guess, I was just stubborn. And that stubbornness caused me to inflict traits on PHP as part of my first venture into programming language design.
As a result, my traits for PHP were released about 5 years later with PHP 5.4. So, it took a lot of stubbornness… Fun fact: Wikipedia explains traits with a PHP example, perhaps because PHP is one of the few curly-brace languages that is relatively close to the Smalltalk traits design.
Meanwhile, in the VM course, we started to look in detail into a little Smalltalk called SOM (Simple Object Machine). Specifically, we worked with CSOM, the C implementation of SOM. Together with a fellow student, I chose a rather ambitious topic: build a just-in-time (JIT) compiler for SOM. Well, in the end, I think, he did most of the work. And I learned more than I could have imagined. In our final presentation we reported performance gains of 20% to 55%. The JIT compiler itself was a baseline compiler that translated bytecodes one by one to x86 machine code. The only fancy thing it did was to supporting hybrid stack frames, i.e., using essentially the C stack, but still providing a full object representation of the stack as Smalltalk context objects.
This JIT compiler project was a lot of fun, but also a lot of headache… Perhaps not something, I’d generally recommend as a first project. However, after the VM course, and the work on traits, I was really interested to continue and learn more about VMs and modularity, and perhaps also combine it with the hyped aspect-oriented, feature-oriented, and context-oriented programming ideas, which I haven’t taken the time to study yet.
Under the guidance of Michael and Robert Hirschfeld, I started the work on my master thesis, which resulted in a Virtual Machine Architecture Definition Language (VMADL). VMADL combined ideas of feature-oriented and aspect-oriented programming to allow us to build a VM product line: CSOM/PL. It used CSOM, from the VM course, and combined the results of the various student projects. So, one could built a CSOM for instance with native or green threads, with a reference counting GC, or a traditional mark/sweep GC, and so on. It was all based on a common code base of service modules, which were linked together with combiners that used aspects to weave in necessary functionality at points explicitly exposed by the service modules. Since that is all very brief and abstract, the CSOM/PL paper is probably a better place to read up on it.
I guess, that’s enough for today. Since this only covers the first few steps until summer 2008, there is more to come on:
- supporting all kind of concurrency models on a simple VM
- performance, performance, and metaprogramming
- and safe combination of concurrency models