Hacker News new | ask | show | jobs
by WastingMyTime89 1146 days ago
> This is exactly what I wrote, but in a Stockholm-syndrome-y way.

Do you complain about having to put braces around C expressions to not get unexpected behaviour from the compiler?

> He points out a real ambiguity in the syntax where the parser literally parses the same-looking and same-behaving statements completely differently.

No, he doesn’t. If that what you got from the article, you were bamboozled. He points out that match, try and (;) have different precedence which is not ambiguous. Writing begin and end is not a workaround. That’s how you mark blocks which is what he should have done because, well, he wants a block.

Erlang has exactly the same issue if you write unidiomatic code by the way.

That’s unsurprising because "don’t write code implicitly relying on precedence behaviour" is taught to virtually all beginners in most programming languages.

1 comments

If you shouldn't write code that way then it should be a compilation error (or at the very least a warning) to write code that way.
I’m not sure I agree.

It’s perfectly legitimate code and working code. It’s just hard to read.

Should language prevents you from writing hard to read code if it means making trade off? I personally think that’s what linters are for but you are free to disagree.

I’m going to bed and don’t think I will revisit this comment thread. It’s probably the longest discussion I ever had about syntax points you don’t even encounter while using the language.

I have fond memory of writing OCaml. It’s nice to use. It gets out of your way. The compiler is quick. It gives nice error message. The syntax and semantics are flexible enough and elegant enough than you don’t feel like your fighting the language and your code feels nice. That’s what matters to me at the end of the day.

Is there ANY common language without TONS of ways to write bad code?

Is there ANY such language at all regardless of popularity?

It's a spectrum. Most languages have some ways to write bad code, but there are definitely languages that have more or fewer ways compared to other languages. E.g. languages with simpler precedence rules, like Lisp or TCL, avoid this particular issue because you just can't write code with unintuitive precedence (although in the case of Lisp people often end up writing a macro that recapitulates the problem).