Angel \”Java\” Lopez on Blog

April 30, 2010

Working in AjIo: Io-Like interpreter in C#

Filed under: .NET, AjIo, C Sharp, Functional Programming, Open Source Projects — ajlopez @ 12:34 pm

Last year, I discovered Io programming language:

http://www.iolanguage.com/

overview

Io is a prototype-based programming language inspired by Smalltalk (all values are objects, all messages are dynamic), Self (prototype-based), NewtonScript (differential inheritance), Act1 (actors and futures for concurrency), LISP (code is a runtime inspectable/modifiable tree) and Lua (small, embeddable).

It has a simple syntax, and its features are based in functional languages, Smalltalk, Self and others. As usual, I want to write my own version, with a twist: support for native objects. That is, to implement an interpreter over a virtual machine plus class libraries. The current choices are Java or .Net.

Two weeks ago, @MartinSalias pointed me to Io, again. Then, past weekend, I started my own implementation, based only in the written specification. It will be not exactly the same language, and it is still work in progress.

The code is in my Google project AjCodeKata:

http://code.google.com/p/ajcodekatas/

in the trunk, under AjIo folder. There is a .NET solution, with three projects:

The class library is the core, the console program can be used to interact with the interpreter, and the test project has the test I wrote during the design/coding process.

Actually, I have written the lexer, the parser, and the main languages objects, using TDD approach, as usual. You can write:

Some days ago, I implemented the assignment operators (syntax suger over setSlot, newSlot, updateSlot):

but, now, you have native .NET object support:

Next steps:

- Write more comparison operators (I only write ==)
- Native numbers (now, only ints are parsed, but other can be managed, try 1 / 6, it returns a real)
- Precedence in arithmetic operators (now 2 + 2 * 3 returns 12, instead 8)
- for, foreach, range, and more (I only write if())
- block() (I have method())
- include()
- Begin to write some Io library objects

About last point: I should decide how to implements things like:

List clone

Possible approaches:

- List as a derived object (Object clone) with its own slots, wrapping a native list
- List clone returning native ArrayList, then ArrayList type has associated “slots”
- No List, and use directly the native objects

As in AjSharp, original Io has agents and coroutines. I want to add AjSharp features (agents, goroutines, channels, queue channels, futures) to AjIo. Original Io implements agents with virtual machine “threads”: that is, it’s not using operating system threads, the virtual machine executes the many agents code, switching from one code to another during running (I guess, I don’t see the implementation code in Io). I won’t take that approach, in my first attempts.

As usual, I had fun written this stuff!

Keep tuned!

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

5 Comments »

  1. [...] this link: Working in AjIo: Io-Like interpreter in C# « Angel “Java” Lopez on … If you enjoyed this article please consider sharing [...]

    Pingback by Working in AjIo: Io-Like interpreter in C# « Angel “Java” Lopez on … | Source code bank — April 30, 2010 @ 7:05 pm

  2. [...] Working in AjIo: Io-like interpreter in C# [...]

    Pingback by Objects in AjIo (Part 1) « Angel “Java” Lopez on Blog — May 12, 2010 @ 1:50 pm

  3. [...] Working in AjIo: Io-like interpreter in C# [...]

    Pingback by Objetos en AjIo (Parte 1) - Angel "Java" Lopez — May 13, 2010 @ 9:13 am

  4. nice share… thanks

    Comment by Ecko — June 14, 2010 @ 10:25 am


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. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 68 other followers

%d bloggers like this: