December 23rd, 2003

  • evan

fast code

Why is OCaml fast?

An in-depth look at OCaml's x86 code generation. Some of it's pretty hardcore. One obvious observations is that it can generate relatively fast assembly because you don't need to check types at runtime.

This bit on the addition function near the end is rad: (It's actually more subtle than this - to perform the mathematics quickly, OCaml uses the x86 addressing hardware in a way that probably wasn't intended by the designers of the x86.)

Internal representation of strings.

I got hopeful looking at the MLDonkey screenshots that it could make fancy-looking Windows native GUIs, but that appears to be written in Java.
  • evan

ocaml + xml

I was bitching to gaal about the usefulness of LogJam's XML output in generating PDFs, when I started Googling for "ocaml xml".

OX uses OCaml's meta-language support to support XML terms in the language directly (see tutorial for some EBNF¹). They also have some regular-expression-like pattern matching over XML.

CDuce isn't really ocaml-related (besides being written in it) but appears to use DTDs to statically verify / optimize XML processing. They say "a CDuce program can run faster (30% to 60%) than an equivalent XSLT style-sheet" but I don't really understand how valid the comparison is.

I've played with PXP before but it hurt my head. But I think they were doing what seemed to me to be the sensible goal: use the DTD to process the XML directly into a data structure. A straight DOM tree is annoying to work with, because every node must have a list of children, even for the common cases where they only have one string child; using a DTD allows you to specialize your tree to the document format.
(LogJam's XML processing is really painful and makes me feel gross because it's so repetitive. But that's in C and I don't expect much out of C.)

1 I hate it when people introduce language features via EBNF. It's much easier for me to see some examples and infer abstraction than it is for me to see abstraction and generate examples.