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

Why Ruby?

Why Ruby?

Slides for my Ruby landscape talk at Pretoria.rb - http://www.meetup.com/pretoria-rb/events/186593022

Kenneth Kalmer

June 18, 2014
Tweet

More Decks by Kenneth Kalmer

Other Decks in Programming

Transcript

  1. [1] pry(main)> class History [1] pry(main)* [1] pry(main)* def when?

    [1] pry(main)* 1995 [1] pry(main)* end [1] pry(main)* [1] pry(main)* def where? [1] pry(main)* "Japan" [1] pry(main)* end [1] pry(main)* [1] pry(main)* def by? [1] pry(main)* "Matz" [1] pry(main)* end [1] pry(main)* [1] pry(main)* end => :by? [2] pry(main)> lesson = History.new => #<History:0x007fcdb306a3f0> [3] pry(main)> lesson.when? => 1995 [4] pry(main)> lesson.where? => "Japan" [5] pry(main)> lesson.by? => "Matz"
  2. $ pry [1] pry(main)> 1.is_a?( Object ) && 1.is_a?( Fixnum

    ) => true ! [2] pry(main)> true.is_a?( Object ) && true.is_a?( TrueClass ) => true ! [3] pry(main)> nil.is_a?( Object ) && nil.is_a?( NilClass ) => true ! [4] pry(main)> "PTA".is_a?( Object ) && "PTA".is_a?( String ) => true
  3. $ pry [1] pry(main)> 1.object_id == 1.object_id => true !

    [2] pry(main)> "PTA".object_id == "PTA".object_id => false
  4. $ pry [1] pry(main)> require 'nokogiri' => true ! [2]

    pry(main)> require 'open-uri' => true ! [3] pry(main)> doc = Nokogiri::HTML(open("http://en.wikipedia.org/wiki/ Ruby_(programming_language)")) => #(Document:0x3fe11d253454…) ! [4] pry(main)> paragraph = doc.search('//*[@id="mw-content-text"]/p[23]').text => "Matsumoto has said that Ruby is designed for…” ! [5] pry(main)> paragraph =~ /"([^"]*)/ => 194 ! [6] pry(main)> $1 => "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. That is the primary purpose of Ruby language."
  5. require “*” • State of the art dependency management •

    Authors now building the same tool for the Rust programming language
  6. require “adhearsion” class MyController < Adhearsion::CallController def run answer resp

    = ask "How many woodchucks?", :limit => 1 say "You said #{resp}. That's obviously wrong!" end end ! # adhearsion.com
  7. require “artoo” connection :sphero, adaptor: :sphero, port: '4560' device :sphero,

    driver: :sphero ! work do every(3.seconds) do puts "Rolling..." sphero.roll 60, rand(360) end end ! # artoo.io
  8. require “simple_form” simple_form_for @user do |f| = f.input :email =

    f.input :password = f.submit "Login" • Rapid form building • Highlight errors • Wrappers for Bootstrap
  9. require “reform” class SongForm < Reform::Form property :title property :length

    ! validates :title, presence: true validates :length, numericality: true end ! class SongsController def new @form = SongForm.new(Song.new) end
  10. require “active_interaction” • Model business processes as simple objects. •

    Avoid the callback hell that so easily happens in models