Angel \”Java\” Lopez on Blog

December 12, 2012

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

Filed under: AjTalk, C Sharp, Open Source Projects, Programming Languages, Smalltalk — ajlopez @ 2:11 pm

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#:

https://github.com/ajlopez/AjTalk

There is a small Hello, World:

nil subclass:#Object
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Objects'
!

Object subclass:#Program
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Objects'
!

!Program class methods!

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

At repo:

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

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

http://www.ajlopez.com

http://twitter.com/ajlopez

2 Comments »

  1. [...] Previous Post [...]

    Pingback by AjTalk In C# (2): A Simple Web Server « Angel ”Java” Lopez on Blog — December 15, 2012 @ 7:52 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 65 other followers

%d bloggers like this: