back to article Next; tech; meltdown..? Mandatory; semicolons; in; JavaScript; mulled;

In what non-technical people might take as an attempt to outdo the absurdity of the tabs vs. spaces debate that continues to divide programmers, the TC39 technical group that advises the development of ECMAScript – the specification from which JavaScript is implemented – has proposed telling web developers to terminate …

pascal

Ah, Borland, come back;

happy days;

30
1
Silver badge

Re: pascal

Took the words out of my mouth.

Made feel so young and forget about my beard being 50% white nowdays.

Now, back to carefully tabulating everything to the correct tab mark (or actually having VIM do it for me).

10
0
Silver badge

"And it, feels, well, a little hurtful."

It's not about the feels, it's that JavaScript is ambiguous if you rely on ASI. I thought any programmer would have been able to understand that.

It's also ambiguous in a thousand other ways too, but I guess nobody's going to do the decent thing and take it round the back of the woodshed and shoot it, so we'll have make do with minor improvements like this.

86
3
Bronze badge

Re: "And it, feels, well, a little hurtful."

Technically its not ambiguous, asi has rules. As with truthy and falsey, it may be wierd to look at but there are strict rules.

If you jshint your code it usually looks decent

0
0

Alternatively...

How about something like...

"use strict2";

... to force the requirement?

8
2
Anonymous Coward

Re: Alternatively...

Or just use eslint.

2
0
Silver badge

Re: Alternatively...

Do you need the trailing semi;?

0
0
Anonymous Coward

Re: Alternatively...

"Do you need the trailing semi;?"

Not until you use strict2 you don't ;-)

1
0

Re: Alternatively...

You also forgot the trailing; --

0
0
Silver badge

Re: Alternatively...

Use an IDE that puts them in for you?

1
1
Silver badge

Like most programmers, I guess, I have strong opinions on tabs vs spaces, but why the hell is a semicolon an issue? Most languages I've used have insisted on them so I use them habitually and can't see the issue in adding them.

For tabs vs spaces, the only argument I can see for spaces is that online resources use spaces so it makes grabbing snippets easier. Tabs lets the developer choose how big an indent they want, and (potentially) lets every developer have their own preference without messing up other people's code. But, honestly, most IDEs nowadays let you toggle back and forth easily enough that I'm not sure why anyone cares.

27
4
Anonymous Coward

Tabs v spaces

Can be a real pain with Python where the number of characters forming the indent specify the block level.

Does that line have an indent of '1' or four?

Unambiguous if a space is used, but it may appear as multiple spaces if tabs are used - e.g. two in one editor and four in another. Gets really nasty to work out why the code doesn't work as expected if a mix are used - code may be at different block levels even when it shows as being at the same level.

27
4

Re: Tabs v spaces

Dear Sir,

languages that need whitespace to decide the structure of a program should be similarly taken around the back of the shed.

Regards,

Guus

110
16
Trollface

Re: Tabs v spaces

"Gets really nasty to work out why the code doesn't work as expected if a mix are used"

Dont you have a just-fixit script to replace all tabs with 4 spaces? it saves loads of aggro when copying and pasting a mish mash of stackoverflow answers, some with tabs and some with spaces. :P

1
3
Silver badge

Re: Tabs v spaces

RPG II anyone? Each position on the first line was another configuration parameter and woe betide you if you missed a character.

Then setting flags, using exact column positions.

Give me semi-colons and tabs/spaces any day!

And what about in-line or hanging opening curly brackets?

5
1
Silver badge

Re: Tabs v spaces

"languages that need whitespace to decide the structure of a program ..."

BOO!

4
4
Anonymous Coward

Re: Tabs v spaces

Can be a real pain with Python where the number of characters forming the indent specify the block level.

Only if you're an idiot and mix tabs and spaces (or spaces and more spaces) in indentation.

Does that line have an indent of '1' or four?

"Does that line have an indent of 2, 3, 4, 5, 8 spaces?"

Unambiguous if a space is used, but it may appear as multiple spaces if tabs are used - e.g. two in one editor and four in another.

So someone who reads 8-character indented code more easily could read your code more easily? The horror!

Would you prefer to force all developers to work with the same font and text size? That would make it even more unambiguous!

Gets really nasty to work out why the code doesn't work as expected if a mix are used

And yet you spacers conveniently forget that you have even worse problems if two people both use spaces, but have their preferred "space" indent set to different widths.

