The Ruby Style Guide is nearing its second birthday. The project has gained more attention and more traction than I could have imagined. For the millionth time I was amazed by the fantastic Ruby developers around the world.
The project has also steadily evolved:
- it covers more and more aspects of programming in Ruby
- it features many more code examples
- it is now translated in several languages
- it gave birth to the automated static code analyzer RuboCop
- it has become the basis for hundreds of slightly modified internal project or company style guides
One common criticism for the Ruby style guide is that it doesn’t feature extensive rationale about most of the rules in it. That’s deliberate – even now the document is pretty intimidating. If we were to delve into the reasoning behind each and every rule, the guide’s size might come close to that of a small book.
I do, however, feel that the rationale behind some of the rules is important. That’s why I’ll be starting a series of N posts devoted to the topic. I’ll try to cover as many of the rules as I can – from the more straightforward ones like maximum line length, to the most controversial ones like the use of single-quoted strings when possible. The articles will be published in no particular order and on no particular schedule.
Keep an eye out for the installments in the series here and on Twitter. I’m looking forward to many interesting discussions with you!
Feel free to take a look at the first article in the series, dedicated to the maximum line length we should aim for.
Articles in the Series
- The Elements of Style in Ruby #1: Maximum line length
- The Elements of Style in Ruby #2: Favor sprintf(format) over String#%
- The Elements of Style in Ruby #3: Make sure something is an array
- The Elements of Style in Ruby #4: Array#join vs Array#*
- The Elements of Style in Ruby #5: Readability of long numeric literals
- The Elements of Style in Ruby #6: Attributes Redux
- The Elements of Style in Ruby #7: The case against ===
- The Elements of Style in Ruby #8: Know Thy Predicates
- The Elements of Style in Ruby #9: Hash#has_key? and Hash#has_value? are deprecated
- The Elements of Style in Ruby #10: In cryptic Perlisms we do not trust
- The Elements of Style in Ruby #11: Invoking Lambdas/Procs