loading...
Cover image for Given a chance to time-travel to 90s and rewrite the JavaScript specification, what you'd have done differently?

Given a chance to time-travel to 90s and rewrite the JavaScript specification, what you'd have done differently?

prahladyeri profile image Prahlad Yeri ・1 min read

The title says it all. What change will you make to JS to make it easier to code and understand from today's perspective. Would you for example:

  1. Add classes and proper inheritance?
  2. Have support for namespaces?
  3. Support for static types?
  4. Built-in runtime for various tasks?

Discussion

markdown guide
 

Perhaps just,

  • no hoisting
  • no undefined. null only.
  • no undue type coercions. Throw more errors. Perhaps also, true dynamic arrays

Just make Javascript less of a minefield is most important.

Indeed, Javascript did tried its best to prevent UI from crashing, but it failed more than sometimes.

It did somewhat succeed in preventing UI for hanging, though.

 
 

Should utility libraries be centralized? However, I think Node.js and web browsers are vastly different.

I actually think towards smaller size of global object. And only import when needed.

 

A standard library would ease a lot of problems like huge node_modules with hundreds of similar utility packages and as many similar but different approaches to solve the same problems. I mean, a standard library, like that on Python or PHP.

Now that I think about it, some other cool things would be having a single type of file module (no more ASM and CommonJS) and import/export syntax, as well as avoid any unwanted context binding (like with the old function syntax)

Now that I think what it actually does IRL.

  • Golang + VSCode -- on first run, it installs many code quality tools to the central store, i.e. GOPATH
  • Python + VSCode -- if virtualenv is present, it attempts to install "only pylint" to the venv, otherwise, it will try install globally.

I would argue that "A standard library would ease a lot of problems like huge node_modules" isn't real. The approach is whether you will use isolated environment or not. Also there is a solution in Node.js world, like pnpm, but is it against Node.js's philosophy?