Live data from Hacker News

The GitHub Styleguide

github.com

11–20 of 82 posts

Re: The GitHub Styleguide

#11
post #10

I liked their guideline on when to use bang methods like `array.map!` in ruby: "The names of potentially 'dangerous' methods (i.e. methods that modify self or the arguments, exit!, etc.) should end with an exclamation mark. Bang methods should only exist if a non-bang method exists. " That last sentence finally made me understand why `string.gsub!` takes a bang but `FileUtils.rm_rf(dir)` does not, even though the lat…

first time i heard that was from greg browns Ruby Best Practices book (was probably the best thing I took away from it). At this point (unfortunately) bang means almost nothing, since the reason to use bang seems to be different for every rubyist

Re: The GitHub Styleguide

#14
After reading this, I just want to say that I do not think semicolon-less javascript is, in general, a good idea.

Development projects are almost always team efforts. And, unfortunately, there's almost always one or two team members who aren't very good. Some of you folks that only work on startups with brilliant people might disagree, but in my experience most development teams have some bad apples who have let their tech skills rot, or won't try for some reason or another.

These people are going to have a tremendous time just writing halfway competent javascript (especially since it's probably not similar to their OOP language of choice). Suggesting they write code in an uncommon way is just begging for trouble. Most of the examples on the internet use semicolons, as do most of the frameworks. In fact, I hope that members of my future teams never see this javascript style guide or even know that it's possible to omit semicolons in many cases.

I'm quite sure someday soon I'm going to hear this over the cube wall: "Hey, GitHub doesn't use semicolons in their javascript so I won't either!" And then I will be very, very sad.

Re: The GitHub Styleguide

#15
post #14

After reading this, I just want to say that I do not think semicolon-less javascript is, in general, a good idea. Development projects are almost always team efforts. And, unfortunately, there's almost always one or two team members who aren't very good. Some of you folks that only work on startups with brilliant people might disagree, but in my experience most development teams have some bad apples who have let thei…

Yeah, you save one character per line, and gain a lot more in cognitive friction. Words to live by: "don't make me think" even about whether or not I need a semi-colon here.

Re: The GitHub Styleguide

#16
post #6

No semicolons in javascript! This is subversive and should be suppressed.

Their style guide disagrees with mine! KILL THEM ALL!!! Did you read the article they linked to? I did. I still disagree with the style rule, but I don't feel like I'd win an argument with them about it.

When it comes to arguments about semicolons, there are no winners.

Re: The GitHub Styleguide

#17

Scanning through the Ruby styleguide for GitHub-specific changes I found this gem: "The and and or keywords are banned. It's just not worth it. Always use && and || instead." sad trombone

Indeed, "and" and "or" are excellent for their intended use, for control flow. Like explained by the style guide the Github one is based on. https://github.com/bbatsov/ruby-style-guide

   # boolean expression
   if some_condition && some_other_condition
     do_something
   end

   # control flow
   document.saved? or document.save!

Re: The GitHub Styleguide

#18
post #14

After reading this, I just want to say that I do not think semicolon-less javascript is, in general, a good idea. Development projects are almost always team efforts. And, unfortunately, there's almost always one or two team members who aren't very good. Some of you folks that only work on startups with brilliant people might disagree, but in my experience most development teams have some bad apples who have let thei…

I completely agree with you. I'm also unsure about imposing coffeescript - although I find it interesting - in an enterprise environment.

I'd rather have nicely crafted and long winded javascript with convention followed, than half javascript and half coffeescript which will hurt people's brain at some stage.

Eventually, that stuff bites you and productivity - all that for the fame of using a brand new language (no offence intended) in the enterprise world. Assuming code is meant to live on for 4-5 years at least here.

Re: The GitHub Styleguide

#19
Interesting to see their choice in the never ending battle about the indentation of "private" in ruby. The lack of a empty line below "private" seems like it would make the code hard to read. The "private" could easily be missed.

Currently I prefer using "private" indented to the same level as "def", with no change of indentation of code after "private", and an empty line before and after "private".

Post reply on HN