Hacker News new | ask | show | jobs
by bubblebeard 684 days ago
I have been using JS for more than 20 years, and I do not like it. There are parts of it I find useful, but I avoid using it as much as I can in any project.

The biggest reason for this being that the execution of JS code it down to the browser rendering the page where it’s deployed. As such it’s practically impossible to get any code to run consistently. This is of course only relevant in my day to day work as a web dev.

That aside, JS has some funny behavior. If you wish toninderstand JS better you could read up on how null and undefined works.

You could also read up on how functions work, they are objects actually.

1 comments

> the execution of JS code it down to the browser rendering the page where it’s deployed. As such it’s practically impossible to get any code to run consistently

Can you elaborate on this part? I would say one of the strengths of JS is that you can get it to run consistently just about anywhere.

Certainly! Now, I’m no expert and may get some things wrong here, if anyone else knows better I’d be happy to be corrected.

Every browser implements a version of ECMAScript (this is a specification declaring what features of the JS language will be available for the JS engine included with the browser).

This means that every browser on the planet, and every version of them, support different JS features.

For example, let and const are commonly used to define variables, but if someone happens to use an old browser version the use of these would cause an error, which in turn may cause all the rest of JS code to stop executing, resulting in (worst case scenario) your website being rendered useless to that particular person.

On top of that different browsers may use different engines. So even if they define the same ES version the code may still execute differently (this was for example a very big issue with Microsoft browsers in the past).

This may seem trivial, but new JS features emerge all the time. Granted, this was a much bigger problem before ~2015 something, but it’s by no means none existent today.

Thus, you cannot be sure the code you write locally will actually function the same everywhere, and you are unlikely to know how often failures even occur since it all happens client side.

I think with the official deprecation of IE this is mostly a thing of the past since all major browsers are “evergreen” and support a pretty recent standard. This certainly was the case only a couple of years ago, and it’s almost always wise to have a bundler (e.g webpack) that can target a fixed standard as output via transpilation/polyfill just in case you are itching to use the experimental features.