SlideShare a Scribd company logo
1 of 42
MAC
RUBY
   Brendan G. Lim
    @brendanlim
brendan@intridea.com
WHO HERE HAS A
   MAC?
WHO HERE HAS
WORKED WITH
OBJECTIVE-C?
DEVELOPED
OSX OR IPHONE APPS?
OBJECTIVE-C
• Object-oriented    extensions to C

• Strongly   typed

• Like   Ruby, influenced by Smalltalk

• Primary    language for Cocoa

• Garbage    collection (2.0)

• 32   and 64-bit support
COCOA

• Set   of object-oriented frameworks

• Used   for writing Max OSX and iPhone OS apps

• Includes    FoundationKit, and AppKit

• Typically   built using tools like XCode and Interface Builder
CORE FOUNDATION
• Low    level libraries that ship with Mac OSX

• Used   for passing primitive types to OSX C routines

• Most   routines follow ‘CF’ naming convention

• Open-Sourced     by Apple as CF-Lite
WHY RUBY INSTEAD
OF OBJECTIVE-C?
RUBY VS OBJECTIVE-C

 object.method(param)
          =

[object method:param];
RUBY VS OBJECTIVE-C

   person.set_name(“john”, “doe”)

                 =

[person setNameWithFirst:@”john”
                withLast:@”doe”];
RUBY VS OBJECTIVE-C

          array = []
              =
    NSMutableArray *array =
[[NSMutableArray alloc] init];
RUBY VS OBJECTIVE-C

             “ string”.strip
                        =
   [@“ string” stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]]
RUBY VS OBJECTIVE-C

      dictionary = {“key1” => “value1”, “key2” => “value2”}



                                        =
NSArray *keys = [NSArray arrayWithObjects:@”key1”,@”key2”];
NSArray *data = [NSArray arrayWithObjects:@”value1”,@”value2”];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
RUBYCOCOA
• Mac   OSX framework

• Bridge   between Objective-C and Ruby

• Can   manipulate Objective-C objects using Ruby

• Write    Cocoa apps in Ruby

• Runs    on Ruby 1.8

• Ships   with OSX Leopard
RUBYCOCOA VS OBJECTIVE-C

setObject_forKey_(iphone, phone)

               =

[setObject:iphone forKey:phone];
SO WHY NOT
RUBYCOCOA?
WHY NOT RUBYCOCOA

• Performance

 • Two     runtimes

 • Two     garbage collectors

 • Object    conversions

• Syntax   doesn’t feel like Ruby
MAC
RUBY


       +
MAC
RUBY
• Impl. of   Ruby 1.9 that runs on the Objective-C runtime

•   Open sourced by Apple

• Originally   created by Laurent Sansonetti

• Replacing    RubyCocoa

• Objects    are peers with no translation layer

• Multi-core   (Grand Central Dispatch)

• HotCocoa      Support
MAC
RUBY
  Object   NSObject
  String   NSMutableString
  Number   NSNumber
  Array    NSMutableArray
  Hash     NSMutableDictionary
MAC
RUBY

       Objects   Objective-C
       Classes   Objective-C
       Methods   Objective-C
MAC
RUBY
>> s = “rubyconf”
=> “rubyconf”

>> s.class
=> NSMutableString

>> s.class.ancestors
=> [NSMutableString,NSString,Comparable,NSObject,Kernel]

>> s.upcase
=> “RUBYCONF”

>> s.uppercaseString
=> “RUBYCONF”
MAC
RUBY
>> NSString.new(“rubyconf”)
=> “rubyconf”

>> NSString.stringWithString(“rubyconf”)
=> “rubyconf”

>> NSString.alloc.initWithString(“rubyconf”)
=> “rubyconf”
MAC
RUBY
>> a = []
=> []

>> a.class
=> NSMutableArray

>> a.class.ancestors
=> [NSMutableArray,NSArray,Enumerable,NSObject,Kernel]

>> a << “RubyConf”
=> [“RubyConf”]
MACRUBY VS OBJECTIVE-C




-(void) locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation {
}
MACRUBY VS OBJECTIVE-C
 def locationManager(manager
       didUpdateToLocation:newLocation
              fromLocation:oldLocation)
 end

