▲ | laylomo2 10 hours ago | ||||||||||||||||||||||||||||||||||
The more I used ocaml the more I found beauty in the syntax. It’s very ergonomic in many ways: 1. It’s whitespace insensitive, which means I can code something up really messy and the code formatted will automatically fix it up for me. 2. In general there aren’t a ton of punctuation characters that are very common, which is great for typing ergonomics. Don’t get me wrong, there are still a lot of symbols, but I feel compared to some languages such as Rust, they’re used a lot less. Beyond the syntax, there are a couple of things I really like about the language itself: 1. Due to the way the language is scoped, whenever you encounter a variable you don’t recognize, you simply have to search in the up direction to find its definition, unless it’s explicitly marked as “rec”. This is helpful if you’re browsing code without any IDE tooling, there’s less guessing involved in finding where things are defined. Downside: if the “open” keyword is used to put all of a module’s values in scope, you’re usually gonna have a bad time. 2. The core language is very simple; in general there are three kinds of things that matter: values, types, and modules. All values have a type, and all values and types are defined in modules. 3. It’s very easy to nest let bindings in order to help localize the scope of intermediate values. 4. It has a very fast compiler with separate compilation. The dev cycle is usually very tight (oftentimes practically instantaneous). 5. Most of the language encourages good practice through sane defaults, but accessing escape hatches to do “dirty” things is very easy to do. 6. The compiler has some restrictions which may seem arcane, such as the value restriction and weak type variables, but they are valuable in preventing you from shooting yourself in the foot, and they enable some other useful features of the language such as local mutation. | |||||||||||||||||||||||||||||||||||
▲ | bloomingkales 8 hours ago | parent [-] | ||||||||||||||||||||||||||||||||||
2. In general there aren’t a ton of punctuation characters that are very common, which is great for typing ergonomics. Don’t get me wrong, there are still a lot of symbols, but I feel compared to some languages such as Rust, they’re used a lot less. I never really seen someone put that into words. I always feel a certain kind of weird when I look at a language with tons of punctuation (Typescript is good example). | |||||||||||||||||||||||||||||||||||
|