Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

It is definitely very legible here and at least as legible as the Rust equivalent. It’s actually a lot more legible than the Rust equivalent here to be fair.

The Ocaml program is mostly matching followed by a chain of operations. It’s far removed from elegance for elegance sake. Meanwhile Rust is handicapped by the machinery it forces you to deal with as a lower level language introducing life time.

Type annotations are a non issue. They are systematically provided in Ocaml in a different file than the code. This header file is not provided here because well it’s a blog post.



I suppose that's ultimately in the eye of the beholder. I suspect that if this compiler were to be 10x, 100x bigger, you'd see a pretty big difference. Like rustc, as massive as it is, is pretty legible as compilers go.


I will take any of the dozen of sometimes very large compilers written in Ocaml above rustc personally but to each their own.


I'd love links to them! I tried reading the OCaml compiler source but quickly got overwhelmed.


You can browse compiler source code here with type annotation and code navigation if you like https://htzh.github.io/browse-ocaml/ . The editor plugins typically don't work on the compiler itself. These annotations and links were generated fairly painlessly from Ocaml compiler features (most hard work done by the compiler already).


Thanks for the links! I'll try to give it a read sometime.

But also, the editor plugins don't work on the compiler itself? Why's that? So you can't use Merlin on the OCaml compiler? That doesn't seem great.

And what's with the syntax highlighting being funky? The highlighter appears to think that a lot of these files have unterminated comments or string literals.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: