Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

Published in: Technology, Education
  • Be the first to comment


  1. 1. <ul><ul><li>Ruby </li></ul></ul><ul><ul><li>A Programmer's Best Friend </li></ul></ul>
  2. 2. Disclaimer: This ((might|will) be|is) a Technical Talk
  3. 3. Disclaimer: This might be a Technical Talk This will be a technical talk This is a Technical talk
  4. 4. You decide.
  5. 5. aizat.who? <ul><li>Ezwan Aizat Bin Abdullah Faiz </li></ul><ul><ul><li>[email_address] </li></ul></ul><ul><li>Web Developer </li></ul><ul><li>Ruby, Ruby on Rails, PHP, LAMP </li></ul><ul><li>(Previous) MyOSS Meetup Organizer </li></ul>
  6. 6. My Background <ul><li>Still a University Student </li></ul><ul><ul><li>Monash University </li></ul></ul><ul><li>10 years ago </li></ul><ul><ul><li>Basic HTML </li></ul></ul><ul><li>Took a long break </li></ul><ul><li>5 years ago, I tried to learn </li></ul><ul><ul><li>C++ </li></ul></ul><ul><li>3 years ago, I learned </li></ul><ul><ul><li>PHP </li></ul></ul><ul><li>1 year ago, I experimented with </li></ul><ul><ul><li>C, Ruby, Python </li></ul></ul><ul><li>Winner of the eGenting Competition 2006 </li></ul><ul><ul><li>using Ruby </li></ul></ul>
  7. 7. Ruby.is_a? <ul><li>Programming Language </li></ul><ul><li>Interpreted Scripting Language </li></ul><ul><li>Duck language </li></ul><ul><li>Inspired from: </li></ul><ul><ul><li>Smalltalk, Perl, Lisp, Python, CLU, Dylan </li></ul></ul><ul><li>Syntax is generally like all other programming languages </li></ul>
  8. 8. Ruby's History and Background <ul><li>Developed in Japan </li></ul><ul><li>Yukihiro Matsumoto </li></ul><ul><ul><li>Was in Malaysia last year for AsiaOSS </li></ul></ul><ul><li>First public Release in 1995 </li></ul><ul><li>Aim was in “trying to make Ruby natural, not simple,” </li></ul>
  9. 9. Often people, especially computer engineers, focus on the machines . They think, &quot;By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, the machine will something something something.&quot; They are focusing on machines . But in fact we need to focus on humans , on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves. Yukihiro Matsumoto
  10. 10. Basic Features <ul><li>Classes, Inheritance </li></ul><ul><li>Threads </li></ul><ul><li>Cross Platform </li></ul><ul><li>Iterators and Closures </li></ul><ul><li>Garbage Collection </li></ul><ul><li>Exception Handling </li></ul><ul><li>Object Oriented </li></ul><ul><li>Regular Expressions </li></ul><ul><li>Variables are not typed </li></ul><ul><li>Powerful string operations </li></ul><ul><li>Operator Overloading </li></ul><ul><li>Introspection, Reflection, Meta programming </li></ul>
  11. 11. To Ruby From Java <ul><li>Similarities </li></ul><ul><ul><li>Garbage Collector </li></ul></ul><ul><ul><li>Objects are strongly typed </li></ul></ul><ul><ul><li>public, private and protected methods </li></ul></ul><ul><ul><li>Embedded doc tools </li></ul></ul><ul><li>Differences </li></ul><ul><ul><li>Don't need to compile code, just run it </li></ul></ul><ul><ul><li>No static type checking </li></ul></ul><ul><ul><li>No casting </li></ul></ul>
  12. 12. To Ruby From PHP <ul><li>Similarities </li></ul><ul><ul><li>Dynamically typed </li></ul></ul><ul><ul><li>eval </li></ul></ul><ul><ul><li>Fairly large standard library </li></ul></ul><ul><ul><li>Arrays and hashes work like expected </li></ul></ul><ul><li>Differences </li></ul><ul><ul><li>Strong typing </li></ul></ul><ul><ul><li>Everything is an object </li></ul></ul><ul><ul><li>No abstract classes or interfaces </li></ul></ul><ul><ul><li>Almost everything is a method call </li></ul></ul>
  13. 13. <ul><ul><li>Ruby declared TIOBE's Programming Language of 2006 </li></ul></ul><ul><ul><li> </li></ul></ul>
  14. 14. TIOBE Programming Community Index
  15. 15. TIOBE Programming Community Index In the recent past it was necessary to have a large company behind the language to get it in the spotlight (Sun with Java, Microsoft with C#), but nowadays a killer app appears to be sufficient. Viral marketing via the Internet works! The winners of the last 2 years, PHP and Java, are the losers of this year.
  16. 16. <ul><ul><li>Generally its like all other programming languages, </li></ul></ul><ul><ul><li>Except with a few syntax changes </li></ul></ul>
  17. 17. Conditions <ul><li>General </li></ul><ul><li>Ruby </li></ul>if condition # ... elsif condition2 # ... else # ... end b = a if condition unless condition # ... else # ... end b = a unless condition if (condition) { # ... } else if (condition2) { # ... } else { # ... }
  18. 18. Loops <ul><li>General </li></ul><ul><li>Ruby </li></ul>while i < 5 # ... end until i == 5 # ... end apples.each { | apple | ... } shapes.each do | shape | puts shape.polygon? puts shape.sides? end while (condition) { # ... } for (int i; i < array.length; i++) { # ... }
  19. 19. Exception Handling <ul><li>Ruby </li></ul><ul><li>General </li></ul>try { # ... } catch (Exception e) { # ... } finally { # ... } begin # ... rescue RuntimeException => e # ... rescue e # ... ensure # ... end
  20. 20. <ul><li>The Differences </li></ul><ul><ul><li>“Ruby is simple in appearance, but is very complex inside, just like our human body” </li></ul></ul><ul><ul><li>Yukihiro Matsumoto </li></ul></ul><ul><ul><li> </li></ul></ul>
  21. 21. Optional Syntax Full of Expression
  22. 22. Expression <ul><li>Parentheses are optionals (sometimes) </li></ul><ul><li>Semicolons are optional </li></ul><ul><li>Methods can include '!' and '?' </li></ul>array.uniq.sort “ Ruby IS THE BOMB”.downcase! “ Regular expressions are fun”.gsub(/fun/, 'sweet') “ Wasting space “.strip!
  23. 23. Simpler AND Nicer looking code
  24. 24. Everything is an Object
  25. 25. <ul><li>Numbers and other primitive types are not objects </li></ul>1.upto(100) { |i| puts i } 3.14159265.ciel 2.71828182845905.floor
  26. 26. <ul><ul><li>Meta Programming </li></ul></ul><ul><ul><li>(or shooting oneself in the foot) </li></ul></ul>
  27. 27. What is Meta Programming? Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data or that do part of the work during compile time that is otherwise done at run time. In many cases, this allows programmers to get more done in the same amount of time as they would take to write all the code manually. Taken from
  28. 28. Magic! <ul><li>Santize a string </li></ul><ul><li>Convert all non alphanumeric to a 'underscore' </li></ul>class String def sanitize self .gsub( / [^a-z1-9]+ /i , ' _ ' ) end end puts &quot; Ruby gives you alot of $$$ yo! &quot; .sanitize # Ruby_gives_you_alot_of_yo_
  29. 29. <ul><li>Need to shuffle an array? </li></ul>class Array def shuffle size.downto( 1 ) { | n | push delete_at(rand(n)) } self end end %w[ a b c d e f g ] .shuffle # [&quot;c&quot;, &quot;e&quot;, &quot;f&quot;, &quot;g&quot;, &quot;b&quot;, &quot;d&quot;, &quot;a&quot;]
  30. 30. <ul><ul><li>Why Ruby? </li></ul></ul>
  31. 31. <ul><li>Simpler and concise </li></ul><ul><li>Full of expression </li></ul><ul><li>Easier to understand </li></ul><ul><li>Productive </li></ul><ul><li>Large number of libraries </li></ul>
  32. 32. But, mainly because it's a lot more FUN
  33. 33. Who uses Ruby? <ul><li>HP </li></ul><ul><li>Sun </li></ul><ul><li>Microsoft </li></ul><ul><li>Intel </li></ul><ul><li>NASA </li></ul><ul><li>NOAA </li></ul><ul><li>37 signals </li></ul><ul><li>etc... </li></ul><ul><li>Whole community built around it </li></ul><ul><li>Ruby Central - Non Profit Organization </li></ul><ul><li>Ruby Conference </li></ul><ul><li>etc... </li></ul>
  34. 34. Ruby on Rails <ul><ul><li>Convention over Configuration </li></ul></ul><ul><ul><li> </li></ul></ul>
  35. 35. Hottest thing to hit Web Development <ul><li>Web Application Framework </li></ul><ul><li>Rapid Application/Iterative Development </li></ul><ul><li>AJAX ready </li></ul><ul><li>Convention over Configuration </li></ul><ul><li>Why Ruby? </li></ul><ul><ul><li>Dynamic </li></ul></ul><ul><ul><li>Flexible </li></ul></ul><ul><ul><li>Utilizes Meta Programming heavily </li></ul></ul><ul><ul><li>Domain specific language </li></ul></ul>
  36. 36. Buzz Words Buzz Words Buzz Words
  37. 37. Popular Sites <ul><li>Basecamp </li></ul><ul><ul><li>Project Management </li></ul></ul><ul><li>Twitter </li></ul><ul><ul><li>What are you doing? </li></ul></ul>
  38. 38. Why not Ruby?
  39. 39. Several Limitations <ul><li>Slow performance </li></ul><ul><ul><li>not massively, just marginally </li></ul></ul><ul><ul><li>Benefit is better code </li></ul></ul><ul><ul><li>Now a days we have processing cycles to waste </li></ul></ul><ul><ul><li>Write it in Ruby C Extensions! </li></ul></ul><ul><ul><li>Fixed in Ruby 2.0 </li></ul></ul><ul><li>Limited Unicode Support </li></ul><ul><ul><li>Fixed in Ruby 2.0 </li></ul></ul><ul><li>So when is Ruby 2.0 coming out? </li></ul><ul><ul><li>Hopefully soon... </li></ul></ul>
  40. 40. Resources Programs
  41. 41. IRB – Interactive Ruby <ul><li>Experiment with Ruby from the command line </li></ul><ul><li>Write quick code snippets </li></ul><ul><li>Enhanceable using Ruby </li></ul><ul><ul><li>Support syntax highlighting </li></ul></ul>$ irb >> puts “Hello World” Hello World => nil >>
  42. 42. RI – Ruby Information <ul><li>Quick Ruby documentation </li></ul><ul><li>Takes from both the ruby core code and the external libraries (rubygems) </li></ul>$ ri String#chop! Returns a new String with the last character removed. If the string ends with , both characters are removed. Applying chop ...
  43. 43. Resources Sites
  44. 44. Informational <ul><li>Ruby Progamming Language </li></ul><ul><li> </li></ul><ul><li>Wikipedia </li></ul><ul><ul><li>all knowing, all powerful Wikipedia </li></ul></ul><ul><ul><li> </li></ul></ul>
  45. 45. Learning <ul><li>Why's (Poignant) Guide to Ruby </li></ul><ul><li> </li></ul><ul><li>Ruby In Twenty Minutes </li></ul><ul><li> </li></ul>
  46. 46. MyOSS Meetup <ul><li>Bob Sutor </li></ul><ul><li>Speaking on Open Source, Open Standards and ODF </li></ul><ul><li>The Shift to 'Open': Boost or Brakes for Innovation and Business </li></ul><ul><li>20 th April (next Friday) </li></ul><ul><li>Open University Malaysia (near KLCC) </li></ul><ul><li>7:00-9:30pm </li></ul><ul><ul><li> </li></ul></ul>
  47. 47. <ul><ul><li>Questions? </li></ul></ul><ul><ul><li>Thank You </li></ul></ul><ul><ul><li>[email_address] </li></ul></ul>
  48. 48. <ul><ul><li>Let's Dive Into Ruby </li></ul></ul>