SlideShare une entreprise Scribd logo
1  sur  43
Télécharger pour lire hors ligne
Developing Cocoa
                      Applications With

                       MacRuby
                             Brendan G. Lim
                                 @brendanlim
                             brendan@intridea.com


Saturday, February 5, 2011
Outline
                             •   Objective-C & Cocoa
                             •   RubyCocoa
                             •   MacRuby
                             •   Live Coding
                             •   HotCocoa




Saturday, February 5, 2011
Objective -C
                             •   Object-oriented extensions to C
                             •   Strongly typed
                             •   Like Ruby, influenced by Smalltalk
                             •   Primarily used for Mac OS X and iOS




Saturday, February 5, 2011
Cocoa
                    •   High-level API for Mac OS X

                    •   Set of frameworks

                    •   Includes FoundationKit, AppKit, etc.

                    •   Apps typically built using tools like XCode
                        and Interface Builder




Saturday, February 5, 2011
Why make desktop apps?




Saturday, February 5, 2011
Different Paradigm




Saturday, February 5, 2011
Mac App Store


                                  1. Build MacRuby application
                                  2. Submit to App Store
                                  4. Profit




Saturday, February 5, 2011
Why Ruby instead
                              of Objective-C?



Saturday, February 5, 2011
Apple Loves Ruby

                             2002   Mac OS X 10.2           Ruby 1.6.7

                             2005   Mac OS X 10.4           Ruby 1.8.2

                             2007   Mac OS X 10.5          Ruby 1.8.6
                                                        RubyCocoa, RubyGems, Rails


                             2009   Mac OS X 10.6           Ruby 1.8.7
                                                        RubyCocoa, RubyGems, Rails


                             2011   Mac OS X 10.7          Ruby 1.9.x?
                                                    MacRuby? RubyCocoa, RubyGems, Rails




Saturday, February 5, 2011
Ruby vs Objective-C

                              object.method(param)
                                       =

                             [object method:param];




Saturday, February 5, 2011
Ruby vs Objective-C

                              array = []
                                  =
               NSMutableArray *array =
            [[NSMutableArray alloc] init];



Saturday, February 5, 2011
Ruby vs Objective-C

                             “ string”.strip
                                    =
       [@“ string” stringByTrimmingCharactersInSet:
    [NSCharacterSet whitespaceAndNewlineCharacterSet]]




Saturday, February 5, 2011
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];




Saturday, February 5, 2011
+




Saturday, February 5, 2011
RubyCocoa
                •   Bridge between Objective-C and Ruby

                •   Manipulate Objective-C objects using Ruby

                •   Write Cocoa apps in Ruby

                •   Runs on Ruby 1.8

                •   Ships with OSX Leopard



Saturday, February 5, 2011
RubyCocoa vs Objective-C
   OSX::NSNotificationCenter.defaultCenter.addObserver_selector_name_object(
     self,
      :window_moved,
      "NSWindowDidMoveNotification",
      nil
   )

                                      =
   [[NSNotificationCenter defaultCenter] addObserver:self,
     selector:@selector(windowMoved:)
     name:”NSWindowDidMoveNotification”
     object:nil];




Saturday, February 5, 2011
So, Why Not
                             RubyCocoa?
                             (besides it looking gross)




Saturday, February 5, 2011
Why Not RubyCocoa?
                             •   It’s a bridge!

                                 •   Two runtimes, GCs, etc.

                                 •   Object conversions

                             •   Syntax doesn’t feel like idiomatic Ruby

                             •   It’s getting replaced



Saturday, February 5, 2011
+




Saturday, February 5, 2011
MacRuby

              •   Implementation of Ruby 1.9 that runs on top
                  the Objective-C runtime

              •   Open sourced and supported by Apple

              •   Replacing RubyCocoa

              •   Objects are peers with no translation layer



Saturday, February 5, 2011
MacRuby
                             Object     NSObject
                             String     NSMutableString
                             Number     NSNumber
                             Array      NSMutableArray
                             Hash       NSMutableDictionary




Saturday, February 5, 2011
MacRuby

                             Objects   Objective-C
                             Classes   Objective-C
                             Methods   Objective-C




Saturday, February 5, 2011
MacRuby
     >> s = “magicruby”
     => “magicruby”

     >> s.class
     => String

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

     >> s.upcase
     => “MAGICRUBY”

     >> s.uppercaseString
     => “MAGICRUBY”




