Ask HN: Your favourite style guide?
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.
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.
An example of some interesting things I learned or of which I was reminded:
http://google-styleguide.googlecode.com/svn/trunk/pyguide.html
* utilizing methods of the 'operator' module instead of composing lambdas to perform basic operations
* cautioning against testing for 'implicit false' when dealing with numerical values (to avoid conflating 0 and None)
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'.
best wishes + happy hacking,
- mek
9 comments
[ 3.3 ms ] story [ 27.5 ms ] threadCode 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...
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://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style?rev...
http://google-styleguide.googlecode.com/svn/trunk/javascript...
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.