Is it JavaScript a messy language?

I’m a person usually preferring to use statically-typed languages, but I got used to JavaScript.
The question is: is it JavaScript a messy language or are the programmers the messy ones? :slight_smile:

As a rule, I think that the programmers are the messy ones :slight_smile:. I am not sure that any programming language is inherently messy though some do make it easier to write “write-only” code.

1 Like

In short, yes. It is.

The first version of JavaScript was created in 14 days in 10 days. The idea was to create a language that works only for browsers. The result is one of the only languages that the orthogonality principle is mainly not respected, as well as lack of many constructs commonly seen in other languages. The undefined value being different than null only adds more entropy to the set.

Some initiatives from the community started to change the landscape. Google released Google Chrome, with an independent JavaScript engine called V8 in 2008, and Ryan Dahl used this V8 Engine to create Node.js, a JavaScript environment that works out of the browser. Initially developed to have server applications written in JavaScript, Node.js was repurposed to make possible the development of highly modular applications, libraries and task runners, as well as a mechanism for the community to propose new language constructs. Thanks to Node.js, the biggest beneficiary of the shift was exactly browser-made applications and frameworks, such as Angular, React and Vue.js.

However, this was not enough to fix the broken language design of JavaScript. This started to change when Anders Hejlsberg, the creator of Delphi and C#, and his team proposed TypeScript: a superset of JavaScript that supports typing. TypeScript is now the new norm in the front-end development, and Node.js sequel, Deno, runs TypeScript natively. TypeScript makes possible to find and fix variables problems during the development phase, which is extremely difficult to do in JavaScript, since most of the errors occur in runtime.


I love the flexibility of JavaScript and it’s one of my favorite languages.
However, strong static typing is a really powerful feature that is badly missing.

A decade ago, I’ve been fortunate to be one of the designers/developers of the Opa language.
With an amazing team, we did tremendous work for building Opa.
Personally, I was in charge of the type system and the implementation of the static type checker, and I can say that it is way better than TypeScript. It successfully combines the flexibility of JavaScript and the advantages of strong static typing.
For instance, you can freely manipulate objects like in JavaScript, adding and deleting fields, even dynamically changing the type of a field, and at the same time, static typing gives you the guarantee that your code is type safe.

Unfortunately, even if the language was so good, it’s been difficult to reach a strong adoption quickly.
Today we have TypeScript and ReasonML, which are 2 valid alternatives to JavaScript addressing the static typing issue (partially).
However, I still have every day this nostalgic feeling about Opa. The world would have been different if it was widely adopted, and the very question of JavaScript being a messy language would have been obsolete.

1 Like

Your comment about the first version of JavaScript being created in 14 days prompted me to do some digging. According to JavaScript: The First Twenty Years, Brendan Eich “prototyped the first Mocha implementation in ten contiguous days in May, 1995”. JavaScript wasn’t announced until December that year.

The orthogonality principle link is to the supported languages and frameworks for CxSAST 8.6.0; did you mean to link to a different page?

1 Like

Probably you are right. But for instance, I think that the nature of Perl language pushes programmers to write ugly/messy/unreadable code.

1 Like

What do you think it was missing to get adoption? Marketing only? :slight_smile: some “dinosaur” behind it to promote it?

There were several issues.
Of course, it is much easier for a great dinosaur to enforce adoption of a new language, as we have seen with Swift, Kotlin, Go, TypeScript …
But I think another major issue that we had is related to the business model. It has been decided relatively late to make it open source and to create a community around it.
Now I think that it is a critical point. A new language cannot succeed without a strong open source community and ecosystem. The core language is not enough, and if you cannot propose a wide variety of libraries, you cannot expect wide adoption.

Thanks for observing the problem with the link. I already fixed in the post. The intended link was this one.

Also, thanks for observing the timeline of JavaScript. The last time I visited the Wikipedia article about Brendan Eich, it mentioned 14 days, but now all the sources mention 10 days.

Wasn’t JS originally just a client side validation scripting “language” when it was conceived? It has since taken on a life of its own. I still see it as quick/dirty – and it’s definitely not my favorite language to work with or pick up from another programmer. :slight_smile:

1 Like