SlideShare una empresa de Scribd logo
1 de 47
Une courte introduction à


                           MacRuby
                               Objective-C, Cocoa, LLVM, Grand Central
                                         et autres amusements




Olivier Gutknecht - OSDC.fr - Oct. 3 2009
Olivier Gutknecht
olg@no-distance.net
twitter : olg
Olivier Gutknecht
olg@no-distance.net
twitter : olg




  iCal, iSync, [...]
Olivier Gutknecht
olg@no-distance.net
twitter : olg




  iCal, iSync, [...]     co-founder
                       Server Software
Olivier Gutknecht
olg@no-distance.net
twitter : olg




                                         MacRuby


  iCal, iSync, [...]     co-founder      Lurker actif
                       Server Software
Breaking News !

MacRuby developer
attacked by raptors
Text
 Text
Text
 Text
MacRuby
Mac OS X

  Applications


  Application
  Frameworks
                    Cocoa, WebKit, ...


Core Technologies   CoreGraphics, CoreFoundation, ...


     Darwin         Kernel, userland, libdispatch, ...
Ruby sur OS X
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, gems, Rails


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


20xx         ?          Sky is the limit
Ruby sur OS X
• Ruby sur une plateforme Unix...
• Avec quelques agréments en plus...
  par ex: mongrel_rails_persists:
  intégration launchd, bonjour


• Et Cocoa alors ?
Une affaire de famille

         SmallTalk


Objective-C     Ruby
Ecrire une “vraie” appli
    Mac en Ruby ?




         GitNub
RubyCocoa
• Un vrai bridge (Fujimoto Hisakuni, 2001)
• Syntaxe... intéressante
• Ruby 1.8
• Green threads, non réentrant
• Deux runtimes, deux GC
• Ouch
require 'osx/cocoa'; include OSX
app = NSApplication.sharedApplication
win = NSWindow.alloc.initWithContentRect_styleMask_backing_defer(
[0, 0, 200, 60], NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask,
NSBackingStoreBuffered, false)
win.title = 'Hello World'
button = NSButton.alloc.initWithFrame(NSZeroRect)
win.contentView.addSubview(button)
button.bezelStyle = NSRoundedBezelStyle
button.title = 'Hello!'
button.sizeToFit
button.frameOrigin = NSMakePoint((win.contentView.frameSize.width/
2.0)-(button.frameSize.width/2.0), (win.contentView.frameSize.height/
2.0)-(button.frameSize.height/2.0))
button_controller = Object.new def button_controller.sayHello(sender)
puts "Hello OSDC!" end
button.target = button_controller
button.action = 'sayHello:'
win.display
win.orderFrontRegardless
app.run
Facile.
(si on connait Objective-C, Cocoa, Ruby, et les dragons qui se cachent dans les recoins du bridge)
MacRuby
MacRuby

• One GC to release them all
MacRuby

• One GC to release them all
• One runtime to bind them
MacRuby

• One GC to release them all
• One runtime to bind them
• In the land of Cocoa where Obj-C lie
MacRuby

• One GC to release them all
• One runtime to bind them
• In the land of Cocoa where Obj-C lie
• Et HotCocoa pour rubyfier le tout
MacRuby
      Laurent Sansonetti
           (Apple)
          Vincent Isambart
            Kich Kilmer
             Eloy Duran
             Ben Stiglitz
           Matt Aimonetti
                  ...

       http://www.macruby.org
      http://twitter.com/macruby
En toute simplicité...


• La meilleure plateforme pour les devs Ruby
• Une plateforme de qualité pour les devs Cocoa
Bridge, quel bridge ?
$ macirb
>> s = "osdc"
=> "osdc"

>> s.class
=> NSMutableString

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

>> s.upcase
=> "OSDC"

>> s.uppercaseString
=> "OSDC"

>> s.respondsToSelector(:upcase)
=> 1

>> s.respond_to?(:upcase)
=> true
Bridge, quel bridge ?

• Une classe Ruby est une classe Obj-C
• Une méthode Ruby est une méthode Obj-C
• Une instance Ruby est une instance Obj-C
Syntaxe
                                             Objective-C
