10 Things you should know about Ruby

Preview:

DESCRIPTION

Interrest in Ruby? I think these are 10 things you should know about it. This slide is released under CC-BY-NC-SA

Citation preview

10 ThingsYou Should Know About

Ruby

1. Ruby != Rails

• Programming Language

• 1995 – First public release

• Many Implementations

• MRI 1.8 – Matz’s Ruby Intepreter

• YARV 1.9

• JRuby

• IronRuby

• Rubinius

• MacRuby

• MagLev

• Web application framework written in Ruby

• “Ruby” on “Rails”

• David Heinemeier Hansson (DHH)

• Extracted from 37Signal’s Basecamp in 2004

• Open Source

• Currently maintained by Rails Core Team

• git://github.com/rails/rails

• Latest version: 3.0.1

No more confusion!

http://www.flickr.com/photos/ecstaticist/2589723846/

2. Simple syntax

Too Easy!

http://www.flickr.com/photos/clairity/143368932/

3. Pure Object-Oriented

Everything in Rubyis Object

No Primitive

Even nil ...

... and class!

http://www.flickr.com/photos/gastev/2630867950/

Related to duck!

4. No method call

“Message sending”

5. Mixin

Module

Module

• Collection of methods and constants

• Not-instanciatable

• But callable

• Append features upon included

Multiple inheritanceis very bad

Mixin

• Include methods you want from another module

• No limit of how many modules you include

{ 6. }

(block)

“Closure”

Ruby’s Block

• Passing a block as argument

• Method “yield” or “call” the block

• May passing a object as argument

• Result from the block goes back to the method

7. We love duck

http://www.flickr.com/photos/ymorimo/3975152607/

Duck typing

• If it quacks like a duck, it’s a duck!

• Check for object’s property, not interface

Duck Punching!

Duck Punching(Monkey patch)

• Objects and class are open

• Add method to object even at Runtime!

• Not really recommend, less maintainability, might break some stuff

• But it’s awesome

8. Testing isFFFF**...

(FFFFUUNNN)

Encourage testing

Testing ...

• Ensure everything still works after you make change to something else

• Save you ass from client’s call at 3AM

• Test driven development

• Write test – watch it fails – write just enough code to make it pass – refactor

Testing tools

• RSpec

• Cucumber

• Test::Unit

• Rack::Test

9. RubyGems

Libraries in Ruby

http://rubygems.org

Gem

• Library written under Ruby or C

• Packaged by owner and upload to RubyGems.org

• Easy to install, just gem install gem_name

10. IT’S FUN!

Question?

Thank you!

Prem Sichanugrist

@sikachu

http://sikachu.com

3.9454 in

Beautiful Software