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 …

Page:

  1. andy 28

    pascal

    Ah, Borland, come back;

    happy days;

    1. Voland's right hand 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).

    2. Marco van de Voort

      Re: pascal

      Depends. Does it have semicolon's as statement separator (a la Pascal) or as statement terminator (a la C?)

      IOW is a semicolon before a non statement line (like a closing } ) required?

  2. Dan 55 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.

    1. teknopaul

      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

  3. ijustwantaneasylife

    Alternatively...

    How about something like...

    "use strict2";

    ... to force the requirement?

    1. Anonymous Coward
      Anonymous Coward

      Re: Alternatively...

      Or just use eslint.

    2. elDog

      Re: Alternatively...

      Do you need the trailing semi;?

      1. Anonymous Coward
        Anonymous Coward

        Re: Alternatively...

        "Do you need the trailing semi;?"

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

      2. el_oscuro

        Re: Alternatively...

        You also forgot the trailing; --

        1. sabroni Silver badge

          Re: Alternatively...

          Use an IDE that puts them in for you?

  4. caffeine addict

    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.

    1. Anonymous Coward
      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.

      1. Guus Leeuw

        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

        1. big_D 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?

          1. Alistair
            Windows

            Re: Tabs v spaces

            @BigD:

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

        2. Prst. V.Jeltz Silver badge

          Re: Tabs v spaces

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

          BOO!

        3. Wulfhaven

          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".

        4. Julz

          Re: Tabs v spaces

          @Guus Leeuw

          Can't up vote you enough...

        5. JLV

          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.

          1. el_oscuro

            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. eldakka

            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.

        6. Doctor Syntax 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.

          1. Anonymous Coward
            Anonymous Coward

            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.

        7. EarthDog

          Re: Tabs v spaces

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

          1. Mike Pellatt

            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. Anonymous Coward
            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

        8. Hans 1

          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).

        9. Anonymous Coward
          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

        10. Charlie Clark 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.

      2. Robin Bradshaw
        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. Simon Harris

          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"

          1. Matthew Taylor

            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. Anonymous Coward
              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!)

          2. Temmokan

            Re: Tabs v spaces

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

        2. Anonymous Coward
          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?

      3. Anonymous Coward
        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.

      4. nijam 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.

        1. handleoclast
          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!

      5. Anonymous Coward
        Anonymous Coward

        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.)

        1. Charlie Clark 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.

      6. Ken Hagan 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.

        1. mearnsgeek

          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. TotallyInfo

      Perhaps because JavaScript is used by LOTs of people who are not professional developers and to whom constant clutter is a distraction that makes it harder to write logic.

  5. Lysenko

    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.

    1. caffeine addict

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

    2. Anonymous Coward
      Anonymous Coward

      Awww diddums!

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

    3. Fred M

      "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.

    4. Jove Bronze badge

      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.

  6. Anonymous Coward
    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.

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

Other stories you might like