Saturday, February 5, 2011
MacRuby

     >> NSString.new(“magicruby”)
     => “magicruby”

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

     >> NSString.alloc.initWithString(“magicruby”)
     => “magicruby”




Saturday, February 5, 2011
MacRuby
     >> a = []
     => []

     >> a.class
     => Array

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

     >> a << “MagicRuby”
     => [“MagicRuby”]




Saturday, February 5, 2011
MacRuby vs Objective-C
      -(id)       tableView:(NSTableView *)tableView
       objectValueForColumn:(NSTableColumn *)column
                        row:(int)rowIndex { .. }




Saturday, February 5, 2011
MacRuby vs Objective-C
      -(id)       tableView:(NSTableView *)tableView
       objectValueForColumn:(NSTableColumn *)column
                        row:(int)rowIndex { .. }




         def tableView(tableView
               objectValueForColumn:column
               row:rowIndex)
         end



Saturday, February 5, 2011
MacRuby vs Objective-C
                             Interface Builder Outlets & Actions




                                                                   !




Saturday, February 5, 2011
MacRuby vs Objective-C
                                Interface Builder Outlets

         # Interface
         NSString *myString;
         @property(nonatomic,retain) IBOutlet NSString *myString;


                                           =

                             attr_accessor :myString




Saturday, February 5, 2011
MacRuby vs Objective-C
                              Interface Builder Actions

             # Implementation
             -(IBAction) myAction:(id)sender { ... }


                                         =

                             def myAction(sender)
                              ...
                             end


Saturday, February 5, 2011
MacRuby - Gem Support

                             •   sudo macgem install awesome_gem

                             •   Not all gems supported right now




Saturday, February 5, 2011
MacRuby - Objective-C
                      Frameworks & Libraries

              •   Libraries must have garbage collection support

              •   Libraries must be turned into bundles

              •   Frameworks can easily be included




Saturday, February 5, 2011
Testing MacRuby

                 •   Any Ruby testing framework instantly becomes
                     an Objective-C testing framework

                     •   Test::Unit

                     •   RSpec

                     •   etc...



Saturday, February 5, 2011
What tools will we
                                be using?



Saturday, February 5, 2011
Xcode



Saturday, February 5, 2011
Interface Builder



Saturday, February 5, 2011
Instruments

Saturday, February 5, 2011
Let’s build a MacRuby app




Saturday, February 5, 2011
HotCocoa

               •    Created by Rich Kilmer

               •    Ruby layer that sits on top of Cocoa, etc.

               •    Use Ruby to easily create user interfaces

               •    Used to be included with MacRuby

               •    Now available as a gem



