HACKER Q&A
📣 idontwantthis

Do All Programming Languages Have Features That No One Should Use?


I'm a Typescript Developer these days. I've used Java, Python, and PHP professionally as well, but Javascript/Typescript is by far my most well understood.

In JavaScript, no one is supposed to use the Boolean object constructor (new Boolean()). It is singularly unhelpful, and usually does the opposite of what you want. I've never seen a case for it.

Please correct me if there is some arcane reason to use it.

Do other languages have features like this that newbies might try to use once before getting burned and then literally never touch again no matter how advanced they get?

Are there interesting stories for why those features exist?


  👤 __d Accepted Answer ✓
Every major language I've used has had features banned by local coding standards. COBOL(!), Modula-2, C, C++, TCL, Python, Java, Javascript, PERL, ...

Little languages too: Makefiles, yacc/lex, etc. They were all a better solution than their forebears, but after years of usage, it's clear they have serious flaws.

In general, over the productive life of a language, experience evolves what is considered good, and features that at the time the language was written were fine, or even considered good, fall from favour as experience grows.

To be fair, some do better than others. C++ has basically become a different language over its lifetime -- C++20 is a _very_ different thing than the C++ I used in the late 80s! Much of what was new and interesting in early C++ is now considered dubious at best.

I think we're approaching a time where C (and C++) will be widely considered to have enough misfeatures that they will fall from use, especially in new applications. That's ok: C is 50 years old -- if we hadn't learned how to do it better in that time, I'd be worried!


👤 informationally
I wasn't aware that booleans could be instantiated with a constructor. What would be a reason for using the constructor instead of the literals "true" and "false"?