Hacker News new | ask | show | jobs
by lmm 1154 days ago
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.
2 comments

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