-(void) locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation {
}
MACRUBY VS OBJECTIVE-C
def locationManager(manager
      didUpdateToLocation:newLocation
             fromLocation:oldLocation)
end


>> locationManager(manager
     didUpdateToLocation:newLocation,
            fromLocation:oldLocation)
MACRUBY VS OBJECTIVE-C
def locationManager(manager
      didUpdateToLocation:newLocation
             fromLocation:oldLocation)
end


>> locationManager(manager
     :didUpdateToLocation => newLocation,
     :fromLocation => oldLocation)
MACRUBY VS OBJECTIVE-C
                       Interface Builder Outlets


               attr_accessor :my_string

                                  =
# Interface (header file)
NSString *myString;
@property(nonatomic,retain) IBOutlet NSString *myString;
MACRUBY VS OBJECTIVE-C
          Interface Builder Actions

         def my_action(sender)
          ...
         end
                     =
# Interface
-(IBAction) myAction:(id)sender;

# Implementation
-(IBAction) myAction:(id)sender { ... }
WAIT, WHAT ABOUT
MACRUBY FOR IPHONE/IPAD?
MAC
RUBY




       Xcode
MAC
RUBY




       Interface Builder
MAC
RUBY




       Instruments
MAC
RUBY


   Let’s build something ...
TDD IN MACRUBY
• Good      supports for tests

• AnyRuby testing framework instantly becomes an
 Objective-C testing framework

 • Test::Unit

 • RSpec

 • Cucumber

 • etc...
HOTCOCOA

• Use   Ruby to build a UI without Interface Builder

• Developed    by Rich Kilmer

• MacRuby    0.5 now supports HotCocoa

• Packaged   as a gem in MacRuby 0.5
MACRUBY VS HOTCOCOA
win = NSWindow.alloc.initWithContentRect([10,20,300,300],
  :styleMask => (NSTitleWindowMask           |
                 NSCloseableWindowMask       |
                 NSMiniatureizableWindowMask |
                 NSResizeableWindowMask)



                           =

win = window :frame => [10,20,300,300]
HELLO WORLD IN
       HOTCOCOA
require ‘rubygems’
require ‘hotcocoa’
include HotCocoa
application do |app|
 win = window :size => [100,50]
 b = button :title => ‘Hello’
 b.on_action { puts ‘World!’ }
 win << b
end
MAC
RUBY


       Very exciting future
MAC
RUBY


  It’s Ruby for Cocoa Apps!
MAC
RUBY
             Questions?
             http://macruby.org
    http://macruby.org/hotcocoa.html
   http://bit.ly/macruby-getting-started
      http://bit.ly/macruby-examples
          http://bit.ly/tdd-macruby
  http://github.com/masterkain/macruby

More Related Content

What's hot

ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraAllen Wirfs-Brock
 
Umleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB appUmleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB appLenz Gschwendtner
 
Game Development with Corona SDK and Lua - Lua Workshop 2014
Game Development with Corona SDK and Lua - Lua Workshop 2014Game Development with Corona SDK and Lua - Lua Workshop 2014
Game Development with Corona SDK and Lua - Lua Workshop 2014SergeyLerg
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#Bertrand Le Roy
 
Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011hangxin1940
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHiroshi SHIBATA
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronouskang taehun
 
Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)vibrantuser
 
Macruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMacruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMatt Aimonetti
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Insidejeffz
 
Using Ruby on Rails with legacy Oracle databases
Using Ruby on Rails with legacy Oracle databasesUsing Ruby on Rails with legacy Oracle databases
Using Ruby on Rails with legacy Oracle databasesRaimonds Simanovskis
 
Scarlet SmallTalk
Scarlet SmallTalkScarlet SmallTalk
Scarlet SmallTalkESUG
 

What's hot (20)

ECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing EraECMAScript 6: A Better JavaScript for the Ambient Computing Era
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
 
Umleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB appUmleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB app
 
Game Development with Corona SDK and Lua - Lua Workshop 2014
Game Development with Corona SDK and Lua - Lua Workshop 2014Game Development with Corona SDK and Lua - Lua Workshop 2014
Game Development with Corona SDK and Lua - Lua Workshop 2014
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#
 
RubyMotion Introduction
RubyMotion IntroductionRubyMotion Introduction
RubyMotion Introduction
 
Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby Core
 
