what's mojito?

Mojito is an interpreted object-oriented language, featuring five built-in dynamic types (objects, lists, numbers and strings) and support for writing extensions in Python (and thus also in C/C++).

Its interpreter is written in Python (developed and tested on Python 2.2.1) using the Spark parsing module (version 0.6.1). A re-writing the interpreter in C++ is planned, while there are no plans for replacing the parser (unless I find someone so kind to teach me how to be productive with Bison and Flex :).

So, what's new about it?

The fact is: the interpreter doesn't understand anything about objects, classes, factories, methods and such. It can see nothing but a root node having any number of child nodes which can be either branches (i.e. they can have other child nodes) or leaves (either strings, numbers, lists or functions). You can easily understand how object-oriented programming techniques can be applied to such a back-end. Function nodes have access to two special nodes, parent (guess what? the parent object) and local (nodes created in this branch are destroyed when function returns).

The language itself is quite simple to understand, most of its syntax being inherited from C/C++/Perl/Java; however, it retains some lexical enhancements that might result useful. First of all, every instruction (except for import, create, destroy, break and return statements) results in a return value: everything is an expression (or an object, if you prefer :).

Why would I need mojito?

Actually you don't need it at all: mojito doesn't fill any empty niche in the programming language landscape (except for your alcoholic needs after having spent a night fighting against that fsck'ed compiler). Mojito indeed fills several niches in my professional landscape... and all in all it's a nice language.

What can I do with mojito?

You can do with mojito almost everything you can do with Your Preferred Very High Level Language (TM). Actually, mojito's design allows the creation of wrappers around all kinds of modules of the impressive Python standard library; I'll create some by myself too.


import io;

create n = 4;

while n {
    io.stdout.write('hello, world!'_);
    n -= 1;

Generated parse tree

[domenico@wks mojito] ./mojito.py -f hello_world.moj
version 0.0.1a1
+  << program >>
    +  << import >>
        -  io
    +  << create= >>
        -  n
        +  << num_literal >>
            -  4.0
    +  << while >>
        +  << var >>
            -  n
        +  << suite >>
            +  << call >>
                +  << - >>>
                    +  << - >>>
                        -  io
                        -  stdout
                    -  write
                +  << arglist 1 >>
                    +  << string_literal >>
                        -  hello, world!
            +  << -= >>
                +  << var >>
                    -  n
                +  << num_literal >>
                    -  1.0