Remix.run Logo
UncleOxidant 5 days ago

I mean, I guess it depends on your background, but that code looks pretty nice compared to how it would look in a language without pattern matching and ADTs. This is why the MLs excel for things like parsers, interpreters, and compilers. Beauty is in the eye of the beholder, I guess. I suspect that if you gave it a bit of time it would start to really grow on you - that's how it was in my case. At first: "WTF is this weird syntax?!", a few weeks in "oh, this makes a lot of sense, actually", a few years "Yeah, I'd much rather write this sort of thing in OCaml (or an ML in general)"

manoDev 5 days ago | parent [-]

I don't find the ADT and matching part weird, but rather everything else (as mentioned).

the_af 4 days ago | parent [-]

That's just lack of familiarity.

For this family of languages, it's very uncomplicated and easy to parse (and they all "sort of look the same" if you squint). Consider this: if you knew nothing of Java or C, their syntax would be weird mumbo-jumbo to you too. Even a language which is considered relatively simple, like Python, can trip you up in unexpected ways if you're unfamiliar with it.

Fortunately, getting familiar with the syntax is easy. Doubly so if you actually tackle a project with it.

Coming from a Java/C/Python/JS background, it's hard to casually read OCaml snippets before first getting acquainted with its syntax, because it belongs to a different family of programming languages.