Good morning!



Ruby vs The World


@arnab_deka
http://arnab-deka.com/

Favorite Language?

 

History


  • 1995: Yukihiro Matsumoto, 'Matz' 
  • 2001: The Pick-Axe book
  • 2004: Ruby on Rails by DHH



Speed???

vs

 


There's always another story... 

 

Pure OO

 1.methods => => [:to_s, :inspect, ...]"a string".class => String

No special syntax

Vehicle.new # not new Vehicle()1 + 2 # => 1.+(2)

Mixins

    • like interfaces, but with implementation
    • better than interfaces (Java)
    • clearer than multiple-inheritence (C++/Python) 

Elegant & Readable

cars.map(&:registration_number).reject(&:empty?).join("\n")
// the map part, in Java:List<String> plates = new ArrayList<String>();
for(Car c: cars) {
    plates.add(c.registrationNumber();
}
sentence.split.reverse.join ' ' # ruby" ".join(reversed(sentence.split())) # python

Principle of Least Astonishment

 File: read, open, exists?, path

Functional

 Array/Hash/any Enumerable:   numbers.all? {|number| number.odd? }   ... none?, any?, none?, one?, include?   each, map, reduce, select/reject, sort/group/count, slice etc.
"It's so consistent that you start being able to guess how things will work, and you're right most of the time. It's beautiful. And fun. And practical."
- Steve Yegge
"My conscience won’t let me call Ruby a computer language. That would imply that the language works primarily on the computer’s terms."
_why 

Powerful Meta-Programming

  • method_missing

xml = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)xml.coder {  xml.name 'Matsumoto', :nickname => 'Matz'  xml.language 'Ruby'}# ⇒ <coder><name nickname="Matz">Matsumoto</name><language>Ruby</language></coder>

  • evals and define_method

# Task: description(string), completed(boolean)Task.find(:one, :conditions => {description: 'Attend #RailsGardenBLR'})Task.find_by_description('Attend #RailsGardenBLR')Task.find_all_by_completed(true)
Task.find_or_create_by_description('Go back happy!')

Meta-Programming Gyaan


The best part: Community

  • MINASWAN
  • ecosystem/open source
  • We have lots of drama too!

The best-est part: Developer Happiness

The goal of Ruby is to make programmers happy. I started out to make a programming language that would make me happy, and as a side effect it’s made many, many programmers happy.
- Matz

Happiness has a cascading effect. Happy programmers do the right thing. They write simple, readable code. They take clean, expressive, readable, elegant approaches. They have fun.
- DHH, 37Signals

Thank you!


Ruby vs the world

By Arnab Deka

Ruby vs the world

  • 3,731