Remix.run Logo
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).

lolinder 36 minutes ago | parent | next [-]

I feel the opposite—the typing ergonomics are better with a lower-punctuation language, but the reading ergonomics are substantially worse.

Punctuation is used in written human languages to provide assistance to our brain-parsers—like road signs that help navigate a sentence. Too much punctuation and it becomes a huge problem because it ceases to be meaningful, but have you ever tried reading a Roman inscription written with no spaces or sentence boundaries?

I think programming language punctuation serves the same role—it visually marks out how the parser is going to navigate the code, allowing the reader to use less mental effort repursing code that they initially misparsed. ML-style languages have a simpler syntax than the C family, which means there is some justification for having less assistive punctuation, but I've definitely struggled to navigate OCaml as a result of too little punctuation.

seanwilson 5 hours ago | parent | prev | next [-]

I think typing ergonomics are overlooked as well. CSS has the most verbose syntax for variables I've had to use regularly e.g. `var(--primary-color)` which I find unpleasant to type when experimenting. And I actually like the lack of brackets and commas in OCaml for function e.g. you write `add_numbers 1 2` instead of `add_numbers(1, 2)`. Brackets and commas in particular require you to navigate left/right a lot to add them in the right place while iterating and give confusing errors when you get them wrong.

Would be curious if there's work into a programming language that was optimized for minimal typing while iterating.

layer8 32 minutes ago | parent | next [-]

> Brackets and commas in particular require you to navigate left/right a lot to add them in the right place while iterating and give confusing errors when you get them wrong.

In other languages, modern IDEs take care of that. For an invocation like `addNumbers(1, 2)`, you would perform code completion after typing “aN”, and the IDE would already fill in matching function arguments from the current scope. The selection (cursor) would be highlighting the first argument, so you can readily replace it. Pressing Tab would move to the next argument. Pressing Enter (or similar) would accept the call expression in the current state and move the cursor behind it. So you only type the actual arguments (if necessary) and otherwise just hit combinations of Tab and Enter, or Ctrl+Space for code completion. You generally don’t type the parentheses or commas yourself.

That being said, I’m in favor of languages with not too much punctuation. But there’s a balance, and too little punctuation can also hurt readability.

ttepasse an hour ago | parent | prev [-]

Tangentially there is room for optimizing for non-american keyboards.

The accent grave (backtick) you're using in a Markdown-inspired way is utterly annoying to type on keyboards where accents are implemented as dead keys, to be combined with vowels, common on european keyboard layouts. For your example I had to type `, but then look ahead to the a of add_numbers and remember to put in an extra space, so that the ` and the "a" don't combine to an "à".

Also I find it somewhat illogical: The usage of an accent as a character in itself in programming languages is one of my pet peeves. Just being an ASCII character is not reason good enough to keep using it.

Curly or square brackets, backslashes and other stuff also put you into uncomfortable AltGr or Cmd-Shift territory on some keyboards. American language designers are often blind for these simple ergonomics.

akkad33 8 hours ago | parent | prev [-]

The lambda syntax and default lambda parameters alone make typescript very hard to parse