Live data from Hacker News

Why I sometimes hate JavaScript

geekregator.com

61–66 of 66 posts

Re: Why I sometimes hate JavaScript

#61
post #52
post #42

Good programmer, bad programmer. Good code, bad code. Let's not all pretend we don't have stupid bugs in our code regardless of editor, linting or language. JS is a mediocre language. It is popular because it is ubiquitous, not because it is good. It really does have bad error handling, weird optional rules, problems determining type when adding/concatenating with +, and the list goes on. His was a syntax error that…

>JS is a mediocre language. It is popular because it is ubiquitous, not because it is good. JS is a popular because runs on browser by default.

Yes, which is why it is so ubiquitous.

Re: Why I sometimes hate JavaScript

#62

Earlier quoted context omitted.

As someone pointed out, the implied semicolon isn't the problem. The problem is that the code is written in a way that makes it vulnerable to an implied semicolon. The core syntax of JavaScript won't be changing any time soon, so it's important to teach beginners how to write code that minimises mistakes like these. I haven't seen many books and tutorials attempt this. So it's unfair to blame beginners when there's s…

You know that kind of bullying where someone grabs someone else's arm and uses it to hit them in the head with their own hand, while yelling "Stop hitting yourself! Why are you hitting yourself?"? Javascript's automagic semicolon is that, and you're the kind of person who condones it. Yes, at the end of the day one has to learn how to deal with the automagic semicolon, if one doesn't just give up on Javascript wholes…

Actually that's what I said.

I wasn't blaming the coder or the language.

I was saying that it would help everyone if there was top quality online help explaining how to code around language deficiencies - the kind of deficiencies that everyone has to deal with it, because no language is perfect, and most languages are quite a lot less than perfect in at least some respects.

Be realistic. js isn't suddenly going to be rewritten with a proper semicolon patch. It's too established, and it would break too much code.

So complaining about it is a waste of everyone's time. It's like complaining about the fact that sometimes it gets cold in the winter.

It's more productive to do something practical about producing quality code that minimise possible problems, surely?

Re: Why I sometimes hate JavaScript

#63
I had a similar-ish problem just last night. Spent over an hour crawling through some code trying to figure out why it wasn't working like it was supposed to. I ended up doing the divide-and-conquer approach with "console debugging". I was cursing wildly by the end of it.

All to find in the end that I had used ( ) instead of [ ] (or maybe it was the other way 'round?) in a thick spot of code, and Javascript was happy to try to do that without throwing any kind of error.

That sort of thing happens in all languages to some extent, but debugging in Javascript is unmitigated hell.

Re: Why I sometimes hate JavaScript

#64

Earlier quoted context omitted.

You know that kind of bullying where someone grabs someone else's arm and uses it to hit them in the head with their own hand, while yelling "Stop hitting yourself! Why are you hitting yourself?"? Javascript's automagic semicolon is that, and you're the kind of person who condones it. Yes, at the end of the day one has to learn how to deal with the automagic semicolon, if one doesn't just give up on Javascript wholes…

Actually that's what I said . I wasn't blaming the coder or the language. I was saying that it would help everyone if there was top quality online help explaining how to code around language deficiencies - the kind of deficiencies that everyone has to deal with it, because no language is perfect, and most languages are quite a lot less than perfect in at least some respects. Be realistic. js isn't suddenly going to b…

I want to make sure that you understand why i wrote that post. I saw you mentioning that the docs need to be better. I actually KNOW the problem, since we have it in Perl too, and i made a site for it. ( perl-tutorial.org )

However, your first two lines were still:

> the implied semicolon isn't the problem.

> The problem is [...] the code [...]

Which is simply not an acceptable thing to say. The first thing to do is admitting that the language is the problem, not the coders or their code. The second thing is, now they're listening instead of being disgusted at you, to tell them solutions.

Re: Why I sometimes hate JavaScript

#65

Optional semicolons is my biggest hate with Javascript --- combined with expression statements silently discarding their result, it makes this kind of mistake far too easy to make. Personally I've never understood with Javascript strict mode doesn't make semicolons mandatory.

Isn't strict mode purely semantical? IIRC you can implement a use strict pass purely on the AST, after the parser. It's not an excuse, of course.

Bah. You're absolutely right, of course, that's why strict mode won't help.

Now I find myself wishing there was a stricter mode. , perhaps...

Re: Why I sometimes hate JavaScript

#66
post #22

Earlier quoted context omitted.

This is like the if (x = true) {} kind of error. Yeah it sucks, but it's not really the language's fault. Not to mention that that large a block of addition is bad code smell to me.

>Yeah it sucks, but it's not really the language's fault. Imagine a language were assignments were only done via := and comparisons with = or ==. A programmer would never encounter this error.

Ada does precisely this. (It also doesn't support assignment inside expressions at all.)

Modern Ada's a thoroughly nice language; I did a writeup: https://cowlark.com/2014-04-27-ada

Post reply on HN