Live data from Hacker News

JavaScript Is Weird

jsisweird.com

111–120 of 383 posts

Re: JavaScript Is Weird

#111
post #34

Earlier quoted context omitted.

From what I read on forums, every single piece of technology that's ever been invented is trash according to some self-appointed expert. I doubt I could name a programming language used by more than 100 people about which at least one person hasn't written a crtical comment.

Elixir? I've never used it but reading about it I kept going ohh, ahhh and wow! In stead of my standard: ** ** * k * ** * sh?!?

https://news.ycombinator.com/item?id=25787548

I've never used Elixir so can't say whether the criticisms are justified.

Re: JavaScript Is Weird

#112

> 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

If we want to perceive JS as it is we need to follow its history, understand the basic ideas behind different features of the language, understand the trade-offs behind various design decisions, etc.

Basically, it was meant to be a dialect of Scheme, but with map and array data structures at the bottom, as opposed to lists (hello, Clojure!). Suddenly, the last-minute decision was made to add Java-like syntax and OOP to this language and rebrand it as 'JavaScript'. Brendan Eich did the best he could in the limited timeframe to implement this. Then in 2015 'design-by-committee' approach was accepted and horrible feature creep started. We can then investigate every feature and how it pushed individual company's agendas while compromising the integrity and vision of the language, but that's a typical design-by-committee story.

Re: JavaScript Is Weird

#113

Earlier quoted context omitted.

They don’t. They just use “console.log”, you see it because you opened the console. It’s not like they know you’re there and then write a message.

Devtools can actually be detected to a certain extent - https://github.com/sindresorhus/devtools-detect

This entire project should be copied verbatim into browser bug trackers, imho.

Re: JavaScript Is Weird

#114
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 t…

We've had these exact same sorts of issues in PHP. It can go undetected for awhile and cause subtle bugs. A good type system helps a lot. I appreciate that Kotlin is more stringent than Java with no implicit conversions between Int/Long/Float/Double.

Re: JavaScript Is Weird

#115
post #59
post #30

Earlier quoted context omitted.

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.

Just because something is popular isn't reason for it to be good. Examples: fossil fuels, (over)fishing, rage-based engagement, hard drugs.

Just to add to your list: Ed Sheeran

Re: JavaScript Is Weird

#116
There are some real problems with the quirks of Javascript too even if the examples are not that common. Some JS coders for instance use the oneof pattern and if you then forget somewhere to check if you got a Number instead of a Boolean you can end up with something weird. I have seen it several times.

Re: JavaScript Is Weird

#117

Nobody programs like that, so it's not an issue in real-world applications.

I would agree if wasn't for the fact that JS is a dynamically typed language.

You can (and sometimes will) run into instances of this without noticing, because while you won't explicitly write

  true++
you might do something like

  x = someFunction()
  x++
not realising that someFunction() might return a boolean under some circumstances.

Anyone who worked with a sufficiently large JS codebase ran into one of these cases and got unexpected results at some point due to this.

Re: JavaScript Is Weird

#118
post #20

Earlier quoted context omitted.

Is javascript any more "trash" than python or ruby? I don't think so.

Presuming server-side JS, as you won't run Ruby or Python in the browser, typically, you can say that all 3 dynamic languages, as such (garbage collected, heap-based, untyped) will waste computer resources and perform worse than typed compiled languages (even garbage-collected ones) due to memory usage patterns. Python has an interesting C FFI interface, among other approaches, that can at least allow CPU and memory-…

> As I see large front-end teams frequently pushing JS from a typescript base lately, I'm not sure that even the JS community supports "everything JS" anymore.

Given how close typescript is to javascript, wouldn't it be more appropriate to treat it as just a dialect of javascript (like coffescript was) rather than a different language like python or go would be?

Re: JavaScript Is Weird

#119
post #101

Why are people wasting time on sites like this? Every programming language has some weird stuff in it. If you are writing code like that then you are the problem not the language. Is this just for the clicks? Is this developer click bait?

I took the quiz and enjoyed it. Just have some fun, I don’t think the quiz wants to convey any deeper message.

Re: JavaScript Is Weird

#120

You're weird if you write code like this.

The sad part is that you don't have to and still encounter one of these cases.

The reason is that JS is dynamically typed and thus functions are free to return multiple result types. So you might run into one of these and get unexpected results because at some point in your code one of the functions returned an empty array instead of a number or a boolean, or divided by zero, or...

It's good to at least be aware of these edge cases so you can avoid them.

Post reply on HN