
Ask HN: Your favourite style guide? - mekarpeles
I was laying in bed and suddenly found myself wondering, what are the best examples of style guides for different languages. As a python enthusiast and moderate Google fan boy, I thought I'd take a look at how Google does things.<p>I've visited Google's Python style guide several times before, but never really spent time reading through the fine print and digging into the company's reasoning for their style choices.<p>In retrospect, there are many mistakes I could have avoided and good practices I could have adopted, had I originally read Google's style guides more comprehensively.<p>An example of some interesting things I learned or of which I was reminded:<p>http://google-styleguide.googlecode.com/svn/trunk/pyguide.html<p>* utilizing methods of the 'operator' module instead of composing lambdas to perform basic operations<p>* cautioning against testing for 'implicit false' when dealing with numerical values (to avoid conflating 0 and None)<p>The experience left me wondering, which style guides hackers have found most helpful for different languages. I'm also curious to hear opinions on whether these style guides are adequate for all skill levels (do they help programmers grow) or whether they cater to building a 'good programmer/code base' rather than a 'good programmer'.<p>best wishes + happy hacking,<p>- mek
======
mekarpeles
In case other Python enthusiasts are seeking additional resources (besides
reading PEP 8) Bhadra and others on stack overflow suggest:

Code Like a Pythonista: Idiomatic Python
(<http://python.net/~goodger/projects/pycon/2007/idiomatic/>)

Common mistakes and Warts (<http://learnpython.pbwiki.com/PythonTricks>)

How not to write Python code (<http://eikke.com/how-not-to-write-python-
code/>)

Python gotcha (<http://eikke.com/python-gotcha/>)

Here's the stack overflow thread I was looking at:
[http://stackoverflow.com/questions/356161/python-coding-
stan...](http://stackoverflow.com/questions/356161/python-coding-standards-
best-practices)

------
mhd
PEP 20.

If you need something longer, the official Java Coding Style[1] is getting a
bit old, but Java is probably _the_ language where you're least surprised when
you start working at a new company or project.

Other than that, I prefer actual books that don't just focus on indentation,
but go beyond that, like Perl Best Practices or Smalltalk With Style.

[1]:
[http://www.oracle.com/technetwork/java/codeconvtoc-136057.ht...](http://www.oracle.com/technetwork/java/codeconvtoc-136057.html)

------
yayitswei
Google's Javascript style guide is also pretty helpful:

[http://google-
styleguide.googlecode.com/svn/trunk/javascript...](http://google-
styleguide.googlecode.com/svn/trunk/javascriptguide.xml)

We have a linter run checks on each commit. Adding too many barriers to
committing isn't good, but so far this seems to work well.

------
mekarpeles
I'd also be very interested in hearing how different companies have come to
develop their own style guides and what special cases necessitated said
changes. If anyone has a style guide they've written and would like to share
it, I'd love to take a look.

------
godisdad
I am particular to Netbsd's Kernel Normal Form:

[http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style?rev...](http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style?rev=1.50&content-
type=text/x-cvsweb-markup)

------
Hates_
Github has a collection for CSS, HTML, Javascript and Ruby:
<https://github.com/styleguide/>

~~~
mekarpeles
This is great, I didn't know this existed. Thanks Hates_!

------
lmm
Twitter's scala guide is fantastic:
<http://twitter.github.com/effectivescala/>

~~~
mekarpeles
Thanks for sharing this reference, lmm. Pretty solid guide. I'm pretty new to
scala so I'm looking forward to reading through this.

