← Back to context

Comment by marcosdumay

3 days ago

The reason is that the language was designed in a week with a "product manager" pushing the developer's design into something that only has "is a programming language" in common with it during that week.

The sooner that abomination is killed, the best.

Prototype based languages existed before Javascript and even before Self. It wasn’t an adhoc or new idea.

The prototype ("Mocha") was created in a week, but the language went through multiple iterations. (See https://www.wirfs-brock.com/allen/jshopl.pdf)

Honestly, I can point you to languages with worse design than JS.

There was an idea (perhaps from BASIC) that "scripting" means permissive. Instead of failing fast, it was designed to fall back to something that works (e.g., '1'+1=2). That's a terrible design decision, and JS tried to reverse it in every future iteration.

The other two big issues for me were: trying to imitate Java (with the new keyword, instanceof, and null). The prototype mechanism that JS took from Self is simpler and easier to understand if you leave out those constructs.

The other issue was the lack of modules. That was part of the idea that JS was for short, interactive scripts on a page; the initial version didn't plan for how we use it today.

Other than that, I prefer JS over Perl, C, C++, PHP, shell scripting, or TCL.

Edit: Actually, '1'+1 is '11' in JS (facepalm), but '1'*2 converts to a number. That's why it was a terrible idea. But, to be fair, many "scripting" languages did that kind of type coercion. I guess that language designer hated cryptic compile errors.