Person *person = [Person new];

[person name];
[person setName:name];
[person setFirstName:first lastName:last];


                                               MacRuby
person = Person.new

person.name
person.name = myName
person.setFirstName(first, lastName:last)
HotCocoa
require ‘hotcocoa’
include HotCocoa

application do
  win = window :title => ‘hello OSDC’, :frame => [0, 0, 200, 60]
  b = button :title => ‘Hello!’, :layout => {:align => :center}
  win << b
  b.on_action { puts “Hello OSDC!” }
end
Ruby 1.9


Parseur     Runtime   Built-in classes

YARV         GC           Stdlib
MacRuby

               Runtime
 Parseur                      Stdlib

LLVM/Roxor     libobjc   Built-in Classes
AOT    JIT     libauto
                         CoreFoundation
MacRuby 0.4 - 04/09

•   Intégration XCode

•   Embedding / Runtime
    Control

•   HotCocoa

•   Threaded GC
MacRuby 0.5 - xx/09

•   YARV ? LLVM !

•   RubySpec

•   AOT

•   GrandCentral

•   ...
Pourquoi LLVM ?
Coolest Logo Ever
Tout le monde adore
les microbenchmarks

(surtout s’ils sont menteurs
     et non significatifs)
C

static int fib(int n)
{
  if (n < 3) {
    return 1;
  } else {
    return fib(n - 1) + fib(n - 2);
  }
}
Objective-C

@implementation Fib
- (int)fib:(int)n
{
  if (n < 3) {
   return 1;
  } else {
   return [self fib:n - 1] + [self fib:n - 2];
  }
}
@end
4




                        3
temps d’exécution (s)




                        2




                        1




                        0
                                fib(40)
                            C             Objective-C
Ruby

def fib(n)
  if n < 3
    1
  else
    fib(n-1) + fib(n-2)
  end
end

p fib(ARGV.join("").to_i)
4




                        3
temps d’exécution (s)




                        2




                        1




                        0
                                  fib(40)


                            C   MacRuby     Objective-C
MRI Ruby 1.8
$ ruby fibo.rb 40
102334155


                               MacRuby
$ macruby fibo.rb 40
102334155


                           MacRuby AOT
$ macrubyc fibo.rb -o fibo
$ ./fibo 40
102334155
Grand Central
# A GCD-based implementation of the sleeping barber problem:
#   http://en.wikipedia.org/wiki/Sleeping_barber_problem
#   http://www.madebysofa.com/#blog/the_sleeping_barber

waiting_chairs = Dispatch::Queue.new('com.apple.waiting_chairs')
semaphore = Dispatch::Semaphore.new(3)
index = -1
while true
  index += 1
  success = semaphore.wait(Dispatch::TIME_NOW)
  if success != 0
    puts "Customer turned away #{index}"
    next
  end
  waiting_chairs.dispatch do
    semaphore.signal
    puts "Shave and a haircut #{index}"
  end
end
Le bonheur

   ?
Pourquoi MacRuby ?

• Ruby pour développer des applications
  desktop “mac-like”
• Un terrain d’expérimentation formidable
• Des perspectives ... intéressantes
Q&A
• Compatibilité Ruby 1.9
 • Actuellement ≈ 80% sur la suite
    rubyspec
• Portabilité sur d’autres plateformes
 • Dépendances FLOSS, aucun obstacle
    technique insurmontable...
 • ... des volontaires ?
Merci !

Más contenido relacionado

La actualidad más candente

Développement d'un générateur d'intépréteur de bytecodes pour une JVM embarquée
Développement d'un générateur d'intépréteur de bytecodes pour une JVM embarquéeDéveloppement d'un générateur d'intépréteur de bytecodes pour une JVM embarquée
Développement d'un générateur d'intépréteur de bytecodes pour une JVM embarquéeMustapha Tachouct
 
RASPBERRY PI - votre infrastructure : ansible, user, iptables, monitoring, re...
RASPBERRY PI - votre infrastructure : ansible, user, iptables, monitoring, re...RASPBERRY PI - votre infrastructure : ansible, user, iptables, monitoring, re...
RASPBERRY PI - votre infrastructure : ansible, user, iptables, monitoring, re...XavierPestel
 
OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student
OWF12/PAUG Conf Days From dalvik to apps development    jérôme pilliet studentOWF12/PAUG Conf Days From dalvik to apps development    jérôme pilliet student
OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet studentParis Open Source Summit
 
Techday Arrow Group: Java 8
Techday Arrow Group: Java 8Techday Arrow Group: Java 8
Techday Arrow Group: Java 8Arrow Group
 
Les Promises en Javascript
Les Promises en JavascriptLes Promises en Javascript
Les Promises en JavascriptBenoit Zohar
 
I le langage java d'una manière avancée introduction
I  le langage java d'una manière avancée introductionI  le langage java d'una manière avancée introduction
I le langage java d'una manière avancée introductionsabrine_hamdi
 
Développer en natif avec C++11
Développer en natif avec C++11Développer en natif avec C++11
Développer en natif avec C++11Microsoft
 
Les fonctions lambdas en C++11 et C++14
Les fonctions lambdas en C++11 et C++14Les fonctions lambdas en C++11 et C++14
Les fonctions lambdas en C++11 et C++14Aurélien Regat-Barrel
 
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...XavierPestel
 

La actualidad más candente (9)

Développement d'un générateur d'intépréteur de bytecodes pour une JVM embarquée
Développement d'un générateur d'intépréteur de bytecodes pour une JVM embarquéeDéveloppement d'un générateur d'intépréteur de bytecodes pour une JVM embarquée
Développement d'un générateur d'intépréteur de bytecodes pour une JVM embarquée
 
RASPBERRY PI - votre infrastructure : ansible, user, iptables, monitoring, re...
RASPBERRY PI - votre infrastructure : ansible, user, iptables, monitoring, re...RASPBERRY PI - votre infrastructure : ansible, user, iptables, monitoring, re...
RASPBERRY PI - votre infrastructure : ansible, user, iptables, monitoring, re...
 
OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student
OWF12/PAUG Conf Days From dalvik to apps development    jérôme pilliet studentOWF12/PAUG Conf Days From dalvik to apps development    jérôme pilliet student
OWF12/PAUG Conf Days From dalvik to apps development jérôme pilliet student
 
Techday Arrow Group: Java 8
Techday Arrow Group: Java 8Techday Arrow Group: Java 8
Techday Arrow Group: Java 8
 
Les Promises en Javascript
Les Promises en JavascriptLes Promises en Javascript
Les Promises en Javascript
 
I le langage java d'una manière avancée introduction
I  le langage java d'una manière avancée introductionI  le langage java d'una manière avancée introduction
I le langage java d'una manière avancée introduction
 
Développer en natif avec C++11
Développer en natif avec C++11Développer en natif avec C++11
Développer en natif avec C++11
 
Les fonctions lambdas en C++11 et C++14
Les fonctions lambdas en C++11 et C++14Les fonctions lambdas en C++11 et C++14
Les fonctions lambdas en C++11 et C++14
 
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...
Pipeline Devops - Intégration continue : ansible, jenkins, docker, jmeter...
 

Similar a Introduction à MacRuby - OSDC.fr 2009

Retours Devoxx France 2016
Retours Devoxx France 2016Retours Devoxx France 2016
Retours Devoxx France 2016Antoine Rey
 
Ops@viadeo : Puppet & Co... 6 mois après par Xavier Krantz
Ops@viadeo : Puppet & Co... 6 mois après par Xavier KrantzOps@viadeo : Puppet & Co... 6 mois après par Xavier Krantz
Ops@viadeo : Puppet & Co... 6 mois après par Xavier KrantzOlivier DASINI
 
Chap1_PresentationJava.pdf
Chap1_PresentationJava.pdfChap1_PresentationJava.pdf
Chap1_PresentationJava.pdfsayf7
 
Solutions Linux 2008 - JavaScript
Solutions Linux 2008 - JavaScriptSolutions Linux 2008 - JavaScript
Solutions Linux 2008 - JavaScriptRaphaël Semeteys
 
