Daily Archives: November 29, 2012

Working on AjTalk: Smalltalk VM, C# version

After working on my Node.js distributed examples (Genetic Algorithms), and my Python interpreter (Spanish Post, GitHub repo), I went back to work on AjTalk, my Smalltalk VM implementation. I have three projects (C# version, Java version, JavaScript/NodeJs version), but now I’m working on the C# one.

The past weeks, I added a simple/naive but functional save/load binary images, and I have a new bytecode compiler: instead of parsing code and directly generates the bytecodes, AjTalk builds an AST-like structure in memory, and using visitors, it can generate the bytecodes (past year, I had implemented a visitor that transforms the AST to JavaScript code, to use in my JavaScript VM version). The visitor pattern could be used to generate different outcomes using the same AST input (litmus test: a third visitor generating Python, Ruby or C# code (in this case, using dynamic objects)).

I can load more than one Machine at the same time: in my jargon, a Machine has the objects and classes of a living image. Instead of being a singleton, I can create, populate and load from images more than a Machine. The main code at:

https://github.com/ajlopez/AjTalk/blob/master/Src/AjTalk/Machine.cs

I could generate a minimal image for a hello world (< 300 bytes!), see the code at:

https://github.com/ajlopez/AjTalk/blob/master/Src/AjTalk.Console/Programs/HelloWorld.st

I exercised the parsers loading and executing the Pharo file outs:

https://github.com/ajlopez/AjTalk/blob/master/Src/AjTalk.Tests/CodeFiles/PharoCoreKernelObjects.st
https://github.com/ajlopez/AjTalk/blob/master/Src/AjTalk.Tests/CodeFiles/PharoKernelNumbers.st
https://github.com/ajlopez/AjTalk/blob/master/Src/AjTalk.Tests/CodeFiles/PharoKernelClasses.st

All written using TDD, as usual 🙂

Now I have many machines in memory, I would like to implement this idea:

– Load a Machine A (with its classes, methods, objects) having a complete class library
– Load a Machine B, having only some classes and objects
– Set Machine A to be the host of Machine B.
– Reimplement #doesNotUnderstand message processing in Machine B so, if a message is not located in that machine, the search of the corresponding method continues in the similar classes at Machine A. In this way, I could use all the power of Machine A, to operate on a slim Machine B. Machine A could have all the development tools/classes/methods, meanwhile Machine B still have a minimal size. A similar ideas is being explored by @morplenauta (Squeak committer), see Spanish email list.

Another project: to have a minimal static files web server, using native .NET objects (System.NET).

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez