Introduction à MacRuby - OSDC.fr 2009

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Introduction à MacRuby - OSDC.fr 2009 - Presentation Transcript

    1. Une courte introduction à MacRuby Objective-C, Cocoa, LLVM, Grand Central et autres amusements Olivier Gutknecht - OSDC.fr - Oct. 3 2009
    2. Olivier Gutknecht olg@no-distance.net twitter : olg
    3. Olivier Gutknecht olg@no-distance.net twitter : olg iCal, iSync, [...]
    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
    7. Text Text
    8. Text Text
    9. MacRuby
    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. 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
    17. Facile. (si on connait Objective-C, Cocoa, Ruby, et les dragons qui se cachent dans les recoins du bridge)
    18. MacRuby
    19. MacRuby • One GC to release them all
    20. MacRuby • One GC to release them all • One runtime to bind them
    21. MacRuby • One GC to release them all • One runtime to bind them • In the land of Cocoa where Obj-C lie
    22. 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
    23. MacRuby Laurent Sansonetti (Apple) Vincent Isambart Kich Kilmer Eloy Duran Ben Stiglitz Matt Aimonetti ... http://www.macruby.org http://twitter.com/macruby
    24. En toute simplicité... • La meilleure plateforme pour les devs Ruby • Une plateforme de qualité pour les devs Cocoa
    25. 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
    26. 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
    27. 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)
    28. 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
    29. Ruby 1.9 Parseur Runtime Built-in classes YARV GC Stdlib
    30. MacRuby Runtime Parseur Stdlib LLVM/Roxor libobjc Built-in Classes AOT JIT libauto CoreFoundation
    31. MacRuby 0.4 - 04/09 • Intégration XCode • Embedding / Runtime Control • HotCocoa • Threaded GC
    32. MacRuby 0.5 - xx/09 • YARV ? LLVM ! • RubySpec • AOT • GrandCentral • ...
    33. Pourquoi LLVM ?
    34. Coolest Logo Ever
    35. Tout le monde adore les microbenchmarks (surtout s’ils sont menteurs et non significatifs)
    36. C static int fib(int n) { if (n < 3) { return 1; } else { return fib(n - 1) + fib(n - 2); } }
    37. Objective-C @implementation Fib - (int)fib:(int)n { if (n < 3) { return 1; } else { return [self fib:n - 1] + [self fib:n - 2]; } } @end
    38. 4 3 temps d’exécution (s) 2 1 0 fib(40) C Objective-C
    39. Ruby def fib(n) if n < 3 1 else fib(n-1) + fib(n-2) end end p fib(ARGV.join("").to_i)
    40. 4 3 temps d’exécution (s) 2 1 0 fib(40) C MacRuby Objective-C
    41. 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
    42. 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
    43. Le bonheur ?
    44. Pourquoi MacRuby ? • Ruby pour développer des applications desktop “mac-like” • Un terrain d’expérimentation formidable • Des perspectives ... intéressantes
    45. 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 ?
    46. Merci !
    SlideShare Zeitgeist 2009

    + guest60b8020bguest60b8020b Nominate

    custom

    72 views, 0 favs, 0 embeds more stats

    Une courte introduction à MacRuby lors d'OSDC.fr d more

    More info about this document

    CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

    Go to text version

    • Total Views 72
      • 72 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 1
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories