Friday, November 11, 2011

HaXe and OCaml (and Racket ?)

(x-post from G+)


The more I look at HaXe as a hedge against the uncertainty in the Flash world, the more I like it. The only reason I've resisted promoting it in the workplace is the fact that the underlying toolchain (the compiler) is written in OCaml - a language I don't know and have never wanted to know, given that I have already spent the time to climb the Haskell learning curve.

The Adobe news this week made me reconsider, and I have been researching the OCaml language and ecosystem. It is not an inferior Haskell, and in many ways seems more practical. That fact that it has a stable bytecode format is really nice - especially when there are projects like this that translate the bytecode to Javascript: http://ocsigen.org/js_of_ocaml/

Then there is this LLVM language implementation tutorial that uses OCaml: http://llvm.org/docs/tutorial/OCamlLangImpl1.html

I've been shopping around for a new systems programming language to replace Java (if Java can be considered a systems programming language). The languages I like, Clojure and Erlang, are both tied to VMs and the languages I really-really like, Prolog and Scheme, are not - for me - good systems languages. OCaml feels like it could be the one.

I am using DrRacket (the Racket Scheme IDE) for more and more of my UI prototyping experiments and would hate to abandon that (especially since OCaml's default graphics library uses X11). So I am thinking about ways to bring OCaml into my DrRacket environment - either through the FFI or by hacking the bytecode->JS translator to emit Scheme instead.

I'm looking forward to getting my bytecode hacking mojo back !

2 comments:

Sarino said...

Hi, Nick:

Sorry, off topic: You've probably moved on from your swi-prolog / racket interop project, but I wonder what versions of racket and swi prolog you used. I keep getting crashes on Ubuntu 64-bit using racket 5.2 and swi-prolog 5.10.4. Thanks for any help.

Nick Main said...

Hi Sarino:

Sorry - I don't recall. I have upgraded both Racket and SWI several times since then.

The interop is/was fragile - especially if you redefine predicates.

I have been busy implementing a fast Prolog engine in HaXe for my day job (was using the Racket/SWI bridge to prototype some games in that context). I plan to swing back around and implement a proper Prolog engine on top of Scheme/Racket (as open source). "Proper" in the sense of being able to run CHR (Constraint Handling Rules).

What are you using Racket+SWI for ?

--Nick