Javascript isn’t a language. It is just a specification. Well, that’s true for many other languages like Python and Java. However, most languages have just one de facto implementation. For example, CPython for Python. Java has two major ones - Oracle’s JDK and Google’s Android Java. That’s not true for Javascript though.
- Different implementations - All browsers have slightly different implementations of Javascript.
To cover the gaps there are magical libraries called
Polyfills.
Of course, that doesn’t help with the issue of server-side vs client-side Javascript.
All the libraries are on npmjs.com, and it is for you to guess which one works and
the subtle differences due to
security restrictions that are imposed on browser-side JS.
- No built-in libraries (batteries) - Unlike Java, Go, Python, etc. Javascript ships
with no batteries included.
So, even for simple tasks like padding, there are
third-party libraries.
The idea that these libraries are not buggy or have security issues is preposterous.
While all projects depend on third-party libraries, Javascript takes it to the next level
due to a lack of batteries.
- Server-side Javascript - Node.js’s founder has moved to
Deno.
But Deno support is still
poor across libraries.
You will start with Node.js in 2024 and will be forced to migrate in a few years once everyone
moves to Deno.
This reminds me of
Python of 2015-20 era.
Python 2 was deprecated but Python 3 support was poor. You would write code in Python 2 despite knowing its limited shelf-life.
- Single backend frontend codebase - Well, good luck with that.
God forbid if your engineer is lost where the backend Javascript code ends and
the frontend begins leading to leaks of
Database credentials.
- Typescript - Kotlin is better than Java.
I have heard that Swift is better than Objective-C.
TypeScript isn’t better than Javascript though primarily because it is a superset of Javascript.
It is better than Javascript but not the magic bullet.
Further, your gazillion poor-quality Node.js dependencies might still be written in Javascript.
- React - React is the most popular framework.
Vue, however, is a better framework that neatly separates Javascript, CSS, and HTML
into three separate sections of the same component definition file.
React, on the other hand, prefers a multi-indented hideous JSX syntax.
I can’t imagine why someone feels that HTML embedded inside Javascript is superior.
Further, Vue has batteries like redux, etc. built into it.
While Javascript is unavoidable, here’s how I think one should try to limit its spread.
- No Javascript for the backend codebases - My preference is
Go but even Python is more maintainable.
- No
React Native for mobile
- Use Typescript
- And if you can, avoid React.
Vue is much superior but about one-fifth of the market share of
React.
- Run
npm and yarn inside
docker using
Amazing Sandbox to ensure safety from supply chain attacks.