Hacker News new | ask | show | jobs
by brmgb 1039 days ago
I think it’s your inexperience talking here as programs in both languages here use mostly the same naming conventions and abbreviations, the main difference being that Ocaml is its usual terse and to the point while Rust is well far less terse
1 comments

Yeah isn't that my point? Rust isn't trying to be short or elegant. There's no zen of Rust. There are elegant aspects of Rust, but it's not a central goal. Whereas with OCaml it's trying to be elegant. It's encouraging people to write a program where you read it, go "wait, how does that work?", then re-read it and marvel at the beauty of it.

To be clear, elegance is important. A language absent of elegance would be a bore to write (cough Java cough). But too much elegance and it can eclipse the legibility of the language. No type annotations is elegant. Is it legible? Not in my opinion. But perhaps it is in yours.

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).