SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
Ruby meets Cocoa
          Eloy Duran
Online
http://superalloy.nl/slides/ruby_meets_cocoa.pdf
Who is this guy?!
class EloyDuran < HomoSapiensObject

  attr_reader http://superalloy.nl/blog
  attr_writer e.duran@superalloy.nl

  def self.rubycocoa_os_stuff
    { :qtkit => 'Back in the day, when it was impossible to access C functions provided with a
                 framework from the Ruby side of the RubyCocoa bridge. I had written a wrapper
                 for QTKit which implemented all those functions.',

        :bridge_doc => 'A tool that ships with RubyCocoa which parses the Apple Objective-C
                        HTML reference files and transforms the Objective-C methods to the way
                        that calling is done from Ruby. The outputted ruby source files are then
                        passed to rdoc which creates HTML and ri documentation.',

        :ActiveRecordBindingsSupport => 'A set of Cocoa subclasses, included with RubyCocoa,
                                         which try to be the glue between Cocoa Bindings and
                                         ActiveRecord. Allowing you to create a CoreData like
                                         application, but instead using ActiveRecord as a backend.' }
  end

  def self.recent_super_secret_commercial_project
    quot;Can't say much about it, but basically it's a platform consisting of a server and clients,
    which handle the distribution of media files used in narrowcasting. The server is a Rails
    application with a Flex frontend to add media files to playlists. The clients are mac mini's
    that communicate with the server to see what they need to display and then start the transfer
    via the bittorrent protocol. The clients also run a application which displays the media
    files when needed. This player is created with RubyCocoa.quot;
  end
end
What is this Cocoa thing?
•   Cocoa is Apple’s native object-orientated programming
    environment for Mac OS X, written in Objective-C.

•   It’s derived from the NeXTSTEP and OPENSTEP programming
    environments developed by NeXT in the late 80’s.
    This is still visible in the prefix of all the class names, which is the
    acronym “NS” (for NeXTSTEP): NSString, NSArray etc.

•   It is a collection of frameworks, most notably:

    •   Foundation Kit / Foundation: not tied to the GUI
        eg: string manipulations.

    •   Application Kit / AppKit: to interact with the GUI
        eg: buttons, text fields.
Objective-C

•   Created by Brad Cox and Tom Love in the early 80’s,
    influenced heavily by Smalltalk.

•   Object-oriented programming language.

•   A strict superset of C, which means that any C code can be
    compiled by an Objective-C compiler.

•   Most of the syntax is inherited from C, the object-orientated
    syntax was added to allow Smalltalk-style messaging.

•   Like C, lots of semi-colons....
Objective-C example
                 Let’s say we have an instance of a class,
            which implements the following instance method:

       // An instance method called sayMessage:toPerson:
       - (void)sayMessage:(NSString)msg toPerson:(NSString)person
       {
           NSLog(@”%@ %@!”, msg, person);
       }

   When we pass the instance the sayMessage:toPerson message,
        a line will be printed to the console by NSLog()

[theInstance sayMessage:@”Hello” toPerson:@”World”]; //=> “Hello World!”
The most important thing
about Objective-C to me....
I’m a total (Obj-)C noob!
          by choice...
So, I need another solution
 to make use of Cocoa’s
      excellent facilities.
RubyCocoa
RubyCocoa History
•   Late 2001: Started by Hisakuni Fujimoto. Release 0.1 - 0.4

•   2002 - 2006: Release 0.5. More committers joined:
    Chris Thomas, Kimura Wataru, Jonathan Paisley, Tim Burks.

•   2006-05: Laurent Sansonetti (Apple inc) joins the committers list
    in order to make RubyCocoa a first class citizen among the
    programming languages supported in Mac OS X10.5 (leopard).
    Most notable is the addition of Libffi/BridgeSupport.

•   2006-11: I joined the committers list to add BridgeDoc.

•   2006-12: First preview (0.9) of the Apple branch was released.

•   2007-01: Second preview (0.10) was released.

•   2007-05: Third preview (0.11) and now officially the current
    stable release was released.
What is RubyCocoa?
•   It is a real bridge between the Ruby & Objective-C programming
    languages. Which means it isn’t limited to a predefined set of
    Cocoa frameworks.

•   It works by creating a Ruby proxy class for a Objective-C class.
    The method calls are sent through the use of Libffi.
    Which also allows us to call C functions even though they aren’t
    methods on objects.

•   The classes are imported lazily.
    Meaning that RubyCocoa imports them only on demand.

•   BridgeSupport allows RubyCocoa to bridge other parts of a
    framework, like C structures, constants.

•   Because it’s a real bridge, it works both ways. Thus you can mix
    Ruby and Objective-C inside your app.
RubyCocoa example
      Let’s say we have an instance of a Objective-C class,
       which implements the following instance method:
     // An instance method called sayMessage:toPerson:
     - (void)sayMessage:(NSString)msg toPerson:(NSString)person

           Ruby doesn’t have named parameters (yet?),
so the selectors have to be translated in a way that we can use it:
# Traditional syntax
theInstance.sayMessage_toPerson_('Hello', 'World')
# Lazy traditional syntax
theInstance.sayMessage_toPerson('Hello', 'World')
# Alternative syntax
theInstance.objc_send(:sayMessage, 'Hello',
                        :toPerson, 'World')
Time for some action!


     The state of the art
      MailDemo sample

Let’s all pray uncle Murphy won’t act upon his law.....
             Or laugh, whichever you prefer.
Questions?
Readfood:
•Hisakuni Fujimoto: http://fobj.com/hisa/d
•Laurent Sansonetti: http://chopine.be/lrz/diary
•Me: http://superalloy.nl/blog
•RubyCocoa website/wiki: http://rubycocoa.sf.net
•Drop by in the irc channel (freenode): #ruby-osx
•MailingLists: http://rubycocoa.sf.net/GettingSupport
•RubyCocoa tutorials: http://rubycocoa.com
•Original MailDemo tutorial:
http://cocoadevcentral.com/articles/000080.php

•Unlimited coding inspiration: http://www.johnnyweb.fr

Contenu connexe

Tendances

Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deploymentThilo Utke
 
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)SATOSHI TAGOMORI
 