Use an editor with visible white-space. Use an editor which auto-adjusts indentation behaviour to the file. BE CONSIDERATE.

By which, I mean: tabs are objectively superior.

8
26
Silver badge

Re: Tabs v spaces

> Can be a real pain with Python ...

That's what you get for using a language where white space carries a semantic content. It really is a misguided design.

52
5
Silver badge
Windows

Re: Tabs v spaces

@BigD:

Please stop reminding me about this nightmare I lived in my youth!

4
1
Silver badge

Re: Tabs v spaces

Talking of things that should be taken out to the back of the shed...

applications made by "copying and pasting a mish mash of stackoverflow answers"

25
0

Re: Tabs v spaces

That would be most of them then? Depending on the definition of "structure of a program". I took it to mean "whitespace is significant in source code".

3
0
Silver badge
Coat

Re: Tabs v spaces

That's what you get for using a language where white space carries a semantic content. It really is a misguided design.

Python's semantic whitespace is clearly an inferior imitation of Damian Conway's Acme::Bleach module for perl. From the description: The first time you run a program under use Acme::Bleach, the module removes all the unsightly printable characters from your source file. The code continues to work exactly as it did before, but now it looks like this:

use Acme::Bleach;

Plenty for the tab vs space people to argue over!

11
0

Re: Tabs v spaces

@Guus Leeuw

Can't up vote you enough...

5
5
JLV
Silver badge

Re: Tabs v spaces

So, by that line of reasoning, Lisp should be shot because _I_ think its excessive use of parentheses sucks? Despite being a super clever language with devoted followers?

Hint: in both cases, their formatting approach is a meta design-feature. Plenty of people like that design, plenty do not.

If you don't, then don't use them.

Thankfully languages are not like Maduro in Venezuela, plenty of choices around.

Heck, I've even heard from reliable sources that some people like PERL.

3
3
Silver badge

Re: Tabs v spaces

"languages that need whitespace to decide the structure of a program should be similarly taken around the back of the shed."

I can see why someone thought it would be a good idea. I can also see why it isn't. An IDE that automates indentation or something like cb is a better solution.

3
1

Re: Tabs v spaces

"Gets really nasty to work out why the code doesn't work as expected if a mix are used - code may be at different block levels even when it shows as being at the same level."

Not if you use a decent editor, it doesn't (I prefer emacs - your own tastes will vary)

But then what do I know? I've only been a Python dev for 15 years ...

