SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Similar a 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
 

Similar a 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
 

Más 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
 

Más 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
 

Último

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Último (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

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