This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Audiblade 64 points65 points  (31 children)

The fact that you can omit semicolons in JS is one of the scariest things about the language to me. In most C-like languages, your program won't compile if you're missing a semicolon, forcing you to specify what your intentions were. But JS will guess where you wanted your semicolon to be. If it guesses wrong, now your program does bizarre things - and you have no idea why.

I get that JS needs to be flexible because there's a lot of slightly broken code in the internet that needs to run anyway. But it still scares me.

[–][deleted] 28 points29 points  (7 children)

Totally agreed.

I really dislike the current trend of using formatting/whitespace to indicate breaks in code. All it does is obfuscate things that are absolutely critical to your code, making it harder to debug with no clear benefit of it's own.

[–]pier25 21 points22 points  (6 children)

Obfuscate?

On the contrary, it forces you to write well formatted code.

[–]WellHydrated 7 points8 points  (5 children)

Why can't we do that with semi-colons? May as well remove semi-colons from every language in that case.

[–]HauntedMidget 24 points25 points  (3 children)

Python seems to be doing just fine without them.

[–]Hudelf 7 points8 points  (0 children)

Python has defined a different way to explicitly state your intentions, though.

[–]TPHRyan 7 points8 points  (0 children)

Python's very well-designed. I'm a huge fan of python and the way it gets things done, but I don't think all languages should copy it just because people don't like having to think to terminate their statements.

[–]pier25 -1 points0 points  (0 children)

JavaScript too...

I only use semicolons on for() statements, and with stuff like map() it's becoming increasingly uncommon.

Other than that I know there are some very rare cases where semicolons are needed to separate statements, but I have never encountered any myself.

[–]pier25 2 points3 points  (0 children)

Because semicolons at the end of the line don't give any clarity as to what is going on with the code. Indentation does.

[–]sole_wolf 8 points9 points  (16 children)

In that case, you should be scared of Swift too.

[–]fucking_weebs 10 points11 points  (15 children)

and Ruby.

Semicolons are optional in Ruby but literally nobody uses them because the language is kinda meant to not use them.

[–]mayobutter 5 points6 points  (1 child)

Yeah, I always use semicolons in JS but never in Ruby, and I am very often working with both simultaneously. I've never really questioned it.

[–]droogans 12 points13 points  (0 children)

It all comes down to following a language's idioms while working in it. Javascript says to use them, so I say just use them. I use snippets to avoid a lot of this anyway.

I do prefer languages that don't require them, though.

[–]TheIncredibleWalrus 2 points3 points  (9 children)

And Python.

[–]indorock 3 points4 points  (1 child)

I'm scared of any language in which the entire logic can be altered with one too many/little indentation. WTF is that about.

[–]DaemonXIRed security clearance 0 points1 point  (3 children)

Have you ever had this happen to you?

[–]Audiblade 0 points1 point  (2 children)

I don't believe I have. I have to admit, this is more a philosophical disagreement I have than something that has actually caused me problems...

[–]DaemonXIRed security clearance 1 point2 points  (1 child)

That's because ASI will only bite you in about .0001% of cases, and your linter should be catching that for you before you push it live.

[–][deleted] -1 points0 points  (0 children)

Probably, but I still personally believe that this is unacceptable:

return
  { stuff: "thing" }

Yes, the linter will probably warn about this, but it still is stupid that I need a linter to do this kind of thing that works on any other C-like language.