C++ 11 - Tech Days 2014 in Paris
C++ 11 - Tech Days 2014 in ParisC++ 11 - Tech Days 2014 in Paris
C++ 11 - Tech Days 2014 in Parischristophep21
 
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++Microsoft
 
XebiCon'17 : Kotlin, état de l'art - Benjamin Lacroix et Sergio Dos Santos
XebiCon'17 : Kotlin, état de l'art - Benjamin Lacroix et Sergio Dos SantosXebiCon'17 : Kotlin, état de l'art - Benjamin Lacroix et Sergio Dos Santos
XebiCon'17 : Kotlin, état de l'art - Benjamin Lacroix et Sergio Dos SantosPublicis Sapient Engineering
 
BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseries
BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseriesBreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseries
BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseriesXavier MARIN
 
Partie1 TypeScript
Partie1 TypeScriptPartie1 TypeScript
Partie1 TypeScriptHabib Ayad
 
Développer sereinement avec Node.js
Développer sereinement avec Node.jsDévelopper sereinement avec Node.js
Développer sereinement avec Node.jsJulien Giovaresco
 
Mariadb pour les developpeurs - OSDC
Mariadb pour les developpeurs - OSDCMariadb pour les developpeurs - OSDC
Mariadb pour les developpeurs - OSDCChristophe Villeneuve
 
Environnement de développement de bases de données
Environnement de développement de bases de donnéesEnvironnement de développement de bases de données
Environnement de développement de bases de donnéesISIG
 
Présentation LMAX / Disruptor
Présentation LMAX / DisruptorPrésentation LMAX / Disruptor
Présentation LMAX / DisruptorSOAT
 
Etat de l'art Server-Side JavaScript - JS Geneve
Etat de l'art Server-Side JavaScript - JS GeneveEtat de l'art Server-Side JavaScript - JS Geneve
Etat de l'art Server-Side JavaScript - JS GeneveAlexandre Morgaut
 

Similar a Introduction à MacRuby - OSDC.fr 2009 (20)

Retours Devoxx France 2016
Retours Devoxx France 2016Retours Devoxx France 2016
Retours Devoxx France 2016
 
Ops@viadeo : Puppet & Co... 6 mois après par Xavier Krantz
Ops@viadeo : Puppet & Co... 6 mois après par Xavier KrantzOps@viadeo : Puppet & Co... 6 mois après par Xavier Krantz
Ops@viadeo : Puppet & Co... 6 mois après par Xavier Krantz
 
Présentation de Node.js
Présentation de Node.jsPrésentation de Node.js
Présentation de Node.js
 
Chap1_PresentationJava.pdf
Chap1_PresentationJava.pdfChap1_PresentationJava.pdf
Chap1_PresentationJava.pdf
 
Solutions Linux 2008 - JavaScript
Solutions Linux 2008 - JavaScriptSolutions Linux 2008 - JavaScript
Solutions Linux 2008 - JavaScript
 
C++ 11 - Tech Days 2014 in Paris
C++ 11 - Tech Days 2014 in ParisC++ 11 - Tech Days 2014 in Paris
C++ 11 - Tech Days 2014 in Paris
 
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
Bonnes pratiques pour apprivoiser le C++11 avec Visual C++
 
XebiCon'17 : Kotlin, état de l'art - Benjamin Lacroix et Sergio Dos Santos
XebiCon'17 : Kotlin, état de l'art - Benjamin Lacroix et Sergio Dos SantosXebiCon'17 : Kotlin, état de l'art - Benjamin Lacroix et Sergio Dos Santos
XebiCon'17 : Kotlin, état de l'art - Benjamin Lacroix et Sergio Dos Santos
 
The future of JavaScript
The future of JavaScriptThe future of JavaScript
The future of JavaScript
 
BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseries
BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseriesBreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseries
BreizhCamp 2019 - IoT et open source hardware pour la collecte de timeseries
 
Partie1 TypeScript
Partie1 TypeScriptPartie1 TypeScript
Partie1 TypeScript
 
Java vs .Net
Java vs .NetJava vs .Net
Java vs .Net
 
