Ievgenii Narovlianskyi - Ruby is not just a gem

Preview:

Citation preview

RUBY IS NOT JUST A GEM

Ruby is also an awesome programming language. It is a good choice for those who like and follow the KISS principle.

IN THIS PRESENTATION:➤ Short language history➤ Ruby’s flow➤ Some code examples➤ Ruby’s community➤ Few words about nowadays problems of complex

systems development & how Ruby ships us in solving them

➤ Your questions and my answers

MEET THE LIFE STORY (SHORT RUBY’S

HISTORY NOTES)21 years old

BIRTH1993

Matz (Yukihiro Matsumoto) wanted a language perfect for his needs:

➤ Syntactically Simple➤ Truly Object-Oriented➤ Having Iterators and Closures➤ Exception Handling➤ Garbage Collection➤ Portable

TODDLER YEARS

December, 1996

➤ Ruby 1.0 was released➤ Ruby 1.1 shortly followed in August

of 1997➤ The first stable version of Ruby

(1.2) was released in December of 1998.

PRIMARY SCHOOL YEARS

1998-2004

➤ In 1998, Matz created a simple English homepage for Ruby - ‘Ruby-Talk’. Ruby was beginning to spread beyond Japan.

➤ In October of 1999: the first book on the Ruby programming language «The Object-oriented Scripting Language Ruby» by Yukihiro Matsumoto and Keiju Ishitsuka.

➤ In 2001, the first English book on Ruby, Programming Ruby (“The Pickaxe”), was published.

➤ Ruby 1.8 was released in 2003. This release made large amounts of changes to the agile 10-year-old language.

➤ In 2004, RubyGems was released to the public.

THE REBELLIOUS TEENAGER

2005-2012

➤ 2005: Ruby on Rails (RoR)➤ In March of 2007, Ruby 1.8.6 was

released➤ December, 2007: Ruby 1.9➤ 2011: Ruby 1.9.3 (stable)

STRONG ADULT

2013-nowadays

➤ February 2013: Ruby 2.0.0 was released➤ Christmas day of 2013: Ruby 2.1.0 was released➤ Ruby’s 21st birthday (February 24, 2014): Ruby

2.1.1 was released. Ruby is now legally allowed to drink in the US. (Speed improvements and bugfixes).

➤ May of 2014: Ruby 2.1.2 was released (more bugfixes and is the current stable version of Ruby).

FUTUREMatz wanted a programming language that suited his needs, so he built one. (If you can’t find something that you like, program it yourself).From 0.95 to 2.1.2, Ruby has struck the awe of those who wished to program the way they wanted, not the way the machine wanted.We can’t know the future of the Ruby language, but we can predict it based on the past. I believe that the Ruby language, and its fantastic community will continue furthering the language above and beyond what others think is possible, and projects built using it will do the same.

RUBY’S FLOW

Ruby code Ruby interpreter

jRuby

MRI

PEACES OF CODE

puts ’’Hello, World!’’

1. Hello world

=> Hello, World!

a = 10puts ’’now ’a’ is equal to: #{a}’’

2. String interpolation

=> now ’a’ is equal to 10

array = [1, "a", [2, :b]]array.first=> 1array.select {|e| [String, Array].include?(e) }=> ["a", [2, :b]]array.map &:to_s=> ["1", "a", "[2, :b]"]

2. Play with Arrays

hash = {field: "2", key: [3, "4"]}hash[:key]=> "2"hash.keys=> [:field, :key]hash.flatten=> [:field, "2", :key, [3, "4"]]other_hash = {field: 3, other_key: "c"}hash.merge other_hash=> {:field=>3, :key=>[3, "4"], :other_key=>"c"}

2. Play with Hashes

class Fruit attr_reader :weight, :eaten

def initialize(weight) @weight = weight @eaten = false end

def eat if @eaten raise "This #{class}" was already eaten" end @eaten = true endend

3. Some OOPclass Apple < Fruit attr_reader :cultivar

def initialize(weight, cultivar) super(weight) @cultivar = cultivar end

def eat super @weight = @weight * 0.1 endend

test_apple = Apple.new(300, "Rannet")test_apple.weight=> 300test_apple.cultivar=> «Rannet»test_apple.eaten=> falsetest_apple.eat=> truetest_apple.weight=> 30test_apple.eat=> RuntimeError: This Apple was already eaten

RUBY’S COMMUNITY

➤ Ruby groups: rubyusergroups.org➤ Ruby mailing (Ruby-Talk, Ruby-Core, Ruby-Doc, Ruby-CVS)➤ Ruby IRC (irc://irc.freenode.net/ruby)➤ Blogs (O’Reilly Ruby, Riding Rails, Ruby Inside, Matz’

Blog)➤ Contribute to Ruby Core (https://github.com/ruby/ruby)➤ Conferentions (RubyConf, RubyKaigi, …)

NOWADAYS DEVELOPMENT PROBLEMS

COMPLEXITY

USERS COUNT

TIME, DEV RESOURCES

SUPPORT, COMPUTING RESOURCES, DATA STORAGE

Recommended