Extending Node.js using C++
Extending Node.js using C++Extending Node.js using C++
Extending Node.js using C++
 
Rack
RackRack
Rack
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronous
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)
 
Macruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMacruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich Kilmer
 
Map kit light
Map kit lightMap kit light
Map kit light
 
Graphql with Flamingo
Graphql with FlamingoGraphql with Flamingo
Graphql with Flamingo
 
C# Today and Tomorrow
C# Today and TomorrowC# Today and Tomorrow
C# Today and Tomorrow
 
Ruby meetup ROM
Ruby meetup ROMRuby meetup ROM
Ruby meetup ROM
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Inside
 
Using Ruby on Rails with legacy Oracle databases
Using Ruby on Rails with legacy Oracle databasesUsing Ruby on Rails with legacy Oracle databases
Using Ruby on Rails with legacy Oracle databases
 
Scarlet SmallTalk
Scarlet SmallTalkScarlet SmallTalk
Scarlet SmallTalk
 

Similar to Mac ruby to the max - Brendan G. Lim

MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012Mark Villacampa
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deploymentThilo Utke
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleRaimonds Simanovskis
 
RubyMotion
RubyMotionRubyMotion
RubyMotionMark
 
Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets CocoaRobbert
 
GUI Programming with MacRuby
GUI Programming with MacRubyGUI Programming with MacRuby
GUI Programming with MacRubyErik Berlin
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012rivierarb
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
 
Modified "Why MacRuby Matters"
Modified "Why MacRuby Matters"Modified "Why MacRuby Matters"
Modified "Why MacRuby Matters"Sean McCune
 
RubyMotion Introduction
RubyMotion IntroductionRubyMotion Introduction
RubyMotion IntroductionLori Olson
 
Playing With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsPlaying With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsMike Hagedorn
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developergicappa
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes BackBurke Libbey
 

Similar to Mac ruby to the max - Brendan G. Lim (20)

RubyMotion
RubyMotionRubyMotion
RubyMotion
 
MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deployment
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
 
RubyMotion
RubyMotionRubyMotion
RubyMotion
 
Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets Cocoa
 
Why MacRuby Matters
Why MacRuby MattersWhy MacRuby Matters
Why MacRuby Matters
 
Macruby intro
Macruby introMacruby intro
Macruby intro
 
ruby-cocoa
ruby-cocoaruby-cocoa
ruby-cocoa
 
ruby-cocoa
ruby-cocoaruby-cocoa
ruby-cocoa
 
GUI Programming with MacRuby
GUI Programming with MacRubyGUI Programming with MacRuby
GUI Programming with MacRuby
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
Modified "Why MacRuby Matters"
Modified "Why MacRuby Matters"Modified "Why MacRuby Matters"
Modified "Why MacRuby Matters"
 
RubyMotion Introduction
RubyMotion IntroductionRubyMotion Introduction
RubyMotion Introduction
 
Playing With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsPlaying With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.js
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
Nashorn
NashornNashorn
Nashorn
 

More from ThoughtWorks

Online and Publishing casestudies
Online and Publishing casestudiesOnline and Publishing casestudies
Online and Publishing casestudiesThoughtWorks
 
Insurecom Case Study
Insurecom Case StudyInsurecom Case Study
Insurecom Case StudyThoughtWorks
 
Grameen Case Study
Grameen Case StudyGrameen Case Study
Grameen Case StudyThoughtWorks
 
Construction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific LanguagesConstruction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific LanguagesThoughtWorks
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in RubyThoughtWorks
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in RubyThoughtWorks
 
Lets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagiLets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagiThoughtWorks
 
Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
 Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank... Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...ThoughtWorks
 
Nick Sieger-Exploring Rails 3 Through Choices
Nick Sieger-Exploring Rails 3 Through Choices Nick Sieger-Exploring Rails 3 Through Choices
Nick Sieger-Exploring Rails 3 Through Choices ThoughtWorks
 
Present and Future of Programming Languages - ola bini
Present and Future of Programming Languages - ola biniPresent and Future of Programming Languages - ola bini
Present and Future of Programming Languages - ola biniThoughtWorks
 
The ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj KumarThe ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj KumarThoughtWorks
 
Ruby 124C41+ - Matz
Ruby 124C41+  - MatzRuby 124C41+  - Matz
Ruby 124C41+ - MatzThoughtWorks
 