PHP and Node.js-Differences and Similarities
PHP and Node.js-Differences and SimilaritiesPHP and Node.js-Differences and Similarities
PHP and Node.js-Differences and SimilaritiesCloud Analogy
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCTim Burks
 
HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009jarfield
 
Socket Programming using Java
Socket Programming using JavaSocket Programming using Java
Socket Programming using JavaRahul Hada
 
Distributed Ruby and Rails
Distributed Ruby and RailsDistributed Ruby and Rails
Distributed Ruby and RailsWen-Tien Chang
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?Hiroshi SHIBATA
 
692015 programming assignment 1 building a multi­threaded w
692015 programming assignment 1 building a multi­threaded w692015 programming assignment 1 building a multi­threaded w
692015 programming assignment 1 building a multi­threaded wsmile790243
 
Mazda siv - web services
Mazda   siv - web servicesMazda   siv - web services
Mazda siv - web servicesOlivier Lépine
 
What Makes Objective C Dynamic?
What Makes Objective C Dynamic?What Makes Objective C Dynamic?
What Makes Objective C Dynamic?Kyle Oba
 
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...Alexandre Morgaut
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for RubyHiroshi SHIBATA
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...bobmcwhirter
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 

Tendances (20)

Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deployment
 
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
 
PHP and Node.js-Differences and Similarities
PHP and Node.js-Differences and SimilaritiesPHP and Node.js-Differences and Similarities
PHP and Node.js-Differences and Similarities
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPC
 
Difference between php and node
Difference between php and nodeDifference between php and node
Difference between php and node
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009
 
Socket Programming using Java
Socket Programming using JavaSocket Programming using Java
Socket Programming using Java
 
Distributed Ruby and Rails
Distributed Ruby and RailsDistributed Ruby and Rails
Distributed Ruby and Rails
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?
 
Groovy & Grails
Groovy & GrailsGroovy & Grails
Groovy & Grails
 
692015 programming assignment 1 building a multi­threaded w
692015 programming assignment 1 building a multi­threaded w692015 programming assignment 1 building a multi­threaded w
692015 programming assignment 1 building a multi­threaded w
 
Mazda siv - web services
Mazda   siv - web servicesMazda   siv - web services
Mazda siv - web services
 
What Makes Objective C Dynamic?
What Makes Objective C Dynamic?What Makes Objective C Dynamic?
What Makes Objective C Dynamic?
 
20140918 ruby kaigi2014
20140918 ruby kaigi201420140918 ruby kaigi2014
20140918 ruby kaigi2014
 
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
State of the art: Server-Side JavaScript - WebWorkersCamp IV - Open World For...
 
RubyGems 3 & 4
RubyGems 3 & 4RubyGems 3 & 4
RubyGems 3 & 4
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for Ruby
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 

Similaire à Ruby Meets Cocoa

Macruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMacruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMatt Aimonetti
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overviewThomas Asikis
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVMJung Kim
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...Jérôme Petazzoni
 
CC-Castle; The best Real-Time/Embedded/HighTech language EVER?
CC-Castle; The best Real-Time/Embedded/HighTech language EVER?CC-Castle; The best Real-Time/Embedded/HighTech language EVER?
CC-Castle; The best Real-Time/Embedded/HighTech language EVER?Albert Mietus
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the RubyistWill Green
 
