# Code Conventions for Ruby

**URL:** <https://rubytalk.org/t/code-conventions-for-ruby/11407>\
**Category:** ruby-talk\
**Created:** [7 May 2004 15:03 UTC](https://rubytalk.org/t/code-conventions-for-ruby/11407 "2004-05-07T15:03:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vladare](https://avatars.discourse-cdn.com/v4/letter/v/e36b37/32.png) [@Vladare](https://rubytalk.org/u/Vladare)\
**Post date:** [7 May 2004 15:03 UTC](https://rubytalk.org/t/code-conventions-for-ruby/11407/1 "2004-05-07T15:03:55Z")

</div>

Hi All,

Is there on net some completeness manuals described Code Conventions  
for the Ruby like manual below ?

[http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html](http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html)

Best Regards,  
Vladare

---

<div class="post-metadata">

**Author:** ![Dave\_Burt](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@Dave\_Burt](https://rubytalk.org/u/Dave_Burt)\
**Post date:** [11 May 2004 14:28 UTC](https://rubytalk.org/t/code-conventions-for-ruby/11407/2 "2004-05-11T14:28:57Z")

</div>

> … Code Conventions for Ruby … ?

TMTOWTDI

A bit like Perl, which can get messy, except the language itself, by things  
like newlines instead of semicolons, encourages you to write legibly (or  
maybe the newlines/semicolons thing is the only way).

Actually, now I think more about it, there seems to be almost a de-facto  
standard of two spaces per indentation level.

And, now I do some research, I find that there’s the start of a collection  
of this kind of thing in the RubyGarden:

> **[WebMD - Better information. Better health.](https://www.webmd.com/?RubyStyleGuide)**
>
> The leading source for trustworthy and timely health and medical news and information. Providing credible health information, supportive community, and educational services by blending award-winning expertise in content, community services, expert...

---

<div class="post-metadata">

**Author:** ![David\_A\_Black3](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@David\_A\_Black3](https://rubytalk.org/u/David_A_Black3)\
**Post date:** [11 May 2004 22:38 UTC](https://rubytalk.org/t/code-conventions-for-ruby/11407/3 "2004-05-11T22:38:51Z")

</div>

Hi –

“Dave Burt” [burtdav@hotmail.com](mailto:burtdav@hotmail.com) writes:

> > … Code Conventions for Ruby … ?
> 
> TMTOWTDI

But even in Perl, whose motto that is, that doesn’t mean everything is  
equally smiled upon; Perl actually comes with a style guide 🙂

> A bit like Perl, which can get messy, except the language itself, by things  
> like newlines instead of semicolons, encourages you to write legibly (or  
> maybe the newlines/semicolons thing is the only way).
> 
> Actually, now I think more about it, there seems to be almost a de-facto  
> standard of two spaces per indentation level.
> 
> And, now I do some research, I find that there’s the start of a collection  
> of this kind of thing in the RubyGarden:  
> [http://www.rubygarden.org/ruby?RubyStyleGuide](http://www.rubygarden.org/ruby?RubyStyleGuide)

See also:

[http://pub.cozmixng.org/~the-rwiki/rw-cgi.rb?cmd=view;name=RubyCodingConvention](http://pub.cozmixng.org/~the-rwiki/rw-cgi.rb?cmd=view;name=RubyCodingConvention)

You can also look to the Ruby core library for guidance on style  
matters. It’s not completely uniform but it’s very close in certain  
matters that come up again and again (indentation, variable\_names,  
etc.). That way, even if you decide to depart from aspects of Matz’s  
style, you’ll at least know you’re doing so 🙂

David

> **···**
>
> –  
> David A. Black  
> [dblack@wobblini.net](mailto:dblack@wobblini.net)
