Slide 1

Slide 1 text

@kierangraham @brewbot

Slide 2

Slide 2 text

Why Ruby?

Slide 3

Slide 3 text

Writing code is difficult

Slide 4

Slide 4 text

Errors / Debugging / Despair Read Docs / Stack Overflow Presenting Data Getting Data Your Idea You

Slide 5

Slide 5 text

Errors / Debugging / Despair Read Docs / Stack Overflow Presenting Data Getting Data Your Idea You

Slide 6

Slide 6 text

Errors / Debugging / Despair Read Docs / Stack Overflow Presenting Data Getting Data Your Idea You

Slide 7

Slide 7 text

Errors / Debugging / Despair Read Docs / Stack Overflow Presenting Data Getting Data Your Idea You

Slide 8

Slide 8 text

Errors / Debugging / Despair Read Docs / Stack Overflow Presenting Data Getting Data Your Idea You

Slide 9

Slide 9 text

Writing code is * *Ruby makes it nicer

Slide 10

Slide 10 text

Ruby is expressive What you expect to happen is usually what happens

Slide 11

Slide 11 text

Ruby is readable Reading code like a machine isn’t so nice

Slide 12

Slide 12 text

Ruby is for people There’s plenty of other languages optimised for machines

Slide 13

Slide 13 text

Brewbot.brew! do recipe "Ruby on Ales" do ingredient :water ingredient malts: [ "British Pale Ale Malt", "Crystal Malt", "Munich Malt" ] ! ingredient hops: ["Colombus", "Cascade"] end end !

Slide 14

Slide 14 text

–Someone “But I can already do these things in [x] language, see!”

Slide 15

Slide 15 text

+++++ +++++ initialize counter (cell #0) to 10 [ use loop to set the next four cells to 70/100/30/10 > +++++ ++ add 7 to cell #1 > +++++ +++++ add 10 to cell #2 > +++ add 3 to cell #3 > + add 1 to cell #4 <<<< - decrement counter (cell #0) ] > ++ . print 'H' > + . print 'e' +++++ ++ . print 'l' . print 'l' +++ . print 'o' > ++ . print ' ' << +++++ +++++ +++++ . print 'W' > . print 'o' +++ . print 'r' ----- - . print 'l' ----- --- . print 'd' > + . print '!' > . Hello World!

Slide 16

Slide 16 text

[“Pun

Slide 17

Slide 17 text

Comparing to Objective-C* *This is a totally ridiculous comparison I know

Slide 18

Slide 18 text

beers = ["Rochefort 8", "Carlsberg"] + ["Pliny the Elder", "Harp"] => ["Rochefort", "Carlsberg", "Pliny the Elder", "Harp"] ! nice_beers = beers - ["Carlsberg", "Harp"] => ["Rochefort", "Pliny the Elder”] ! nice_beers = nice_beers + ["The Kernel Pale Ale"] => ["Rochefort", "Pliny the Elder", "The Kernel Pale Ale"] Arrays in Ruby

Slide 19

Slide 19 text

NSMutableArray *beers = [@[@"Rochefort 8", @"Carlsberg", @"Pliny the Elder", @"Harp"] mutableCopy]; => ["Rochefort", "Carlsberg", "Pliny the Elder", “Harp"] ! NSMutableArray *nice_beers = [beers mutableCopy]; [nice_beers removeObjectsInArray:@[@"Carlsberg", @"Harp"]]; => ["Rochefort", "Pliny the Elder"] ! [nice_beers addObject:@"The Kernel Pale Ale"]; => ["Rochefort", "Pliny the Elder", "The Kernel Pale Ale"] Arrays* in Objective-C

Slide 20

Slide 20 text

nice_beers.each do |beer| puts "I like " + beer end ! => I like Rochefort 8 => I like Pliny the Elder => I like The Kernel Pale Ale => ["Rochefort 8", "Pliny the Elder", "The Kernel Pale Ale"] Arrays and Blocks in Ruby

Slide 21

Slide 21 text

[nice_beers enumerateObjectsUsingBlock: ^(NSString *beer, NSUInteger idx, BOOL *stop) { NSLog(@"I like %@", beer); }]; ! => I like Rochefort 8 => I like Pliny the Elder => I like The Kernel Pale Ale Arrays and Blocks in Objective-C

Slide 22

Slide 22 text

Beer.create name: "Ruby on Ales" Saving models using Ruby on Rails

Slide 23

Slide 23 text

NSManagedObjectContext *managedContext = [NSManagedObjectContext new]; Beer *beer = [Beer createInContext:managedContext]; beer.name = @"Ruby on Ales"; NSError *error = nil; [managedContext save:&error]; Saving models in Objective-C using Core Data

Slide 24

Slide 24 text

Quick and Simple Tasks with Ruby Write a script or use irb

Slide 25

Slide 25 text

2.0.0-p353 :002 > 2 + 2 => 4 2.0.0-p353 :003 > [1,2,3,4] + [5,6,7,8] => [1, 2, 3, 4, 5, 6, 7, 8] 2.0.0-p353 :004 > irb - Interactive Ruby Shell

Slide 26

Slide 26 text

Gems 2,620,319,971 downloads of 69,904 gems

Slide 27

Slide 27 text

Community Ruby community holds high quality, well documented, well tested code very dearly

Slide 28

Slide 28 text

How do I setup Ruby?

Slide 29

Slide 29 text

Is your text editor Sublime? Sublime Text is an amazing editor on Mac, Windows and Linux

Slide 30

Slide 30 text

On Mac* (and Linux) *My preferred environment

Slide 31

Slide 31 text

The Terminal iTerm 2 is a replacement for the built-in Terminal.app

Slide 32

Slide 32 text

Your Mac comes preinstalled with Ruby but… …you should avoid it

Slide 33

Slide 33 text

sudo is bad Leave the system alone and get your own Ruby!

Slide 34

Slide 34 text

RVM can help Ruby Version Manager lets you have multiple Rubies installed beside but isolated from each other

Slide 35

Slide 35 text

On Windows* *I don’t really use Windows so your mileage may vary.

Slide 36

Slide 36 text

RubyInstaller rubyinstaller.org

Slide 37

Slide 37 text

Learning Ruby

Slide 38

Slide 38 text

Pick something you already use in [insert language]… …and try porting it to Ruby

Slide 39

Slide 39 text

See what exists already in Ruby How does your port compare?

Slide 40

Slide 40 text

Learn by example; read code What ways are other people writing Ruby?

Slide 41

Slide 41 text

Read about Ruby Read blogs, documentation, tweets

Slide 42

Slide 42 text

Write in Ruby Starting is the hardest part

Slide 43

Slide 43 text

Thanks Enjoy some of the Ruby on Ales beer specially brewed for Belfast Ruby by Brewbot ! @kierangraham @brewbot