Daily Archives: December 12, 2012

AjTalk in C# (1): A minimal Hello, World image

Next Post

If you read this blog (and have the patience to follow me at Twitter ;-), you already know I was busy working on my AjTalk Smalltalk-like VM written in C#:


There is a small Hello, World:

nil subclass:#Object

Object subclass:#Program

!Program class methods!

main @System.Console writeLine: 'Hello, world'! !

At repo:


It coud be smaller, but the Program main is the entry point of a saved image. The console program can generate an image using

ajtalk Programas/HelloWorld.st –s hello.im

and then, launch the image with

ajtalk hello.im

In this case, AjTalk looks for a global Program with a method main, and if it exists, it will be invoked.

The @ notation for @System.Console is the way to refer to a native .NET type.

Note that I don’t load all the class library, only the classes that I need for run the image. AjTalk can manage many Smalltalk machines in memory, each one with its own classes and methods. I have implemented a way of manipulating one machine from another, so you don’t need, in principle, to have a complete environment in machine A. So, I can produce minimal image, if I remove the classes and methods I don’t use. Instead of having a big image in memory, and cut the fat, my running machines born light by design. This is an example of “thinking out of the box”: for decades, Smalltalk developers thought on having only one image, and were struggling on how to make it an smaller one. My approach is totally different: make the VM so it can manage many machine/images in memory, so one can be manipulated from another one.

I should write more about the current implementation and features (and issues to solve), like: remote objects, object methods, processes, semaphores, multithreading, native access, save/load images, internal AST, visitors, code generation for JavaScript, bytecodes in compiled blocks, modules (loosly inspired in Python import,  and Node.js require), environments (to avoid class name collision), and more.

Keep tuned!

Angel “Java” Lopez