Upgrade to Pro — share decks privately, control downloads, hide ads and more …

10 Things you should know about Ruby

10 Things you should know about Ruby

Interrest in Ruby? I think these are 10 things you should know about it.

This was presented in Barcamp Bangkok 4, Oct 23-24, 2010, at Sripathum University Bangkhen Campus.

F1c4a3bb1606cc4a61711e61e2fe6146?s=128

Prem Sichanugrist

October 23, 2010
Tweet

More Decks by Prem Sichanugrist

Other Decks in Programming

Transcript

  1. 10 Things You Should Know About Ruby

  2. 1. Ruby != Rails

  3. • Programming Language • 1995 – First public release •

    Many Implementations • MRI 1.8 – Matz’s Ruby Intepreter • YARV 1.9 • JRuby • IronRuby • Rubinius • MacRuby • MagLev
  4. “I wanted a scripting language that was more powerful than

    Perl, and more object-oriented than Python. That's why I decided to design my own language”
  5. Smalltalk Perl Lisp Scheme Python CLU Eiffel Ada Dylan {

  6. • Web application framework written in Ruby • “Ruby” on

    “Rails” • David Heinemeier Hansson (DHH) • Extracted from 37Signal’s Basecamp in 2004
  7. • Open Source • Currently maintained by Rails Core Team

    • git://github.com/rails/rails • Latest version: 3.0.1
  8. No more confusion! http://www.flickr.com/photos/ecstaticist/2589723846/

  9. 2. Simple syntax

  10. None
  11. None
  12. None
  13. None
  14. None
  15. None
  16. None
  17. Too Easy! http://www.flickr.com/photos/clairity/143368932/

  18. 3. Pure Object-Oriented

  19. Everything in Ruby is Object

  20. No Primitive

  21. None
  22. Even nil ...

  23. None
  24. ... and class!

  25. None
  26. http://www.flickr.com/photos/gastev/2630867950/ Related to duck!

  27. 4. No method call

  28. “Message sending”

  29. None
  30. None
  31. http://www.flickr.com/photos/headlouse/1484615917/

  32. 5. Mixin

  33. Module

  34. Module • Collection of methods and constants • Not-instanciatable •

    But callable • Append features upon included
  35. Multiple inheritance is very bad

  36. Mixin • Include methods you want from another module •

    No limit of how many modules you include
  37. None
  38. { 6. } (block)

  39. “Closure”

  40. 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
  41. None
  42. 7. We love duck http://www.flickr.com/photos/ymorimo/3975152607/

  43. Duck typing • If it quacks like a duck, it’s

    a duck! • Check for object’s property, not interface
  44. None
  45. None
  46. Duck Punching!

  47. 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
  48. None
  49. 8. Testing is FFFF**... (FFFFUUNNN)

  50. Encourage testing

  51. 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
  52. Testing tools • RSpec • Cucumber • Test::Unit • Rack::Test

  53. None
  54. 9. RubyGems

  55. Libraries in Ruby

  56. http://rubygems.org

  57. Gem • Library written under Ruby or C • Packaged

    by owner and upload to RubyGems.org • Easy to install, just gem install gem_name
  58. 10. IT’S FUN!

  59. Question? Thank you! Prem Sichanugrist @sikachu http://sikachu.com 3.9454 in Beautiful

    Software