Introduction à MacRuby

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 - 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 MacRuby iCal, iSync, [...] co-founder Lurker actif Server Software
    3. Breaking News ! MacRuby developer attacked by raptors
    4. Text Text
    5. Text Text
    6. MacRuby
    7. Mac OS X Applications Application Frameworks Cocoa, WebKit, ... Core Technologies CoreGraphics, CoreFoundation, ... Darwin Kernel, userland, libdispatch, ...
    8. 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
    9. 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 ?
    10. Une affaire de famille SmallTalk Objective-C Ruby
    11. Ecrire une “vraie” appli Mac en Ruby ? GitNub
    12. RubyCocoa • Un vrai bridge (Fujimoto Hisakuni, 2001) • Syntaxe... intéressante • Ruby 1.8 • Green threads, non réentrant • Deux runtimes, deux GC • Ouch
    13. 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
    14. Facile. (si on connait Objective-C, Cocoa, Ruby, et les dragons qui se cachent dans les recoins du bridge)
    15. MacRuby
    16. MacRuby • One GC to release them all
    17. MacRuby • One GC to release them all • One runtime to bind them
    18. MacRuby • One GC to release them all • One runtime to bind them • In the land of Cocoa where Obj-C lie
    19. 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
    20. MacRuby Laurent Sansonetti (Apple) Vincent Isambart Kich Kilmer Eloy Duran Ben Stiglitz Matt Aimonetti ... http://www.macruby.org http://twitter.com/macruby
    21. En toute simplicité... • La meilleure plateforme pour les devs Ruby • Une plateforme de qualité pour les devs Cocoa
    22. 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
    23. 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
    24. 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)
    25. 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
    26. Ruby 1.9 Parseur Runtime Built-in classes YARV GC Stdlib
    27. MacRuby Runtime Parseur Stdlib LLVM/Roxor libobjc Built-in Classes AOT JIT libauto CoreFoundation
    28. MacRuby 0.4 - 04/09 • Intégration XCode • Embedding / Runtime Control • HotCocoa • Threaded GC
    29. MacRuby 0.5 - xx/09 • YARV ? LLVM ! • RubySpec • AOT • GrandCentral • ...
    30. Pourquoi LLVM ?
    31. Coolest Logo Ever
    32. Tout le monde adore les microbenchmarks (surtout s’ils sont menteurs et non significatifs)
    33. C static int fib(int n) { if (n < 3) { return 1; } else { return fib(n - 1) + fib(n - 2); } }
    34. Objective-C @implementation Fib - (int)fib:(int)n { if (n < 3) { return 1; } else { return [self fib:n - 1] + [self fib:n - 2]; } } @end
    35. 4 3 temps d’exécution (s) 2 1 0 fib(40) C Objective-C
    36. Ruby def fib(n) if n < 3 1 else fib(n-1) + fib(n-2) end end p fib(ARGV.join("").to_i)
    37. 4 3 temps d’exécution (s) 2 1 0 fib(40) C MacRuby Objective-C
    38. 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
    39. 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
    40. Le bonheur ?
    41. Pourquoi MacRuby ? • Ruby pour développer des applications desktop “mac-like” • Un terrain d’expérimentation formidable • Des perspectives ... intéressantes
    42. 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 ?
    43. Merci !
    SlideShare Zeitgeist 2009

    + Olivier GutknechtOlivier Gutknecht Nominate

    custom

    263 views, 0 favs, 1 embeds more stats

    Une courte introduction à MacRuby, présentation 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 263
      • 221 on SlideShare
      • 42 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 1
    Most viewed embeds
    • 42 views on http://people.no-distance.net

    more

    All embeds
    • 42 views on http://people.no-distance.net

    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