NekoML done !

posted on 2005-10-15

This week I was quite busy working on NekoML. NekoML is a programming language with an ML type system using type inference and unification. It is quite similar to OCaml but have the following differences :

  • the syntax is different, and more like C or Java syntax, using curly braces for blocks
  • several hacks have been added, especially for the operation + which can take two integers or two floats or two strings
  • there is a lexer library (based on Alain Frisch ULex) that you can use to define lexers at runtime using pure NekoML syntax (ocaml uses ocamlllex which is a compile-time preprocessor with enhanced syntax)
  • streams and streams parsers are directly in the language (ocaml uses camlp4 preprocessor)
  • all values carry their own printers so you can print any value and it will be displayed nicely using NekoML constructors

And most important point is that NekoML compiler generates Neko source code. So you can use Neko Virtual Machine to run NekoML, or write some libraries in NekoML and some others in MotionTypes or other Neko-supported languages.

So the people that know about OCaml might ask what is the point of having a staticly typed programming language running on top of a dynamicly typed VM ? That’s true that’s not the best choice for speed-oriented applications since you can’t generate very efficient native code such as ocaml, but otoh you can use the dynamic features of the Neko language, which are really useful when you want for example :

  • interact with the outer world : databases, serialization…. since you always have the types at runtime, you can handle things better (without crashes)
  • interact with other languages, since you have a common representation and low-level semantics
  • use dynamic linking in order to load plugins at runtime
  • do “low level dynamicly yped” stuff by directly embedding Neko source in a NekoML program

All this together makes NekoML the language of choice for writing language compilers targeting Neko. Next step is to rewrite the NekoML compiler… in NekoML. Once this is done the language will be fully bootstrapped and after I take some time reorganizing and completing standard libraries I can make a Neko 1.1 release that will not use ocaml anymore.

Leave a Reply

You must be logged in to post a comment.