Live data from Hacker News

JavaScript Is Weird

jsisweird.com

71–80 of 383 posts

Re: JavaScript Is Weird

#71

Especially weird was that the quiz stuck at question 2 and kept resizing and shifting the position of the question text on selecting any answer until the quiz ended. CSS in the console is a nice touch though.

I got stuck at question one like this. Running Tor Browser latest version, tried in all security modes.

First time i ever see a form behave like that oO

Re: JavaScript Is Weird

#72
post #63

Earlier quoted context omitted.

The site does say so in the introduction > Even if you're a JS developer, most of this syntax is probably, and hopefully, not something you use in your daily life. So I think you should look at this site more as something fun you might not have known if you're an js developer than as criticism of js. That being said, the !!"" isn't that weird of a syntax is it? I see and use the double exclamation mark all the time.

> that weird of a syntax ought to be "that weird a syntax": it's 'so [adjective] a [noun]' not 'so [adjective] of a [noun]'. It's 'so much of a syntax' but that's because 'much' is a determiner not an adjective, which really makes a much difference. Or if you want to be plain-spoken you can ofc just say 'such a weird syntax'.

https://english.stackexchange.com/a/30012/7762

Re: JavaScript Is Weird

#73
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…

The site does say so in the introduction > Even if you're a JS developer, most of this syntax is probably, and hopefully, not something you use in your daily life. So I think you should look at this site more as something fun you might not have known if you're an js developer than as criticism of js. That being said, the !!"" isn't that weird of a syntax is it? I see and use the double exclamation mark all the time.

The output is "weird" if you don't know the rules for operator precedence and how things convert to their primitive values.

Most people arent going to "know" what '+!![]' will resolve to because it makes literally no sense to combine those operators into a single expression in anything approaching normal code.

Re: JavaScript Is Weird

#75
post #33

Earlier quoted context omitted.

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…

That’s a load of gibberish. JS as a language has nothing to do with browser APIs, why would you judge it based on that? Also, ES6 was ratified six years ago.

Seems like you had a bad experience with espruino / jerryscript or something and are projecting based on that?

Dynamic languages are easier to program in. That’s a fact, and why they are so popular.

Re: JavaScript Is Weird

#76

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.

Using WebAssembly currently means programming in C, C++, Rust, or maybe Go. Despite its flaws, many people prefer programming in JavaScript over any of those lower-level languages.

Re: JavaScript Is Weird

#78
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…

Some of them are stretched examples, others comes from other languages/constraints (floating point, octal, ...), but some other are legitimately weird and error prone: [1, 2, 3] + [4, 5, 6] // -> "1,2,34,5,6" [,,,].length // -> 3

Both of these examples are well-known (and not unexpected) behaviours. I assume you already know why it behaves like that. If not, I can explain it.

> [1, 2, 3] + [4, 5, 6] // -> "1,2,34,5,6"

What would you expect instead?

> [,,,].length // -> 3

Is there any use case where you would want to deal with sparse arrays?

Re: JavaScript Is Weird

#79

if you block JS you get this message > This website is literally about JavaScript. I mean what did you expect, a .NET application? This website is 99.9% poorly optimized and highly questionable JS. And yet, you have JS turned off.

If you open the console to check after you're finished, it says: "What, are you going to check if the results are accurate? Go ahead " But if you open it console while doing the test, it says: "Hey, stop cheating! "

Why the hell can websites tell that I'm in the console? If I want to inspect some parts of a website (perhaps save an image), then I don't want that website to interfere.

Re: JavaScript Is Weird

#80
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…

I think the situation is a bit different. This situation looks different in reality. The result may be (null-0)+"0", but the actual code will be foo()-bar()+baz(). And C will at least give you warning about types, even if NULL-0+"0" could give you an address. Plain JS without extra tooling would happily give you the unexpected result. Some other dynamic languages would at least throw an exception about incompatible types for -/+.
Post reply on HN