Java vs .Net
Java vs .NetJava vs .Net
Java vs .Net
 
Développer sereinement avec Node.js
Développer sereinement avec Node.jsDévelopper sereinement avec Node.js
Développer sereinement avec Node.js
 
Apple : iOS
Apple : iOSApple : iOS
Apple : iOS
 
Mariadb pour les developpeurs - OSDC
Mariadb pour les developpeurs - OSDCMariadb pour les developpeurs - OSDC
Mariadb pour les developpeurs - OSDC
 
Environnement de développement de bases de données
Environnement de développement de bases de donnéesEnvironnement de développement de bases de données
Environnement de développement de bases de données
 
Vert.x 3
Vert.x 3Vert.x 3
Vert.x 3
 
Présentation LMAX / Disruptor
Présentation LMAX / DisruptorPrésentation LMAX / Disruptor
Présentation LMAX / Disruptor
 
Etat de l'art Server-Side JavaScript - JS Geneve
Etat de l'art Server-Side JavaScript - JS GeneveEtat de l'art Server-Side JavaScript - JS Geneve
Etat de l'art Server-Side JavaScript - JS Geneve
 

Introduction à MacRuby - OSDC.fr 2009

  • 1. Une courte introduction à MacRuby Objective-C, Cocoa, LLVM, Grand Central et autres amusements Olivier Gutknecht - OSDC.fr - Oct. 3 2009
  • 4. Olivier Gutknecht olg@no-distance.net twitter : olg iCal, iSync, [...] co-founder Server Software
  • 5. Olivier Gutknecht olg@no-distance.net twitter : olg MacRuby iCal, iSync, [...] co-founder Lurker actif Server Software
  • 6. Breaking News ! MacRuby developer attacked by raptors
  • 10. Mac OS X Applications Application Frameworks Cocoa, WebKit, ... Core Technologies CoreGraphics, CoreFoundation, ... Darwin Kernel, userland, libdispatch, ...
  • 11. Ruby sur OS X 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, gems, Rails 2009 Mac OS X 10.6 Ruby 1.8.7 RubyCocoa, gems, Rails 20xx ? Sky is the limit
  • 12. Ruby sur OS X • Ruby sur une plateforme Unix... • Avec quelques agréments en plus... par ex: mongrel_rails_persists: intégration launchd, bonjour • Et Cocoa alors ?
  • 13. Une affaire de famille SmallTalk Objective-C Ruby
  • 14. Ecrire une “vraie” appli Mac en Ruby ? GitNub
  • 15. RubyCocoa • Un vrai bridge (Fujimoto Hisakuni, 2001) • Syntaxe... intéressante • Ruby 1.8 • Green threads, non réentrant • Deux runtimes, deux GC • Ouch
  • 16.
  • 17. require 'osx/cocoa'; include OSX app = NSApplication.sharedApplication win = NSWindow.alloc.initWithContentRect_styleMask_backing_defer( [0, 0, 200, 60], NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask, NSBackingStoreBuffered, false) win.title = 'Hello World' button = NSButton.alloc.initWithFrame(NSZeroRect) win.contentView.addSubview(button) button.bezelStyle = NSRoundedBezelStyle button.title = 'Hello!' button.sizeToFit button.frameOrigin = NSMakePoint((win.contentView.frameSize.width/ 2.0)-(button.frameSize.width/2.0), (win.contentView.frameSize.height/ 2.0)-(button.frameSize.height/2.0)) button_controller = Object.new def button_controller.sayHello(sender) puts "Hello OSDC!" end button.target = button_controller button.action = 'sayHello:' win.display win.orderFrontRegardless app.run
  • 18. Facile. (si on connait Objective-C, Cocoa, Ruby, et les dragons qui se cachent dans les recoins du bridge)
  • 20. MacRuby • One GC to release them all
  • 21. MacRuby • One GC to release them all • One runtime to bind them
  • 22. MacRuby • One GC to release them all • One runtime to bind them • In the land of Cocoa where Obj-C lie
  • 23. MacRuby • One GC to release them all • One runtime to bind them • In the land of Cocoa where Obj-C lie • Et HotCocoa pour rubyfier le tout
  • 24. MacRuby Laurent Sansonetti (Apple) Vincent Isambart Kich Kilmer Eloy Duran Ben Stiglitz Matt Aimonetti ... http://www.macruby.org http://twitter.com/macruby
  • 25. En toute simplicité... • La meilleure plateforme pour les devs Ruby • Une plateforme de qualité pour les devs Cocoa
  • 26. Bridge, quel bridge ? $ macirb >> s = "osdc" => "osdc" >> s.class => NSMutableString >> s.class.ancestors => [NSMutableString, NSString, Comparable, NSObject, Kernel] >> s.upcase => "OSDC" >> s.uppercaseString => "OSDC" >> s.respondsToSelector(:upcase) => 1 >> s.respond_to?(:upcase) => true
  • 27. Bridge, quel bridge ? • Une classe Ruby est une classe Obj-C • Une méthode Ruby est une méthode Obj-C • Une instance Ruby est une instance Obj-C
  • 28. Syntaxe Objective-C Person *person = [Person new]; [person name]; [person setName:name]; [person setFirstName:first lastName:last]; MacRuby person = Person.new person.name person.name = myName person.setFirstName(first, lastName:last)
  • 29. HotCocoa require ‘hotcocoa’ include HotCocoa application do win = window :title => ‘hello OSDC’, :frame => [0, 0, 200, 60] b = button :title => ‘Hello!’, :layout => {:align => :center} win << b b.on_action { puts “Hello OSDC!” } end
  • 30. Ruby 1.9 Parseur Runtime Built-in classes YARV GC Stdlib
  • 31. MacRuby Runtime Parseur Stdlib LLVM/Roxor libobjc Built-in Classes AOT JIT libauto CoreFoundation
  • 32. MacRuby 0.4 - 04/09 • Intégration XCode • Embedding / Runtime Control • HotCocoa • Threaded GC
  • 33. MacRuby 0.5 - xx/09 • YARV ? LLVM ! • RubySpec • AOT • GrandCentral • ...
  • 36. Tout le monde adore les microbenchmarks (surtout s’ils sont menteurs et non significatifs)
  • 37. C static int fib(int n) { if (n < 3) { return 1; } else { return fib(n - 1) + fib(n - 2); } }
  • 38. Objective-C @implementation Fib - (int)fib:(int)n { if (n < 3) { return 1; } else { return [self fib:n - 1] + [self fib:n - 2]; } } @end
  • 39. 4 3 temps d’exécution (s) 2 1 0 fib(40) C Objective-C
  • 40. Ruby def fib(n) if n < 3 1 else fib(n-1) + fib(n-2) end end p fib(ARGV.join("").to_i)
  • 41. 4 3 temps d’exécution (s) 2 1 0 fib(40) C MacRuby Objective-C
  • 42. MRI Ruby 1.8 $ ruby fibo.rb 40 102334155 MacRuby $ macruby fibo.rb 40 102334155 MacRuby AOT $ macrubyc fibo.rb -o fibo $ ./fibo 40 102334155
  • 43. Grand Central # A GCD-based implementation of the sleeping barber problem: # http://en.wikipedia.org/wiki/Sleeping_barber_problem # http://www.madebysofa.com/#blog/the_sleeping_barber waiting_chairs = Dispatch::Queue.new('com.apple.waiting_chairs') semaphore = Dispatch::Semaphore.new(3) index = -1 while true index += 1 success = semaphore.wait(Dispatch::TIME_NOW) if success != 0 puts "Customer turned away #{index}" next end waiting_chairs.dispatch do semaphore.signal puts "Shave and a haircut #{index}" end end
  • 45. Pourquoi MacRuby ? • Ruby pour développer des applications desktop “mac-like” • Un terrain d’expérimentation formidable • Des perspectives ... intéressantes
  • 46. Q&A • Compatibilité Ruby 1.9 • Actuellement ≈ 80% sur la suite rubyspec • Portabilité sur d’autres plateformes • Dépendances FLOSS, aucun obstacle technique insurmontable... • ... des volontaires ?