Ruby

  • 5,531 views
Uploaded on

 

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,531
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
262
Comments
0
Likes
9

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1.
      • Ruby
      • A Programmer's Best Friend
    http://creativecommons.org/licenses/by/2.5/
  • 2. Disclaimer: This ((might|will) be|is) a Technical Talk
  • 3. Disclaimer: This might be a Technical Talk This will be a technical talk This is a Technical talk
  • 4. You decide.
  • 5. aizat.who?
    • Ezwan Aizat Bin Abdullah Faiz
      • [email_address]
    • Web Developer
    • Ruby, Ruby on Rails, PHP, LAMP
    • (Previous) MyOSS Meetup Organizer
  • 6. My Background
    • Still a University Student
      • Monash University
    • 10 years ago
      • Basic HTML
    • Took a long break
    • 5 years ago, I tried to learn
      • C++
    • 3 years ago, I learned
      • PHP
    • 1 year ago, I experimented with
      • C, Ruby, Python
    • Winner of the eGenting Competition 2006
      • using Ruby
  • 7. Ruby.is_a?
    • Programming Language
    • Interpreted Scripting Language
    • Duck language
    • Inspired from:
      • Smalltalk, Perl, Lisp, Python, CLU, Dylan
    • Syntax is generally like all other programming languages
  • 8. Ruby's History and Background
    • Developed in Japan
    • Yukihiro Matsumoto
      • Was in Malaysia last year for AsiaOSS
    • First public Release in 1995
    • Aim was in “trying to make Ruby natural, not simple,”
  • 9. Often people, especially computer engineers, focus on the machines . They think, "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." 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. Basic Features
    • Classes, Inheritance
    • Threads
    • Cross Platform
    • Iterators and Closures
    • Garbage Collection
    • Exception Handling
    • Object Oriented
    • Regular Expressions
    • Variables are not typed
    • Powerful string operations
    • Operator Overloading
    • Introspection, Reflection, Meta programming
  • 11. To Ruby From Java
    • Similarities
      • Garbage Collector
      • Objects are strongly typed
      • public, private and protected methods
      • Embedded doc tools
    • Differences
      • Don't need to compile code, just run it
      • No static type checking
      • No casting
    http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-java/
  • 12. To Ruby From PHP
    • Similarities
      • Dynamically typed
      • eval
      • Fairly large standard library
      • Arrays and hashes work like expected
    • Differences
      • Strong typing
      • Everything is an object
      • No abstract classes or interfaces
      • Almost everything is a method call
    http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-php/
  • 13.
      • Ruby declared TIOBE's Programming Language of 2006
      • http://www.oreillynet.com/ruby/blog/2007/01/ruby_declared_tiobes_programmi.html
  • 14. TIOBE Programming Community Index
  • 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.
      • Generally its like all other programming languages,
      • Except with a few syntax changes
  • 17. Conditions
    • General
    • Ruby
    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. Loops
    • General
    • Ruby
    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. Exception Handling
    • Ruby
    • General
    try { # ... } catch (Exception e) { # ... } finally { # ... } begin # ... rescue RuntimeException => e # ... rescue e # ... ensure # ... end
  • 20.
    • The Differences
      • “Ruby is simple in appearance, but is very complex inside, just like our human body”
      • Yukihiro Matsumoto
      • http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/2773
  • 21. Optional Syntax Full of Expression
  • 22. Expression
    • Parentheses are optionals (sometimes)
    • Semicolons are optional
    • Methods can include '!' and '?'
    array.uniq.sort “ Ruby IS THE BOMB”.downcase! “ Regular expressions are fun”.gsub(/fun/, 'sweet') “ Wasting space “.strip!
  • 23. Simpler AND Nicer looking code
  • 24. Everything is an Object
  • 25.
    • Numbers and other primitive types are not objects
    1.upto(100) { |i| puts i } 3.14159265.ciel 2.71828182845905.floor
  • 26.
      • Meta Programming
      • (or shooting oneself in the foot)
  • 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 http://en.wikipedia.org/wiki/Metaprogramming
  • 28. Magic!
    • Santize a string
    • Convert all non alphanumeric to a 'underscore'
    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.
    • Need to shuffle an array?
    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.
      • Why Ruby?
  • 31.
    • Simpler and concise
    • Full of expression
    • Easier to understand
    • Productive
    • Large number of libraries
  • 32. But, mainly because it's a lot more FUN
  • 33. Who uses Ruby?
    • HP
    • Sun
    • Microsoft
    • Intel
    • NASA
    • NOAA
    • 37 signals
    • etc...
    • Whole community built around it
    • Ruby Central - Non Profit Organization
    • Ruby Conference
    • etc...
  • 34. Ruby on Rails
      • Convention over Configuration
      • http://www.rubyonrails.com
  • 35. Hottest thing to hit Web Development
    • Web Application Framework
    • Rapid Application/Iterative Development
    • AJAX ready
    • Convention over Configuration
    • Why Ruby?
      • Dynamic
      • Flexible
      • Utilizes Meta Programming heavily
      • Domain specific language
  • 36. Buzz Words Buzz Words Buzz Words
  • 37. Popular Sites
    • Basecamp
      • Project Management
    • Twitter
      • What are you doing?
  • 38. Why not Ruby?
  • 39. Several Limitations
    • Slow performance
      • not massively, just marginally
      • Benefit is better code
      • Now a days we have processing cycles to waste
      • Write it in Ruby C Extensions!
      • Fixed in Ruby 2.0
    • Limited Unicode Support
      • Fixed in Ruby 2.0
    • So when is Ruby 2.0 coming out?
      • Hopefully soon...
  • 40. Resources Programs
  • 41. IRB – Interactive Ruby
    • Experiment with Ruby from the command line
    • Write quick code snippets
    • Enhanceable using Ruby
      • Support syntax highlighting
    $ irb >> puts “Hello World” Hello World => nil >>
  • 42. RI – Ruby Information
    • Quick Ruby documentation
    • Takes from both the ruby core code and the external libraries (rubygems)
    $ ri String#chop! Returns a new String with the last character removed. If the string ends with , both characters are removed. Applying chop ...
  • 43. Resources Sites
  • 44. Informational
    • Ruby Progamming Language
    • http://www.ruby-lang.org
    • Wikipedia
      • all knowing, all powerful Wikipedia
      • http://www.ruby-lang.org
  • 45. Learning
    • Why's (Poignant) Guide to Ruby
    • http://poignantguide.net/ruby/
    • Ruby In Twenty Minutes
    • http://www.ruby-lang.org/en/documentation/quickstart/
  • 46. MyOSS Meetup
    • Bob Sutor
    • Speaking on Open Source, Open Standards and ODF
    • The Shift to 'Open': Boost or Brakes for Innovation and Business
    • 20 th April (next Friday)
    • Open University Malaysia (near KLCC)
    • 7:00-9:30pm
      • http://foss.org.my/projects/meetups/april-2007
  • 47.
      • Questions?
      • Thank You
      • [email_address]
  • 48.
      • Let's Dive Into Ruby