(I'm not saying that it's a particularly _good_ idea, but the people who use it as a stick to beat Python with clearly haven't used it for any length of time. Or have a crap text editor.)

10
2
Silver badge

Re: Tabs v spaces

> "I can see why someone thought it would be a good idea."

Me too. Some programmers obsessively indent their code to keep it visually clear. They have also noted how the curly braces or parentheses can be logically implied by their ever-present indentation. It is therefore natural that they should take the next step and remove those maddening braces! Thus were born the indent-aware languages.

Python is liked by those who also like to indent anyway. This is good because such people tend to be strong performers, and having a language they are comfortable with cannot be a Bad Thing. No one is forced to use Python (well, hardly ever) and the rest of us are happy with our sloppy braces.

6
2
Gold badge

Re: Tabs v spaces

If a mix is used, the whole file is declared syntactically invalid. Problem solved.

A computer should never guess what the programmer meant. Tolerance has its place, and that place is end-user input. Programmers should just get it right and they should have the input thrown back at them repeatedly until they do that.

Funnily enough, this is also the answer to JavaScript's semi-colon question.

13
1

Re: Tabs v spaces

And before some one screams FORTRAN has spaces, F90 took spaces out behind the shed and shot them.

5
1

Re: Tabs v spaces

Don't get me started excessive use of parentheses. Whoever came up with Oracle's tnsnames format should be shot.

2
1

Re: Tabs v spaces

Yeah, well, that was because no-one uses punch cards any more.

Really, once they went the way of the dodo, the Proper Thing to do was absolutely to treat any amount of contiguous whitespace equally. I have that etched into my brain thanks to 'C', which is probably one of the reasons I grapple with Python.

2
1
Silver badge

Re: Tabs v spaces

@Guus

Python is actually doing quite well and, obligatory Slurp reference, OfficeML was quite popular as well (XML, a whitespace character between tags crashed Word).

0
2

Re: Tabs v spaces

>applications made by "copying and pasting a mish mash of stackoverflow answers"

An IDE centered around gluing code fragments from stackoverflow and github together, would surely be the next big thing.

1
0
Silver badge
Holmes

Re: Tabs v spaces

You could fix this. Anyone want to go halfs with me on the millions we could make designing an easy fix for both Tab and Space lovers with one stone?

(Obvious, if it's white space confusing things... get rid of it!)

0
0
Anonymous Coward

Re: Tabs v spaces

> it saves loads of aggro when copying and pasting a mish mash of stackoverflow answers

Ah, programming by Stackoverflow. What could *possibly* go wrong?

1
0
Anonymous Coward

Re: Tabs v spaces

"languages that need whitespace or __Semicolons__ to decide the structure of a program should be similarly taken around the back of the shed."

Fixed that for you.

Regards, FORTRAN USER

1
0
Anonymous Coward

Re: Tabs v spaces

"And before some one screams FORTRAN has spaces, F90 took spaces out behind the shed and shot them."

FORTRAN IV didn't need spaces either. Just respect the card columns.

FORTRAN USER

3
0

Re: Tabs v spaces

That would exterminate 90% of code. Don't suggest such terrible ideas.

0
0
Silver badge
Facepalm

Re: Tabs v spaces

languages that need whitespace to decide the structure of a program should be similarly taken around the back of the shed.

Because? Block delimiters are required for the compiler whitespace is just as good for this as semicolons are and have the advantage of increasing readability.

0
3
Silver badge

Re: Tabs v spaces

Not if you use a decent editor, it doesn't (I prefer emacs - your own tastes will vary)

You can also hit problems when working with people who different settings in which case a per-project convention is necessary and in general this will follow PEP 8 and use spaces.

0
0

Re: Tabs v spaces

> A computer should never guess

> what the programmer meant.

As someone who developed a web browser in the early 2000s, this comment is spot on.

It really means that your programming language should not have sloppy grammar - get this semicolons in there and quit whining.

2
0
Silver badge

Re: Tabs v spaces

> If you don't, then don't use them.

Unfortunately, if you wish to work as part of a team on a project (like, say from your employer) then you often don't have a choice on the language being used.

0
0
Silver badge

Berlin-based developer Yoshua Wuyts laments

Berlin-based hobbyist, I think you mean. I have never met a developer who only used a single language, except for some embedded guys who do everything in C (and even they know several ASM flavours). If all you know is JS then you're equivalent to a VBA power user writing Word macros, which is a useful skill but doesn't give you a credible perspective for addressing language design issues. Listening to guys like this is how Personal Home Page managed to become and remain the worst language in the world (tm).

And it, feels, well, a little hurtful."

Get used to it, snowflake. You're dealing with computers here. They don't "do" empathy and they don't give an Aardvark's left testicle about your emotional state.

84
4
Silver badge

I was starting to think I was the only one who remembered that it used to stand for Personal Home Page...

14
0
Anonymous Coward

Awww diddums!

Agreed, if he just writes code in JS he's not a "real" programmer - I bet he eats Quiche!

17
0

"Get used to it, snowflake. You're dealing with computers here. They don't "do" empathy and they don't give an Aardvark's left testicle about your emotional state."

Exactly. And if you don't agree then you should go help your uncle jack off a horse.

10
0

The snowflake has clearly not been subject to a thorough code review at any time; that just about says it for Javascript development as a whole.

13
0
Anonymous Coward

...programmers, aware that every additional character offers another chance to make an error...

Huh? I'd bet good programmers don't mind adding more characters if that lead to clarity.

46
0
SVV
Silver badge

Re: ...programmers, aware that every additional character offers another chance to make an error...

Yes Someone who finds clarity in code important is invariably also a good programmer (becsause it shows thought and understanding of the craft)

This is really a debate between compiled and interpreted code - and I MUCH prefer the former as you have to follow the rules 100% to even compile successfully. My experience with Javascript and its' "this may or may not work or it also may not work in the way you thought it would" character led me to avoid taking on any job that even hinted that I might have to use it again after my one hateful experience with it.

23
1
Silver badge

Re: ...programmers, aware that every additional character offers another chance to make an error...

Personally I leave all the brackets out of my equations, as by this metric it makes them more likely to be correct.

18
0

Page:

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Forums

Biting the hand that feeds IT © 1998–2018