Live data from Hacker News

JavaScript Is Weird

jsisweird.com

41–50 of 383 posts

Re: JavaScript Is Weird

#41
post #30
post #19

0.2 + 0.1 === 0.3 That's not really a JS problem, that's a floating point problem. Plenty of languages will have the same issue. +!![] "" - - "" (null - 0) + "0" Calling these things weird is fair enough but I can't help thinking this is code you'd never actually write outside of the context of a "Look how weird JS is!" post. It's like picking examples from the Annual Obfuscated C Contest to show how hard it is to un…

Exactly. Finding flaws in a language doesn't mean the language is bad, just that it has... flaws. The proof that JS is actually pretty good is that it has been used to build so many things. Like the old adage about economics, these criticisms are taking something that works in practice and trying to see if it works in theory.

No. Popularity does not indicate quality. Judging the quality of something by its popularity is a form of cyclical reasoning. Especially when there is an obvious alternative explanation, namely that JS is the only language you can in the browser without transpiling and for a long time the only one period.

While the fact JS can be used to build all these things puts a floor on its quality, that floor is uselessly low.

Re: JavaScript Is Weird

#42

I have limited knowledge in web development and its history, but why is javascript a first class language in web dev when all I heard is "javascript bad"? Web assembly seems like a much better choice in hindsight where you can choose different language to compile down to wasm.

Webassembly is too recent. It needs to catch on. The momentum behind Javascript/Node is huge beyond comprehension. The engineering that has been poured into the JIT is also quite something. Just scrapping all of this and starting again with Wasm is not going to get traction from anyone.

Re: JavaScript Is Weird

#43

> JavaScript is a great programming language I have no idea how you could come up with this sentence after this brilliant display of what an insanely stupid language JavaScript is.

To be fair, just because a language allows you to do stupid things, doesn't mean that it's bad.

C, C++, Perl (oh, Perl!) allow you to do weird things, too, so do lots and lots of other languages.

A certain knowledge of this weirdness is very helpful, though, in avoiding it.

Re: JavaScript Is Weird

#44

I have limited knowledge in web development and its history, but why is javascript a first class language in web dev when all I heard is "javascript bad"? Web assembly seems like a much better choice in hindsight where you can choose different language to compile down to wasm.

WASM is not a good solution in a lot of situations. In short:

- you have to package your complete runtime in the Wasm binary, this leads to a large binary and memory footprint

- DOM manipulation requires calling Javascript code, and calling JS from WASM is costly

Re: JavaScript Is Weird

#45
post #33

> JavaScript is a great programming language, but ... Why are we so afraid to call trash "trash"? It's not attacking the creator, but just how can we make progress if things are not perceived as they are? https://wtfjs.com

Why is it trash? Or is this just like PHP where people are so accustomed to shitting on something that they're completely oblivious to the progress that's actually been made? I don't understand what this actually contributes to the discussion beyond it being a tired, beaten-down programming meme.

It is 'trash' for the general purpose 'one-size-fits-all' programming language that it's fans want to impose upon the world. (I shake my head at microcontrollers running dynamic languages. "micro-python" = spare me. line breaks over a TTY? there's the primary question of on-chip resources and a giant shim between the physical realities of a microcontroller and some high-level fantasies about what programming "should be", absent any information on the low level specifics = the issue here.)

It's ES3 API is missing a few things, like Object.keys, etc. I still happily code for browsers in ES5 with a few polyfill functions.

JS works fine for it's core competency: manipulating DOM elements and local data representations.

It's not JS's fault that the browser is the way it is and that HTTP is the way it is and that using a remote directory "browsing" protocol via a specialized file browser that renders hypertext isn't a 2-way bound GUI framework...

Re: JavaScript Is Weird

#46

> JavaScript is a great programming language, but ... Why are we so afraid to call trash "trash"? It's not attacking the creator, but just how can we make progress if things are not perceived as they are? https://wtfjs.com

I thought the same thing. I think the author is afraid of offending people. Downvote culture has conditioned a lot of people to walk on eggshells and write this way.

Funny how this comment got downvoted into Valhalla in a matter of minutes.

Re: JavaScript Is Weird

#47

I think a lot of these errors can be fixed with using strict types, aka Typescript. I've had the same issues with PHP in the past too, which makes me believe that whosoever created these languages had ease of use as a higher priority than strictness, i.e. it's okay to assign bool, int, string to the same variable.. just get the job done.. okay. On the other end of the spectrum is a programming language like Pascal (o…

I had a similar feeling recently using Swift for a project.

Pure JavaScript is definitely a bit too loose for my liking, but I thought Swift went a bit too far in the other direction.

Re: JavaScript Is Weird

#48

> JavaScript is a great programming language, but ... Why are we so afraid to call trash "trash"? It's not attacking the creator, but just how can we make progress if things are not perceived as they are? https://wtfjs.com

We are not saying this because we are afraid to say it, but because it is not true.

JS is a great programming language with a lot of quirks and footguns, most of them easily avoidable by enforcing good coding styles, using easily available and widespread tooling.

And most language have linters or compilers that issue coding-style related warnings, including C, so this is not specific to Javascript.

Re: JavaScript Is Weird

#49
Fortunately nowadays including any of those in your code would award you the review equivalent of bashing your head in.

With the advent of linters most of these patterns started being rightfully considered bad form by default.

Currently even innocent stuff like +new Date() (outputs a timestamp) is already something that I've rarely seen make it through review.

JS is goofy, but ES2015 managed to avoid making the same mistakes. Shame it took so long to implement it.

At the moment the bigger problem is the painful transition from whatever module system you had to ES Modules.

Especially browserNode.js interoperability suffered massively from this.

Hopefully there will be no further standards in this field.

Post reply on HN