contents/ruby-compendium/book/features.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
----- title: "Ruby Compendium - Advanced Language Features" content-type: page ----- <nav class="navigation"><a href="/ruby-compendium/book/core-stdlib.html">← The Core and the Standard Library</a> | <a href="/ruby-compendium/book/index.html">Contents</a> | <a href="/ruby-compendium/book/gems.html">Ruby Gems →</a> </nav> <p>One of the best things about Ruby is that you’re not stuck with a single programming paradigm. Even though everything in Ruby is an object (thereby making it a fully object-oriented language), nothing forbids you to program procedurally, or even use typical functional constructs.</p> <p>The beauty of this is that you can (and should) combine elements from different paradigms, resulting in very powerful and expressive code. What I really like about Ruby though is its inherent dynamic nature.</p> <p>You have a very few constraints when coding:</p> <ul> <li>you can open and close class definitions at will,</li> <li>you are not constrained by object types</li> <li>you can mix-in methods in multiple classes at the same time</li> <li>you can write code that <em>writes itself</em> dynamically (this is commonly called <em>metaprogramming</em>) </li> <li>you can easily create Domain-Specific Language to solve problems faster, with style</li> <li>you can create and pass around blocks of code</li> </ul> <p>All these things make the language very flexible and powerful. Do not overuse Ruby’s power: if your code starts to look like black magic, you’re probably going too far.</p> <aside class="box"> <div class="box-title">If you want to know more...</div> <p>…on specific and advanced Ruby features, check out these articles:</p> <ul> <li><a href="http://olabini.com/blog/2006/09/ruby-metaprogramming-techniques/">Ruby Metaprogramming techniques</a></li> <li><a href="http://www.skorks.com/2010/05/ruby-procs-and-lambdas-and-the-difference-between-them/">Ruby Procs And Lambdas (And The Difference Between Them)</a></li> <li><a href="http://juixe.com/techknow/index.php/2006/06/15/mixins-in-ruby/">Ruby Mixin Tutorial</a></li> <li><a href="http://www.valibuk.net/2009/03/domain-specific-languages-in-ruby/">Domain Specific Languages in Ruby</a></li> </ul> </aside> <nav class="navigation"><a href="/ruby-compendium/book/core-stdlib.html">← The Core and the Standard Library</a> | <a href="/ruby-compendium/book/index.html">Contents</a> | <a href="/ruby-compendium/book/gems.html">Ruby Gems →</a> </nav> |