Project Fedena and Why Ruby on Rails - ArvindArvind G S
Project Fedena and Why Ruby on Rails - ArvindArvind G SProject Fedena and Why Ruby on Rails - ArvindArvind G S
Project Fedena and Why Ruby on Rails - ArvindArvind G SThoughtWorks
 
Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta ThoughtWorks
 
Aman kingrubyoo pnew
Aman kingrubyoo pnew Aman kingrubyoo pnew
Aman kingrubyoo pnew ThoughtWorks
 
HadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkHadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkThoughtWorks
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone DevelopmentThoughtWorks
 
DSL Construction rith Ruby
DSL Construction rith RubyDSL Construction rith Ruby
DSL Construction rith RubyThoughtWorks
 

More from ThoughtWorks (20)

Online and Publishing casestudies
Online and Publishing casestudiesOnline and Publishing casestudies
Online and Publishing casestudies
 
Insurecom Case Study
Insurecom Case StudyInsurecom Case Study
Insurecom Case Study
 
Grameen Case Study
Grameen Case StudyGrameen Case Study
Grameen Case Study
 
BFSI Case Sudies
BFSI Case SudiesBFSI Case Sudies
BFSI Case Sudies
 
Construction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific LanguagesConstruction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific Languages
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in Ruby
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in Ruby
 
Lets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagiLets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagi
 
Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
 Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank... Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
 
Nick Sieger-Exploring Rails 3 Through Choices
Nick Sieger-Exploring Rails 3 Through Choices Nick Sieger-Exploring Rails 3 Through Choices
Nick Sieger-Exploring Rails 3 Through Choices
 
Present and Future of Programming Languages - ola bini
Present and Future of Programming Languages - ola biniPresent and Future of Programming Languages - ola bini
Present and Future of Programming Languages - ola bini
 
The ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj KumarThe ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj Kumar
 
Ruby 124C41+ - Matz
Ruby 124C41+  - MatzRuby 124C41+  - Matz
Ruby 124C41+ - Matz
 
Project Fedena and Why Ruby on Rails - ArvindArvind G S
Project Fedena and Why Ruby on Rails - ArvindArvind G SProject Fedena and Why Ruby on Rails - ArvindArvind G S
Project Fedena and Why Ruby on Rails - ArvindArvind G S
 
Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta
 
Aman kingrubyoo pnew
Aman kingrubyoo pnew Aman kingrubyoo pnew
Aman kingrubyoo pnew
 
HadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkHadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software Framework
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone Development
 
DSL Construction rith Ruby
DSL Construction rith RubyDSL Construction rith Ruby
DSL Construction rith Ruby
 
Cloud Computing
Cloud  ComputingCloud  Computing
Cloud Computing
 

Recently uploaded

The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

