Live data from Hacker News

JavaScript Is Weird

jsisweird.com

251–260 of 383 posts

Re: JavaScript Is Weird

#251
post #224

Earlier quoted context omitted.

Typescript doesn’t save you from all the weird things happening at runtime. A missing check at a context boundary and you can have a wild time (been there).

Context boundary meaning where it interfaces with javascript?

The points where you parse JSON, for example.

Re: JavaScript Is Weird

#252

I’ve taught programming to people who struggled because they were misusing JS and the answer they were getting back coincidentally worked for some inputs but not others. Imagine trying to explain to them that this was their fault? Even trying to find the words to explain what happened made me feel bad that their first experience programming was tarnished by a language that will gladly allow you to do nonsense.

This is why Pascal and COBOL were the CS101 languages at my college. (RPI class of '85)

Re: JavaScript Is Weird

#253

UX nit: would have preferred question-by-question feedback on right answer and overall score, quite a lot to get through 25 questions before you get any reward for your effort :)

I don't think it is a UX nit. You would have started to catch on and learn if you had immediate feedback.

When is the last time you took an in-person test where the proctor told you if you were right/wrong after every question?

You need to grade current knowledge. In fact, I would have removed the multiple choice altogether for this test and had a input(type=text)

EDIT: OK, ok: I get it, it is just a fun website, not the BAR.

Re: JavaScript Is Weird

#254

Earlier quoted context omitted.

I had that experience with Swift for maybe the first 2 days I used it. Nowadays I really appreciate Swift’s strictness. It just helps prevent so many stupid mistakes. I worked on a high-profile project for my company under a strict deadline and Swift was a major part in ensuring we delivered a rock-solid implementation in record time.

The only part of the type system that I feel gets tedious is dealing with numbers, where you're continually casting back and forth between Int, Float, Double, CGFloat (at least the latter is being addressed). I get why it's strict about it due to loss of precision and the madness of floating-point numbers, but sometimes you just don't care

The number things isn't that big of an issue once you get used to considering what type your numbers should be in advance, instead of going back and forth between number types, pick one that's appropriate and stick to it.

Re: JavaScript Is Weird

#255

UX nit: would have preferred question-by-question feedback on right answer and overall score, quite a lot to get through 25 questions before you get any reward for your effort :)

I don't think it is a UX nit. You would have started to catch on and learn if you had immediate feedback. When is the last time you took an in-person test where the proctor told you if you were right/wrong after every question? You need to grade current knowledge. In fact, I would have removed the multiple choice altogether for this test and had a input(type=text) EDIT: OK, ok: I get it, it is just a fun website, not…

I'm trying to look at weird javascript, not haze new employees.

Re: JavaScript Is Weird

#256

Earlier quoted context omitted.

Which is why we use Typescript

The fact that there has to be a different language on top of your language to make it same days all that needs saying really.

Man do I hate my phone's autocorrect. For anyone confused as shit:

The fact that there has to be a different language on top of your language to make it sane says all that needs saying really.

Re: JavaScript Is Weird

#257
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've been thinking for a while that modern languages shouldn't default to floating point computations. They're exactly the right thing if you do data stuff or scientific computing, but given how much of the internet relies on things like e-commerce and how often floating point is still misused for dealing with money, coupled with the fact that even many senior developers aren't fully aware of the subtleties of floating point, I don't understand why we keep making them the default.

If a user does need to do scientific computing, they could use a "# use-floating-point" pragma or something so that literals get interpreted as floating point. Otherwise, we map them to rationals.

Of course, doing rational arithmetic is much slower (for example, Gaussian elimination is exponential for arbitrary precision rationals, while it's famously O(n^3) for floating point), so there's a danger of people accidentally using it in triply nested loops etc., but I have a feeling that if you need to do that kind of thing you know that you might run into performance issues and you think twice.

Re: JavaScript Is Weird

#258
post #131

Earlier quoted context omitted.

[1,2,3] + [4,5,6] An addition operation over two numerical vectors of length 3. I would expect the result to match its inputs and provide a numerical vector of length 3. Thus: [5, 7, 9]

What language has this behavior by default?

Fortran :)

Re: JavaScript Is Weird

#259
post #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.

Why is JS a great programming language?

Re: JavaScript Is Weird

#260
post #244

I’ve taught programming to people who struggled because they were misusing JS and the answer they were getting back coincidentally worked for some inputs but not others. Imagine trying to explain to them that this was their fault? Even trying to find the words to explain what happened made me feel bad that their first experience programming was tarnished by a language that will gladly allow you to do nonsense.

Can it be that JS is not good starting language then? Maybe strongly typed compiled languages would be a better fit? One can argue that if you want to program it might be too much information for starters - but IMO basic types are such a fundamental concept that it would be better to teach that concept early on. It also clears up a lot of newbie confusion as you cannot assign string to an int by mistake with strongly…

Yeah, pretty much everything you mentioned was made clear to me after this.
Post reply on HN