Saturday, February 5, 2011
HotCocoa
                win = NSWindow.alloc.initWithContentRect([10,20,300,300],
                   styleMask: (NSTitleWindowMask           |
                               NSCloseableWindowMask       |
                               NSMiniatureizableWindowMask |
                               NSResizeableWindowMask)



                                           =

                win = window :frame => [10,20,300,300]




Saturday, February 5, 2011
HotCocoa

                             sudo macgem install hotcocoa

                               hotcocoa NAME_OF_APP




Saturday, February 5, 2011
Hello World in HotCocoa
    require ‘hotcocoa’

    class Application
      include HotCocoa

      def start
        application :name => "Hello" do |app|
          app.delegate = self
          window :frame => [500,500,200,100], :title => "Hello" do |win|
            win << label(:text => "Hello World",:layout => {:start => false})
            win.will_close { exit }
          end
        end
      end
    end

    Application.new.start



Saturday, February 5, 2011
Questions?

                                         MacRuby in Action
                                         http://manning.com/lim




                                       http://macruby.org
                             http://bit.ly/macruby-getting-started
                                http://bit.ly/macruby-examples
                                   http://bit.ly/tdd-macruby
Saturday, February 5, 2011

Contenu connexe

En vedette

New  Forodhani ( Jubilee Garden ) Being Rebuilt
New  Forodhani ( Jubilee Garden ) Being RebuiltNew  Forodhani ( Jubilee Garden ) Being Rebuilt
New  Forodhani ( Jubilee Garden ) Being RebuiltHeena Modi
 
Bio - Jean Fares Couture
Bio - Jean Fares CoutureBio - Jean Fares Couture
Bio - Jean Fares CoutureNorma HAYEK
 
Mahatma Gandhi
Mahatma GandhiMahatma Gandhi
Mahatma GandhiHeena Modi
 
Vegetarian vision
Vegetarian visionVegetarian vision
Vegetarian visionHeena Modi
 
Transcript - Facebook Marketing Success Summit Ads Presentation 2011
Transcript - Facebook Marketing Success Summit Ads Presentation 2011Transcript - Facebook Marketing Success Summit Ads Presentation 2011
Transcript - Facebook Marketing Success Summit Ads Presentation 2011Chris Treadaway
 
Schloss mirabell
Schloss mirabellSchloss mirabell
Schloss mirabellHeena Modi
 
The broiler hen
The broiler hen The broiler hen
The broiler hen Heena Modi
 
Porting the QALL-ME framework to Romanian
Porting the QALL-ME framework to RomanianPorting the QALL-ME framework to Romanian
Porting the QALL-ME framework to RomanianConstantin Orasan
 
ExL Pharma Clinical Trials Phase I and Phase IIa Conference Brochure: Phase 1...
ExL Pharma Clinical Trials Phase I and Phase IIa Conference Brochure: Phase 1...ExL Pharma Clinical Trials Phase I and Phase IIa Conference Brochure: Phase 1...
ExL Pharma Clinical Trials Phase I and Phase IIa Conference Brochure: Phase 1...bryonmain
 
Milieu Problematiek
Milieu ProblematiekMilieu Problematiek
Milieu ProblematiekT_COOLS
 
Facebook Marketing Success Summit Presentation 2011 - Success with Facebook Ads
Facebook Marketing Success Summit Presentation 2011 - Success with Facebook AdsFacebook Marketing Success Summit Presentation 2011 - Success with Facebook Ads
Facebook Marketing Success Summit Presentation 2011 - Success with Facebook AdsChris Treadaway
 
EuP Directive About Non Directional Domestic Lighting
EuP Directive About Non Directional Domestic LightingEuP Directive About Non Directional Domestic Lighting
EuP Directive About Non Directional Domestic LightingHeena Modi
 
July 10th 2014 - to use with members from multiple Unions
July 10th 2014 - to use with members from multiple UnionsJuly 10th 2014 - to use with members from multiple Unions
July 10th 2014 - to use with members from multiple UnionsHeena Modi
 
Woman De John Lennon
Woman De John LennonWoman De John Lennon
Woman De John LennonMISANTLA
 

En vedette (20)

Kansas sights
Kansas sightsKansas sights
Kansas sights
 
New  Forodhani ( Jubilee Garden ) Being Rebuilt
New  Forodhani ( Jubilee Garden ) Being RebuiltNew  Forodhani ( Jubilee Garden ) Being Rebuilt
New  Forodhani ( Jubilee Garden ) Being Rebuilt
 
Bio - Jean Fares Couture
Bio - Jean Fares CoutureBio - Jean Fares Couture
Bio - Jean Fares Couture
 
Tips
TipsTips
Tips
 
Father
FatherFather
Father
 
Mahatma Gandhi
Mahatma GandhiMahatma Gandhi
Mahatma Gandhi
 
Vegetarian vision
Vegetarian visionVegetarian vision
Vegetarian vision
 
Adjective Jingle
Adjective JingleAdjective Jingle
Adjective Jingle
 
Transcript - Facebook Marketing Success Summit Ads Presentation 2011
Transcript - Facebook Marketing Success Summit Ads Presentation 2011Transcript - Facebook Marketing Success Summit Ads Presentation 2011
Transcript - Facebook Marketing Success Summit Ads Presentation 2011
 
Schloss mirabell
Schloss mirabellSchloss mirabell
Schloss mirabell
 
The broiler hen
The broiler hen The broiler hen
The broiler hen
 
Porting the QALL-ME framework to Romanian
Porting the QALL-ME framework to RomanianPorting the QALL-ME framework to Romanian
Porting the QALL-ME framework to Romanian
 
ExL Pharma Clinical Trials Phase I and Phase IIa Conference Brochure: Phase 1...
ExL Pharma Clinical Trials Phase I and Phase IIa Conference Brochure: Phase 1...ExL Pharma Clinical Trials Phase I and Phase IIa Conference Brochure: Phase 1...
ExL Pharma Clinical Trials Phase I and Phase IIa Conference Brochure: Phase 1...
 
Milieu Problematiek
Milieu ProblematiekMilieu Problematiek
Milieu Problematiek
 
Facebook Marketing Success Summit Presentation 2011 - Success with Facebook Ads
Facebook Marketing Success Summit Presentation 2011 - Success with Facebook AdsFacebook Marketing Success Summit Presentation 2011 - Success with Facebook Ads
Facebook Marketing Success Summit Presentation 2011 - Success with Facebook Ads
 
Mother
MotherMother
Mother
 
EuP Directive About Non Directional Domestic Lighting
EuP Directive About Non Directional Domestic LightingEuP Directive About Non Directional Domestic Lighting
EuP Directive About Non Directional Domestic Lighting
 
10 words
10 words10 words
10 words
 
July 10th 2014 - to use with members from multiple Unions
July 10th 2014 - to use with members from multiple UnionsJuly 10th 2014 - to use with members from multiple Unions
July 10th 2014 - to use with members from multiple Unions
 
Woman De John Lennon
Woman De John LennonWoman De John Lennon
Woman De John Lennon
 

Similaire à Developing Cocoa Applications with macRuby

RVM and Ruby Interpreters @ RSC Roma 03/2011
RVM and Ruby Interpreters @ RSC Roma 03/2011RVM and Ruby Interpreters @ RSC Roma 03/2011
RVM and Ruby Interpreters @ RSC Roma 03/2011Marcello Barnaba
 
Charla ruby nscodermad
Charla ruby nscodermadCharla ruby nscodermad
Charla ruby nscodermadnscoder_mad
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby DevelopersRenzo Borgatti
 
MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMatt Aimonetti
 
I phone udvikling best brains
I phone udvikling best brainsI phone udvikling best brains
I phone udvikling best brainsOve larsen
 
Sqlpo Presentation
Sqlpo PresentationSqlpo Presentation
Sqlpo Presentationsandook
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & HowGraham Tackley
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSCaridy Patino
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Thomas Lundström
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoaThilo Utke
 
MacRuby for Fun and Profit
MacRuby for Fun and ProfitMacRuby for Fun and Profit
MacRuby for Fun and ProfitJoshua Ballanco
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overviewThomas Asikis
 
Introduzione a macruby
Introduzione a macrubyIntroduzione a macruby
Introduzione a macrubyRenzo Borgatti
 

Similaire à Developing Cocoa Applications with macRuby (20)

RVM and Ruby Interpreters @ RSC Roma 03/2011
RVM and Ruby Interpreters @ RSC Roma 03/2011RVM and Ruby Interpreters @ RSC Roma 03/2011
RVM and Ruby Interpreters @ RSC Roma 03/2011
 
Charla ruby nscodermad
Charla ruby nscodermadCharla ruby nscodermad
Charla ruby nscodermad
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby Developers
 
MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meet
 
RubyMotion
RubyMotionRubyMotion
RubyMotion
 
Intro for RoR
Intro for RoRIntro for RoR
Intro for RoR
 
I phone udvikling best brains
I phone udvikling best brainsI phone udvikling best brains
I phone udvikling best brains
 
MacRuby on Rails
MacRuby on RailsMacRuby on Rails
MacRuby on Rails
 
Sqlpo Presentation
Sqlpo PresentationSqlpo Presentation
Sqlpo Presentation
 
ruby-cocoa
ruby-cocoaruby-cocoa
ruby-cocoa
 
ruby-cocoa
ruby-cocoaruby-cocoa
ruby-cocoa
 
RubyConf 2009
RubyConf 2009RubyConf 2009
RubyConf 2009
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & How
 
Caridy patino - node-js
Caridy patino - node-jsCaridy patino - node-js
Caridy patino - node-js
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoa
 
MacRuby for Fun and Profit
MacRuby for Fun and ProfitMacRuby for Fun and Profit
MacRuby for Fun and Profit
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
Introduzione a macruby
Introduzione a macrubyIntroduzione a macruby
Introduzione a macruby
 

Plus de Brendan Lim

Introduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKIntroduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKBrendan Lim
 
Building Native Apps With Titanium Mobile
Building Native Apps With Titanium MobileBuilding Native Apps With Titanium Mobile
Building Native Apps With Titanium MobileBrendan Lim
 
Im Mobile Who's Coming With Me
Im Mobile Who's Coming With MeIm Mobile Who's Coming With Me
Im Mobile Who's Coming With MeBrendan Lim
 
MacRuby to The Max
MacRuby to The MaxMacRuby to The Max
MacRuby to The MaxBrendan Lim
 
The Lure Of Ubiquitous Mobile
The Lure Of Ubiquitous MobileThe Lure Of Ubiquitous Mobile
The Lure Of Ubiquitous MobileBrendan Lim
 
Mobilizing Your Rails Application - Rails Underground, London, UK
Mobilizing Your Rails Application - Rails Underground, London, UKMobilizing Your Rails Application - Rails Underground, London, UK
Mobilizing Your Rails Application - Rails Underground, London, UKBrendan Lim
 
Mobilizing Your Rails Application - LA Ruby Conference 2009
Mobilizing Your Rails Application - LA Ruby Conference 2009Mobilizing Your Rails Application - LA Ruby Conference 2009
Mobilizing Your Rails Application - LA Ruby Conference 2009Brendan Lim
 

Plus de Brendan Lim (7)

Introduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDKIntroduction to Palm's Mojo SDK
Introduction to Palm's Mojo SDK
 
Building Native Apps With Titanium Mobile
Building Native Apps With Titanium MobileBuilding Native Apps With Titanium Mobile
Building Native Apps With Titanium Mobile
 
Im Mobile Who's Coming With Me
Im Mobile Who's Coming With MeIm Mobile Who's Coming With Me
Im Mobile Who's Coming With Me
 
MacRuby to The Max
MacRuby to The MaxMacRuby to The Max
MacRuby to The Max
 
The Lure Of Ubiquitous Mobile
The Lure Of Ubiquitous MobileThe Lure Of Ubiquitous Mobile
The Lure Of Ubiquitous Mobile
 
Mobilizing Your Rails Application - Rails Underground, London, UK
Mobilizing Your Rails Application - Rails Underground, London, UKMobilizing Your Rails Application - Rails Underground, London, UK
Mobilizing Your Rails Application - Rails Underground, London, UK
 
Mobilizing Your Rails Application - LA Ruby Conference 2009
Mobilizing Your Rails Application - LA Ruby Conference 2009Mobilizing Your Rails Application - LA Ruby Conference 2009
Mobilizing Your Rails Application - LA Ruby Conference 2009
 

Dernier

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Dernier (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Developing Cocoa Applications with macRuby

  • 1. Developing Cocoa Applications With MacRuby Brendan G. Lim @brendanlim brendan@intridea.com Saturday, February 5, 2011
  • 2. Outline • Objective-C & Cocoa • RubyCocoa • MacRuby • Live Coding • HotCocoa Saturday, February 5, 2011
  • 3. Objective -C • Object-oriented extensions to C • Strongly typed • Like Ruby, influenced by Smalltalk • Primarily used for Mac OS X and iOS Saturday, February 5, 2011
  • 4. Cocoa • High-level API for Mac OS X • Set of frameworks • Includes FoundationKit, AppKit, etc. • Apps typically built using tools like XCode and Interface Builder Saturday, February 5, 2011
  • 5. Why make desktop apps? Saturday, February 5, 2011
  • 7. Mac App Store 1. Build MacRuby application 2. Submit to App Store 4. Profit Saturday, February 5, 2011
  • 8. Why Ruby instead of Objective-C? Saturday, February 5, 2011
  • 9. Apple Loves Ruby 2002 Mac OS X 10.2 Ruby 1.6.7 2005 Mac OS X 10.4 Ruby 1.8.2 2007 Mac OS X 10.5 Ruby 1.8.6 RubyCocoa, RubyGems, Rails 2009 Mac OS X 10.6 Ruby 1.8.7 RubyCocoa, RubyGems, Rails 2011 Mac OS X 10.7 Ruby 1.9.x? MacRuby? RubyCocoa, RubyGems, Rails Saturday, February 5, 2011
  • 10. Ruby vs Objective-C object.method(param) = [object method:param]; Saturday, February 5, 2011
  • 11. Ruby vs Objective-C array = [] = NSMutableArray *array = [[NSMutableArray alloc] init]; Saturday, February 5, 2011
  • 12. Ruby vs Objective-C “ string”.strip = [@“ string” stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]] Saturday, February 5, 2011
  • 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]; Saturday, February 5, 2011
  • 15. RubyCocoa • Bridge between Objective-C and Ruby • Manipulate Objective-C objects using Ruby • Write Cocoa apps in Ruby • Runs on Ruby 1.8 • Ships with OSX Leopard Saturday, February 5, 2011
  • 16. RubyCocoa vs Objective-C OSX::NSNotificationCenter.defaultCenter.addObserver_selector_name_object( self, :window_moved, "NSWindowDidMoveNotification", nil ) = [[NSNotificationCenter defaultCenter] addObserver:self, selector:@selector(windowMoved:) name:”NSWindowDidMoveNotification” object:nil]; Saturday, February 5, 2011
  • 17. So, Why Not RubyCocoa? (besides it looking gross) Saturday, February 5, 2011
  • 18. Why Not RubyCocoa? • It’s a bridge! • Two runtimes, GCs, etc. • Object conversions • Syntax doesn’t feel like idiomatic Ruby • It’s getting replaced Saturday, February 5, 2011
  • 20. MacRuby • Implementation of Ruby 1.9 that runs on top the Objective-C runtime • Open sourced and supported by Apple • Replacing RubyCocoa • Objects are peers with no translation layer Saturday, February 5, 2011
  • 21. MacRuby Object NSObject String NSMutableString Number NSNumber Array NSMutableArray Hash NSMutableDictionary Saturday, February 5, 2011
  • 22. MacRuby Objects Objective-C Classes Objective-C Methods Objective-C Saturday, February 5, 2011
  • 23. MacRuby >> s = “magicruby” => “magicruby” >> s.class => String >> s.class.ancestors => [String,NSMutableString,NSString,Comparable,NSObject,Kernel] >> s.upcase => “MAGICRUBY” >> s.uppercaseString => “MAGICRUBY” Saturday, February 5, 2011
  • 24. MacRuby >> NSString.new(“magicruby”) => “magicruby” >> NSString.stringWithString(“magicruby”) => “magicruby” >> NSString.alloc.initWithString(“magicruby”) => “magicruby” Saturday, February 5, 2011
  • 25. MacRuby >> a = [] => [] >> a.class => Array >> a.class.ancestors => [Array,NSMutableArray,NSArray,Enumerable,NSObject,Kernel] >> a << “MagicRuby” => [“MagicRuby”] Saturday, February 5, 2011
  • 26. MacRuby vs Objective-C -(id) tableView:(NSTableView *)tableView objectValueForColumn:(NSTableColumn *)column row:(int)rowIndex { .. } Saturday, February 5, 2011
  • 27. MacRuby vs Objective-C -(id) tableView:(NSTableView *)tableView objectValueForColumn:(NSTableColumn *)column row:(int)rowIndex { .. } def tableView(tableView objectValueForColumn:column row:rowIndex) end Saturday, February 5, 2011
  • 28. MacRuby vs Objective-C Interface Builder Outlets & Actions ! Saturday, February 5, 2011
  • 29. MacRuby vs Objective-C Interface Builder Outlets # Interface NSString *myString; @property(nonatomic,retain) IBOutlet NSString *myString; = attr_accessor :myString Saturday, February 5, 2011
  • 30. MacRuby vs Objective-C Interface Builder Actions # Implementation -(IBAction) myAction:(id)sender { ... } = def myAction(sender) ... end Saturday, February 5, 2011
  • 31. MacRuby - Gem Support • sudo macgem install awesome_gem • Not all gems supported right now Saturday, February 5, 2011
  • 32. MacRuby - Objective-C Frameworks & Libraries • Libraries must have garbage collection support • Libraries must be turned into bundles • Frameworks can easily be included Saturday, February 5, 2011
  • 33. Testing MacRuby • Any Ruby testing framework instantly becomes an Objective-C testing framework • Test::Unit • RSpec • etc... Saturday, February 5, 2011
  • 34. What tools will we be using? Saturday, February 5, 2011
  • 38. Let’s build a MacRuby app Saturday, February 5, 2011
  • 39. HotCocoa • Created by Rich Kilmer • Ruby layer that sits on top of Cocoa, etc. • Use Ruby to easily create user interfaces • Used to be included with MacRuby • Now available as a gem Saturday, February 5, 2011
  • 40. HotCocoa win = NSWindow.alloc.initWithContentRect([10,20,300,300], styleMask: (NSTitleWindowMask | NSCloseableWindowMask | NSMiniatureizableWindowMask | NSResizeableWindowMask) = win = window :frame => [10,20,300,300] Saturday, February 5, 2011
  • 41. HotCocoa sudo macgem install hotcocoa hotcocoa NAME_OF_APP Saturday, February 5, 2011
  • 42. Hello World in HotCocoa require ‘hotcocoa’ class Application include HotCocoa def start application :name => "Hello" do |app| app.delegate = self window :frame => [500,500,200,100], :title => "Hello" do |win| win << label(:text => "Hello World",:layout => {:start => false}) win.will_close { exit } end end end end Application.new.start Saturday, February 5, 2011
  • 43. Questions? MacRuby in Action http://manning.com/lim http://macruby.org http://bit.ly/macruby-getting-started http://bit.ly/macruby-examples http://bit.ly/tdd-macruby Saturday, February 5, 2011