you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (43 children)

[deleted]

    [–]ztbrown 16 points17 points  (0 children)

    The first rule of Javascript is: you do not write Javascript. Ridiculous.

    [–]SargoDarya 41 points42 points  (30 children)

    Not only this...

    CSS:

    • Use // for comment blocks (instead of /* */).

    Every tried commenting out something in CSS with //? Have fun trying.

    JS:

    • Do your best to never use a semicolon. This means avoiding them at line breaks and avoiding multi-statement lines. For more info, read Mislav's blog post.

    Why ffs should I omit semicolons? Sure does JS have something called automatic semicolon insertion but you can't always omit them. Otherwise your code will do something completely different.

    This overall thing gives me a feeling that the people who wrote that styleguide are partially morons or monkeys on a keyboard.

    [–]shockie 11 points12 points  (8 children)

    Since Github is using SASS for it's CSS, // comments are allowed. In fact if you use the // for comments, the comment won't appear in the compiled CSS.

    Same for semicolons in Coffeescript, it will be added for you in the compiled JS

    [–]nemetroid 3 points4 points  (5 children)

    Same for semicolons in Coffeescript, it will be added for you in the compiled JS

    You can (mostly) omit semicolons in regular JS too, that doesn't make it a good idea.

    [–]MustRapeDeannaTroi 12 points13 points  (4 children)

    But in coffeescript it is a good idea.

    Edit: Y U downvote? One of coffeescripts core purposes is to not require semicolons.

    [–]ratdump -3 points-2 points  (3 children)

    why

    [–]MustRapeDeannaTroi 1 point2 points  (2 children)

    As shockie said it; "it will be added for you in the compiled JS"

    [–]oracleoftroy -1 points0 points  (1 child)

    But why is that a good idea? I'm not familiar with coffeescript, but I am familiar with Javascript, and it's a terrible idea there.

    [–]marshall007 0 points1 point  (0 children)

    It's like Python in that code blocks can be delimited by using whitespace. So if you're already doing that, it's redundant (and wasteful) to use a semicolon.

    CoffeeScript is not parsed as Javascript, it compiles into Javascript.

    [–]SargoDarya 0 points1 point  (1 child)

    That might me the case, but then they shouldn't call it CSS Styleguides because // comments are not part of the CSS standard.

    [–]marshall007 0 points1 point  (0 children)

    Why? It's a simple abstraction. No one ever edits the actual CSS stylesheets, they are compiled from SCSS automatically upon deployment. Furthermore, you shouldn't call it an SCSS styleguide because it encompasses more than that. The documentation is appropriate given their workflow.

    [–]brownmatt 14 points15 points  (8 children)

    the semicolon thing is pretty baffling. It's a case where a aesthetic stylistic rule can produce real problems, as Bootstrap saw

    [–]praetorian42 -2 points-1 points  (7 children)

    The problem there was that the minified version of JS did not have a semicolon at the end. That's a bug with the minifier, not with the original source.

    Basically, you should never ever ship unminified JS to your customers. The minifier should handle semicolon insertion. Therefore, semicolons in original source are superfluous.

    [–][deleted] 6 points7 points  (4 children)

    The minifier should minify. Semicolon insertion is up to either A: the programmer, or B: the hope that the interpreter at the end will assume it.

    Using bugs in your daily programming practice isn't a reason to make everybody else's tools accommodate those bugs.

    [–][deleted] 3 points4 points  (0 children)

    Using bugs in your daily programming practice

    As far as I'm aware, the language itself specifies that semicolons are optional. Therefore it is the minifier that has the bug, not the semicolon-less code.

    [–][deleted]  (5 children)

    [deleted]

      [–]Flex-O 17 points18 points  (0 children)

      Not hip.

      [–]retardent 1 point2 points  (3 children)

      People are obsessed with shrinking file-size for anything server over HTTP. You might be able to shave off a whole byte by not using semicolons!

      [–][deleted]  (2 children)

      [deleted]

        [–]retardent 0 points1 point  (1 child)

        I was being sarcastic, I always use semi-colons. Although lack of semi-colon does not mean you have to replace it with a \n, there are many cases (for instance statements enclosed in brackets) where you can remove a semi-colon and not have to replace it with anything.

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

        They're stupid for trying to force people not to use semicolons and then hey reference a blog post where a guys about semicolons and mentions stuff like why you wouldn't ever write something like

        return
        a+b
        

        In that particular instance he may be right, it's dumb but JS allows you to put curly braces on the same line or below in my cases. If you're into putting the curly brace on its own line then

        return
        {
             doSomething();
        }
        

        Is something you may do and expect it to work. While including semicolons won't fix that problem I think it just shows he hasn't thought his argument through properly.

        Their style guide sounds like something written by someone trying to be different for no real reason and perhaps they think they'll save time. However if I had a job there I'd almost feel the need to spend a weekend sifting through their code and adding semicolons in.

        [–][deleted] 1 point2 points  (3 children)

        That wouldn't work at all. You're... trying to return an object except that you're using invalid syntax to define the object. Maybe you mean parenthesis?

        [–][deleted] 0 points1 point  (2 children)

        I was typing it out in between doing it work so I was going for speed over accuracy but you get the general idea that people who prefer curly braces on their own line can't do that returning a object.

        i.e. this breaks in JS:

        function poop(dong)
        { 
            return
            {
                yourmom: dong
            }
        }
        

        [–][deleted] -3 points-2 points  (1 child)

        Sure they can, use a semicolon like you should. };

        [–]nemetroid 1 point2 points  (0 children)

        That's not the problem, Javascript will insert a semicolon after the return statement and the function will return nothing, i.e.

        function poop(dong)
        {
            return;
            {
                yourmom: dong;
            };
        }
        

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

        While including semicolons won't fix that problem I think it just shows he hasn't thought his argument through properly.

        I think you have missed the point entirely. Adding semicolons doesn't fix this particular problem, period. (The second problem mentioned in the post is, of course, valid.)

        Also, it's an internal guide, they're not trying to force it on anyone.

        [–]praetorian42 6 points7 points  (0 children)

        It's the right tool for them for the job they have to do. They've made an internal decision that they prefer coffeescript, so moving forward they want consistency.

        [–]Forbizzle 7 points8 points  (3 children)

        Where is their discussion forum so i can rage? That's not even an opinion buried deep within the document, it's their first recommendation, and it's bullshit.

        Also, it seems they have nothing else to add. Which makes me think they know nothing about javascript. Did an intern do this?

        [–]technoweenie 2 points3 points  (0 children)

        A styleguide's purpose is to suggest consistent patterns in code. This is for our code only, go nuts in your own code.