Writing a Gem with native extensions
Writing a Gem with native extensionsWriting a Gem with native extensions
Writing a Gem with native extensionsTristan Penman
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoaThilo Utke
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Eugene Yokota
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsMichael Lange
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012Mark Villacampa
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails DevsDiacode
 

Similaire à Ruby Meets Cocoa (20)

ruby-cocoa
ruby-cocoaruby-cocoa
ruby-cocoa
 
Macruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMacruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich Kilmer
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
MacRuby, an introduction
MacRuby, an introductionMacRuby, an introduction
MacRuby, an introduction
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
CC-Castle; The best Real-Time/Embedded/HighTech language EVER?
CC-Castle; The best Real-Time/Embedded/HighTech language EVER?CC-Castle; The best Real-Time/Embedded/HighTech language EVER?
CC-Castle; The best Real-Time/Embedded/HighTech language EVER?
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the Rubyist
 
Writing a Gem with native extensions
Writing a Gem with native extensionsWriting a Gem with native extensions
Writing a Gem with native extensions
 
Intro to Rack
Intro to RackIntro to Rack
Intro to Rack
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoa
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)
 
Docker 101
Docker 101 Docker 101
Docker 101
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012
 
Srgoc dotnet_new
Srgoc dotnet_newSrgoc dotnet_new
Srgoc dotnet_new
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 

Plus de Robbert

BDD & Rspec
BDD & Rspec BDD & Rspec
BDD & Rspec Robbert
 
A Ct Os Story
A Ct Os StoryA Ct Os Story
A Ct Os StoryRobbert
 
Camping For The Rest Of Us
Camping For The Rest Of UsCamping For The Rest Of Us
Camping For The Rest Of UsRobbert
 
Betty Builder, Een GUI voor het maken en aanpassen van Rails models en migra...
Betty Builder,  Een GUI voor het maken en aanpassen van Rails models en migra...Betty Builder,  Een GUI voor het maken en aanpassen van Rails models en migra...
Betty Builder, Een GUI voor het maken en aanpassen van Rails models en migra...Robbert
 
ActiveResource & REST
ActiveResource & RESTActiveResource & REST
ActiveResource & RESTRobbert
 
JRuby Rules
JRuby RulesJRuby Rules
JRuby RulesRobbert
 
Serving Up Your Rails App On A Mongrel Cluster
Serving Up Your Rails App On A Mongrel ClusterServing Up Your Rails App On A Mongrel Cluster
Serving Up Your Rails App On A Mongrel ClusterRobbert
 

Plus de Robbert (7)

BDD & Rspec
BDD & Rspec BDD & Rspec
BDD & Rspec
 
A Ct Os Story
A Ct Os StoryA Ct Os Story
A Ct Os Story
 
Camping For The Rest Of Us
Camping For The Rest Of UsCamping For The Rest Of Us
Camping For The Rest Of Us
 
Betty Builder, Een GUI voor het maken en aanpassen van Rails models en migra...
Betty Builder,  Een GUI voor het maken en aanpassen van Rails models en migra...Betty Builder,  Een GUI voor het maken en aanpassen van Rails models en migra...
Betty Builder, Een GUI voor het maken en aanpassen van Rails models en migra...
 
ActiveResource & REST
ActiveResource & RESTActiveResource & REST
ActiveResource & REST
 
JRuby Rules
JRuby RulesJRuby Rules
JRuby Rules
 
Serving Up Your Rails App On A Mongrel Cluster
Serving Up Your Rails App On A Mongrel ClusterServing Up Your Rails App On A Mongrel Cluster
Serving Up Your Rails App On A Mongrel Cluster
 