Mac ruby to the max - Brendan G. Lim

  • 1. MAC RUBY Brendan G. Lim @brendanlim brendan@intridea.com
  • 2. WHO HERE HAS A MAC?
  • 3. WHO HERE HAS WORKED WITH OBJECTIVE-C?
  • 5. OBJECTIVE-C • Object-oriented extensions to C • Strongly typed • Like Ruby, influenced by Smalltalk • Primary language for Cocoa • Garbage collection (2.0) • 32 and 64-bit support
  • 6. COCOA • Set of object-oriented frameworks • Used for writing Max OSX and iPhone OS apps • Includes FoundationKit, and AppKit • Typically built using tools like XCode and Interface Builder
  • 7. CORE FOUNDATION • Low level libraries that ship with Mac OSX • Used for passing primitive types to OSX C routines • Most routines follow ‘CF’ naming convention • Open-Sourced by Apple as CF-Lite
  • 8. WHY RUBY INSTEAD OF OBJECTIVE-C?
  • 9. RUBY VS OBJECTIVE-C object.method(param) = [object method:param];
  • 10. RUBY VS OBJECTIVE-C person.set_name(“john”, “doe”) = [person setNameWithFirst:@”john” withLast:@”doe”];
  • 11. RUBY VS OBJECTIVE-C array = [] = NSMutableArray *array = [[NSMutableArray alloc] init];
  • 12. RUBY VS OBJECTIVE-C “ string”.strip = [@“ string” stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]
  • 13. RUBY VS OBJECTIVE-C dictionary = {“key1” => “value1”, “key2” => “value2”} = NSArray *keys = [NSArray arrayWithObjects:@”key1”,@”key2”]; NSArray *data = [NSArray arrayWithObjects:@”value1”,@”value2”]; NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
  • 14. RUBYCOCOA • Mac OSX framework • Bridge between Objective-C and Ruby • Can manipulate Objective-C objects using Ruby • Write Cocoa apps in Ruby • Runs on Ruby 1.8 • Ships with OSX Leopard
  • 15. RUBYCOCOA VS OBJECTIVE-C setObject_forKey_(iphone, phone) = [setObject:iphone forKey:phone];
  • 17. WHY NOT RUBYCOCOA • Performance • Two runtimes • Two garbage collectors • Object conversions • Syntax doesn’t feel like Ruby
  • 18. MAC RUBY +
  • 19. MAC RUBY • Impl. of Ruby 1.9 that runs on the Objective-C runtime • Open sourced by Apple • Originally created by Laurent Sansonetti • Replacing RubyCocoa • Objects are peers with no translation layer • Multi-core (Grand Central Dispatch) • HotCocoa Support
  • 20. MAC RUBY Object NSObject String NSMutableString Number NSNumber Array NSMutableArray Hash NSMutableDictionary
  • 21. MAC RUBY Objects Objective-C Classes Objective-C Methods Objective-C
  • 22. MAC RUBY >> s = “rubyconf” => “rubyconf” >> s.class => NSMutableString >> s.class.ancestors => [NSMutableString,NSString,Comparable,NSObject,Kernel] >> s.upcase => “RUBYCONF” >> s.uppercaseString => “RUBYCONF”
  • 23. MAC RUBY >> NSString.new(“rubyconf”) => “rubyconf” >> NSString.stringWithString(“rubyconf”) => “rubyconf” >> NSString.alloc.initWithString(“rubyconf”) => “rubyconf”
  • 24. MAC RUBY >> a = [] => [] >> a.class => NSMutableArray >> a.class.ancestors => [NSMutableArray,NSArray,Enumerable,NSObject,Kernel] >> a << “RubyConf” => [“RubyConf”]
  • 25. MACRUBY VS OBJECTIVE-C -(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { }
  • 26. MACRUBY VS OBJECTIVE-C def locationManager(manager didUpdateToLocation:newLocation fromLocation:oldLocation) end -(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { }
  • 27. MACRUBY VS OBJECTIVE-C def locationManager(manager didUpdateToLocation:newLocation fromLocation:oldLocation) end >> locationManager(manager didUpdateToLocation:newLocation, fromLocation:oldLocation)
  • 28. MACRUBY VS OBJECTIVE-C def locationManager(manager didUpdateToLocation:newLocation fromLocation:oldLocation) end >> locationManager(manager :didUpdateToLocation => newLocation, :fromLocation => oldLocation)
  • 29. MACRUBY VS OBJECTIVE-C Interface Builder Outlets attr_accessor :my_string = # Interface (header file) NSString *myString; @property(nonatomic,retain) IBOutlet NSString *myString;
  • 30. MACRUBY VS OBJECTIVE-C Interface Builder Actions def my_action(sender) ... end = # Interface -(IBAction) myAction:(id)sender; # Implementation -(IBAction) myAction:(id)sender { ... }
  • 31. WAIT, WHAT ABOUT MACRUBY FOR IPHONE/IPAD?
  • 32. MAC RUBY Xcode
  • 33. MAC RUBY Interface Builder
  • 34. MAC RUBY Instruments
  • 35. MAC RUBY Let’s build something ...
  • 36. TDD IN MACRUBY • Good supports for tests • AnyRuby testing framework instantly becomes an Objective-C testing framework • Test::Unit • RSpec • Cucumber • etc...
  • 37. HOTCOCOA • Use Ruby to build a UI without Interface Builder • Developed by Rich Kilmer • MacRuby 0.5 now supports HotCocoa • Packaged as a gem in MacRuby 0.5
  • 38. MACRUBY VS HOTCOCOA win = NSWindow.alloc.initWithContentRect([10,20,300,300], :styleMask => (NSTitleWindowMask | NSCloseableWindowMask | NSMiniatureizableWindowMask | NSResizeableWindowMask) = win = window :frame => [10,20,300,300]
  • 39. HELLO WORLD IN HOTCOCOA require ‘rubygems’ require ‘hotcocoa’ include HotCocoa application do |app| win = window :size => [100,50] b = button :title => ‘Hello’ b.on_action { puts ‘World!’ } win << b end
  • 40. MAC RUBY Very exciting future
  • 41. MAC RUBY It’s Ruby for Cocoa Apps!
  • 42. MAC RUBY Questions? http://macruby.org http://macruby.org/hotcocoa.html http://bit.ly/macruby-getting-started http://bit.ly/macruby-examples http://bit.ly/tdd-macruby http://github.com/masterkain/macruby

Editor's Notes

  1. - Objective-C is the primary language for Cocoa development. If you&amp;#x2019;ve ventured into Mac OSX, iPhone or iPad development you&amp;#x2019;ve been faced with the decision to learn Objective-C. - Objective-C is essentially object oriented extensions to the C language - It&amp;#x2019;s a strongly typed language and is influenced by Smalltalk like Ruby -- Objective-C also has Smalltalk-like messaging - There&amp;#x2019;s garbage collection in Objective-C 2.0 and also there&amp;#x2019;s also 32-bit and 64-bit support
  2. - Cocoa is a set of object-oriented frameworks used to create Max OSX and iPhone OS applications. - It includes two major frameworks, Foundation and AppKit. - AppKit contains all the objects you need to implement your graphical user interface. - Foundation includes a base layer of classes that can be used for any type of Cocoa app. - Cocoa apps are typically developed using Xcode and Interface builder using Objective-C.
  3. - Core Foundation is included in Foundation Kit and is a C API that is a mix of low-level routines and wrapper functions - The most important use of Core Foundation is for passing its own primitive types to numerous GUI related C routines - You can recognize a Core Foundation function because the naming almost always starts with CF. Some popular ones are CFRetain and CFRelease for memory management. - Most of Core Foundation was actually open sourced by Apple as a project called CF-Lite
  4. - So what&amp;#x2019;s the big deal with Objective-C anyway? - Why would we want to use Ruby instead of Objective-C?
  5. I&amp;#x2019;m going to go through some differences between Ruby and Objective C. In the following slides, the lines colored in red is ruby code and blue is Objective-C. Here&amp;#x2019;s one of the most basic examples I can show. - Here you can see how we pass a parameter to a method in ruby and in Objective-C. - Also, if you&amp;#x2019;re wondering what the square braces are, they are for binding a message to an object in Objective-C. - Not that bad but it gets more complicated.
  6. - In Objective-C the colon separates names and arguments. - It looks like a hash, but it&amp;#x2019;s not and the order for which arguments are passed in matters. - Also it&amp;#x2019;s good to note that most arguments are identified by name and the first argument is usually included in or attached to the method name.
  7. WIthin Objective-C this is how we would create a new array. We are allocating a NSMutableArray then we are initializing it. Here we&amp;#x2019;re starting to see how much more typing we&amp;#x2019;re going to have to do to accomplish the same thing in Objective-C.
  8. - In this example you can really see how much more we have to do to just strip the white space from a string.
  9. - So, above is how we would create a hash in Ruby and below is how you would have to do, the exact same thing that we can accomplish in one line, in Objective-C. - Wouldn&amp;#x2019;t it be great if we could use Ruby instead of doing all of this? - Unless you really really like typing, I don&amp;#x2019;t see how Objective-C could seem more appealing at this point.
  10. - So, this brings us to, RubyCocoa.
  11. - So that brings us now to RubyCocoa - RubyCocoa is a MacOSX framework - It&amp;#x2019;s a bridge between Objective-C and Ruby and it can manipulate Objective-C objects using Ruby - It runs on Ruby 1.8 and it allows you to simply write Cocoa apps in Ruby. - Also, it ships standard with OSX Leopard, so if you have Leopard or Snow Leopard on your Mac, you&amp;#x2019;ve got RubyCocoa.
  12. - So, this is a comparison between RubyCocoa and Objective-C. - This example shows the setObject forKey function in Objective-C. - On top you can see the RubyCocoa implementation, which is more ruby like but we are oddly mixing camelcase with underscores.
  13. - So why not RubyCocoa? - If we&amp;#x2019;ve already got something that allows us to use Ruby to make Cocoa applications, then why should I use MacRuby?
  14. - Since RubyCocoa is a bridge between Obj-C and Ruby, that means that performance is obviously going to be sacrificed. - There are also two runtimes and two garbage collectors. - Also, there&amp;#x2019;s expensive object conversions. - For example, the first time you access the NSTableView class, RubyCocoa will retrieve all of the necessary info regarding this class and will create a Ruby class of the same name to act as a proxy on demand.
  15. - So, this is where MacRuby comes in. - MacRuby is set to be the replacement for RubyCocoa. - So if you&amp;#x2019;re not too much of a fan of Objective-C then you&amp;#x2019;re going to like MacRuby.
  16. If you aren&amp;#x2019;t much of an Objective-C fan you&amp;#x2019;re going to be really happy with MacRuby.
  17. - MacRuby is Ruby 1.9 ported to run on top of Objective-C runtime. So all classes, methods, and objects are all objective-c. They accomplished this by taking advantage of CoreFoundation. This gives you things like native threads, obj-c&amp;#x2019;s garbage collector, and much more. - Project originally started by Laurent Sansonetti of Apple, who also helped out with RubyCocoa - Unlike RubyCocoa, there&amp;#x2019;s no bridge or translation layer. That means little to no performance penalties. This also means that Ruby objects map to Objective-C objects without any extra work from you. - Since MacRuby 0.5&amp;#x2019;s release, they&amp;#x2019;ve supported Apple&amp;#x2019;s Grand Central Dispatch Library to support multi-core processors. - MacRuby is supposed to be Apple&amp;#x2019;s replacement for RubyCocoa. - Also, MacRuby 0.5 now has HotCocoa support, which I&amp;#x2019;ll briefly talk about later.
  18. Originally, Macruby was called &amp;#x201C;Ruby+Objc&amp;#x201D; and was developed by Laurent Sansonetti. He started working on it in 2007. In March 2008 the first public version of MacRuby was released. In September of 2008 0.3 was released, which included the HotCocoa library, which allows you to develop interfaces using ruby. In March of this year MacRuby 0.4 was released.
  19. - In MacRuby, Ruby types are nicely backed by foundation equivalents in Objective-C. - Here you can see the foundation counterparts of these Ruby classes.
  20. - Going further, what we need to realize here is that all objects are objective-c objects, all classes are objective-c classes and all methods defined in a Ruby class are registered with the Objective-C runtime. - There were able to do this because of Core Foundation, which I mentioned before, which defines all of the primitive data types.
  21. - Instead of using IRB you use MACIRB, which acts and performs the same way as IRB but for MacRuby. - So what I&amp;#x2019;m trying to show you here is that you use MacRuby the same way you would use traditional ruby. - All the Ruby types are backed by Foundation equivalents. Here you can see that instead of just a regular Ruby String object being shown, we get back an NSMutableString. Ruby classes like String are now just aliases to their Foundation counterparts. - Also, it&amp;#x2019;s because of this that we can still call the ruby string method &amp;#x201C;upcase&amp;#x201D; and call the NSMutableString method uppercaseString.
  22. - So it&amp;#x2019;s also good to note that you can build objects by directly calling the Objective-C interface. - Here you can see us creating a new string by calling NSString.new, stringWithString, and allocating and initializing with a string.
  23. - Here you can see us easily creating an array just how we&amp;#x2019;re used to. - Also you scan ee that we get back an NSMutableArray instead of just a Ruby array. - The Array class descends from Ruby and Cocoa objects as well.
  24. - This is an example that shows you what the method definition looks like in objective-c. - If you&amp;#x2019;re familiar with iPhone development, this is one of the callback methods of CoreLocation. - We can see here that the data types for each of the arguments that we need to pass in.
  25. - The MacRuby version of this example is shown above. - It&amp;#x2019;s pretty close except that we removed the data types for each argument and it now looks more like idiomatic ruby with named arguments.
  26. - If you were to try and call this method from MacRuby you could do the following with the named arguments and variables.
  27. - Also, you can even call this method using key-value hash pairs, which could feel much more natural to you. - And remember that even though it looks like a hash, you have to make sure that the ordering stays the same.
  28. - Interface Builder Outlets are essentially instance variables that refer to other objects. - When building graphical interfaces with our MacRuby application we need to be able to access our instance variables in Interface Builder so that we can make connections between our controller and our view. - We can do this by using attr_reader, attr_writer, or attr_accessor in MacRuby. In Objective-C we have to do the following below in red to create an IBOutlet in the header file.
  29. - Interface Builder Actions are methods that we want to be called when a user performs a certain action on an object we specify within Interface Builder. Most commonly this would be a button that you could click on. - Also, by convention it is mandatory to have one parameter for these actions, which is noted above as sender. Sender specified in the method above would be the button that is clicked. - Without this sender parameter, Interface Builder will not register this action.
  30. - After talking about all of the awesomeness of MacRuby some of you are probably wondering if you could ditch Objective-C and just write iPhone or iPad apps using MacRuby. - Sadly, you can&amp;#x2019;t yet. Apple doesn&amp;#x2019;t allow interpreted code and doesn&amp;#x2019;t support garbage collection for the iPhone OS. - Hopefully this will change but right now you&amp;#x2019;re going to have to stick with Objective-C. You could though, use tools like Appcelerator Titanium to create native apps using JavaScript. - If you&amp;#x2019;re interested in hearing about that please come see me after this talk - I&amp;#x2019;d love to talk about it.
  31. - With MacRuby development you&amp;#x2019;ll spend a good chunk of time in XCode. - XCode is an IDE and I&amp;#x2019;m not sure how many people here use it but if you&amp;#x2019;re uncomfortable with it, you can still use your favorite text editor to work on your ruby files but you&amp;#x2019;ll have to come back to XCode to compile your application and run your application. - Xcode isn&amp;#x2019;t installed by default but it comes on that second disk you get with OSX and it&amp;#x2019;s also available for free online.
  32. - You&amp;#x2019;ll also spend a good chunk of your time using Interface Builder, which is part of Xcode. - Interface builder allows for you to build the interfaces for your cocoa or macruby applications using a graphical user interface. - The files you work on are called NIB files which are our views.
  33. - Also, with XCode you get great tools like Instruments. - Instruments allows you to profile your app, check for leaks, memory usage, cpu usage, see how many objects you create, and much more. - You get all of this when using MacRuby.
  34. - What&amp;#x2019;s great about MacRuby is that it&amp;#x2019;s also got good support for testing - Any Ruby testing framework that you&amp;#x2019;d normally use can be used with MacRuby.
  35. - So, the last thing I wanted to talk about was HotCocoa. - HotCocoa was developed by Rich Kilmer and it&amp;#x2019;s a thin Ruby layer that sits on top of Cocoa and other frameworks. - It was designed to simplify the way you can create user interfaces without using Interface Builder. - MacRuby 0.5 now supports HotCocoa and it&amp;#x2019;s included in MacRuby.
  36. - Even though MacRuby allows us to write Cocoa apps using Ruby, if we want to programmatically create our interface we still have to implement the same Objective-C methods to create our UI and that can look a little nasty. - Below you can see how much nicer it is to do this using HotCocoa.
  37. - This is how simple it is to use HotCocoa to programmatically construct your cocoa application. - What this does is create a window 100 pixels wide and 50 pixels tall and adds a button with the title &amp;#x2018;Hello&amp;#x2019;. Once you click this button it will spit out &amp;#x2018;World!&amp;#x2019; to your console.
  38. - Well, so MacRuby has a very exciting future ahead. - The current release is only at version 0.5 so there&amp;#x2019;s so much more that will surprise us before 1.0 is released. - Also, with Apple&amp;#x2019;s backing, soon everybody could be using Ruby to develop their Cocoa Desktop apps -- also possibly even for the iPhone and the iPad.
  39. - And simply, it just allows you to use Ruby to develop Cocoa applications. How cool is that?
  40. - MacRuby 0.5 is built upon the low level virtual machine (LLVM) in 0.5 but they used to use YARV - Switched from YARV to LLVM due to YARV&amp;#x2019;s lack of machine code compilation and the global interpreter lock, which prevented true concurrency. - MacRuby supports Just In Time and Ahead of Time compilation - AOT compilation makes MacRuby a true Ruby compiler