Dernier

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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
🐬 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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Dernier (20)

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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
+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...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Ruby Meets Cocoa

  • 1. Ruby meets Cocoa Eloy Duran
  • 3. Who is this guy?! class EloyDuran < HomoSapiensObject attr_reader http://superalloy.nl/blog attr_writer e.duran@superalloy.nl def self.rubycocoa_os_stuff { :qtkit => 'Back in the day, when it was impossible to access C functions provided with a framework from the Ruby side of the RubyCocoa bridge. I had written a wrapper for QTKit which implemented all those functions.', :bridge_doc => 'A tool that ships with RubyCocoa which parses the Apple Objective-C HTML reference files and transforms the Objective-C methods to the way that calling is done from Ruby. The outputted ruby source files are then passed to rdoc which creates HTML and ri documentation.', :ActiveRecordBindingsSupport => 'A set of Cocoa subclasses, included with RubyCocoa, which try to be the glue between Cocoa Bindings and ActiveRecord. Allowing you to create a CoreData like application, but instead using ActiveRecord as a backend.' } end def self.recent_super_secret_commercial_project quot;Can't say much about it, but basically it's a platform consisting of a server and clients, which handle the distribution of media files used in narrowcasting. The server is a Rails application with a Flex frontend to add media files to playlists. The clients are mac mini's that communicate with the server to see what they need to display and then start the transfer via the bittorrent protocol. The clients also run a application which displays the media files when needed. This player is created with RubyCocoa.quot; end end
  • 4. What is this Cocoa thing? • Cocoa is Apple’s native object-orientated programming environment for Mac OS X, written in Objective-C. • It’s derived from the NeXTSTEP and OPENSTEP programming environments developed by NeXT in the late 80’s. This is still visible in the prefix of all the class names, which is the acronym “NS” (for NeXTSTEP): NSString, NSArray etc. • It is a collection of frameworks, most notably: • Foundation Kit / Foundation: not tied to the GUI eg: string manipulations. • Application Kit / AppKit: to interact with the GUI eg: buttons, text fields.
  • 5. Objective-C • Created by Brad Cox and Tom Love in the early 80’s, influenced heavily by Smalltalk. • Object-oriented programming language. • A strict superset of C, which means that any C code can be compiled by an Objective-C compiler. • Most of the syntax is inherited from C, the object-orientated syntax was added to allow Smalltalk-style messaging. • Like C, lots of semi-colons....
  • 6. Objective-C example Let’s say we have an instance of a class, which implements the following instance method: // An instance method called sayMessage:toPerson: - (void)sayMessage:(NSString)msg toPerson:(NSString)person { NSLog(@”%@ %@!”, msg, person); } When we pass the instance the sayMessage:toPerson message, a line will be printed to the console by NSLog() [theInstance sayMessage:@”Hello” toPerson:@”World”]; //=> “Hello World!”
  • 7. The most important thing about Objective-C to me....
  • 8. I’m a total (Obj-)C noob! by choice...
  • 9. So, I need another solution to make use of Cocoa’s excellent facilities.
  • 11. RubyCocoa History • Late 2001: Started by Hisakuni Fujimoto. Release 0.1 - 0.4 • 2002 - 2006: Release 0.5. More committers joined: Chris Thomas, Kimura Wataru, Jonathan Paisley, Tim Burks. • 2006-05: Laurent Sansonetti (Apple inc) joins the committers list in order to make RubyCocoa a first class citizen among the programming languages supported in Mac OS X10.5 (leopard). Most notable is the addition of Libffi/BridgeSupport. • 2006-11: I joined the committers list to add BridgeDoc. • 2006-12: First preview (0.9) of the Apple branch was released. • 2007-01: Second preview (0.10) was released. • 2007-05: Third preview (0.11) and now officially the current stable release was released.
  • 12. What is RubyCocoa? • It is a real bridge between the Ruby & Objective-C programming languages. Which means it isn’t limited to a predefined set of Cocoa frameworks. • It works by creating a Ruby proxy class for a Objective-C class. The method calls are sent through the use of Libffi. Which also allows us to call C functions even though they aren’t methods on objects. • The classes are imported lazily. Meaning that RubyCocoa imports them only on demand. • BridgeSupport allows RubyCocoa to bridge other parts of a framework, like C structures, constants. • Because it’s a real bridge, it works both ways. Thus you can mix Ruby and Objective-C inside your app.
  • 13. RubyCocoa example Let’s say we have an instance of a Objective-C class, which implements the following instance method: // An instance method called sayMessage:toPerson: - (void)sayMessage:(NSString)msg toPerson:(NSString)person Ruby doesn’t have named parameters (yet?), so the selectors have to be translated in a way that we can use it: # Traditional syntax theInstance.sayMessage_toPerson_('Hello', 'World') # Lazy traditional syntax theInstance.sayMessage_toPerson('Hello', 'World') # Alternative syntax theInstance.objc_send(:sayMessage, 'Hello', :toPerson, 'World')
  • 14. Time for some action! The state of the art MailDemo sample Let’s all pray uncle Murphy won’t act upon his law..... Or laugh, whichever you prefer.
  • 16. Readfood: •Hisakuni Fujimoto: http://fobj.com/hisa/d •Laurent Sansonetti: http://chopine.be/lrz/diary •Me: http://superalloy.nl/blog •RubyCocoa website/wiki: http://rubycocoa.sf.net •Drop by in the irc channel (freenode): #ruby-osx •MailingLists: http://rubycocoa.sf.net/GettingSupport •RubyCocoa tutorials: http://rubycocoa.com •Original MailDemo tutorial: http://cocoadevcentral.com/articles/000080.php •Unlimited coding inspiration: http://www.johnnyweb.fr