SlideShare uma empresa Scribd logo
1 de 43
A quick introduction to


                           MacRuby          Objective-C, Cocoa, LLVM, Grand Central
                                                       and other musings




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




                                         MacRuby


  iCal, iSync, [...]     co-founder      Active lurker
                       Server Software
Breaking News !

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

  Applications


  Application
  Frameworks
                    Cocoa, WebKit, ...


Core Technologies   CoreGraphics, CoreFoundation, ...


     Darwin         Kernel, userland, libdispatch, ...
Ruby on 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 on OS X
• Ruby, just on another unix platform
• With some small improvements...
  e.g. mongrel_rails_persists on OS X Server
  launchd / bonjour integration


• What about Cocoa ?
Family business

         SmallTalk


Objective-C     Ruby
A “true” OS X App in
       Ruby ?




    Sure. Check out Gitnub
RubyCocoa
• A ruby-objc bridge
  (FUJIMOTO Hisakuni, 2001)
• Ruby 1.8
• Green threads, no reentrance
• Two runtimes, two GC
• ... interesting syntax
• 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
Easy.
(when you’re proficient in Objective-C, Cocoa, Ruby and the bridge - here be dragons)
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
      Laurent Sansonetti
           (Apple)
          Vincent Isambart
            Kich Kilmer
             Eloy Duran
             Ben Stiglitz
           Matt Aimonetti
                  ...

       http://www.macruby.org
      http://twitter.com/macruby
Modest goals


• The best platform for Ruby developers
• A great platform for Cocoa developers
Bridge, what 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, what bridge ?

• A Ruby class is an Objective-C class
• A Ruby method is an Objective-C method
• A Ruby instance is an Objective-C instance
Syntax
                                             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



       A thin layer by Rich Kilmer, providing a natural
         ruby experience when coding Cocoa apps
Ruby 1.9


Parser     Runtime   Built-in classes

YARV        GC           Stdlib
MacRuby

               Runtime
  Parser                      Stdlib

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

•   XCode integration

•   Embedding / Runtime
    Control

•   HotCocoa

•   Threaded GC
MacRuby 0.5 - xx/09

•   YARV ? LLVM !

•   RubySpec

•   AOT

•   GrandCentral

•   ...
Why LLVM ?
Coolest Logo Ever
Everybody loves
 microbenchmarks
(lies, damn lies and benchmarks)



                            From a bench by Patrick Thomson @ C4
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
execution time (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
execution time (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
Tools Galore

    ?
Why MacRuby ?

• Ruby for “mac-like” desktop applications
• A wonderful experimentation playground
• ... Interesting perspectives
Q&A

• Ruby 1.9 compatibility
 • Right now, ≈ 80% on rubyspec
• Other platforms, portability
 • No closed-source dependancies, no
    definitive technical blocker
 • ... Any takers ?
Thanks!

Mais conteúdo relacionado

Mais procurados

Autovectorization in llvm
Autovectorization in llvmAutovectorization in llvm
Autovectorization in llvmChangWoo Min
 
[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent Programming[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent ProgrammingTobias Lindaaker
 
Ruby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3xRuby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3xMatthew Gaudet
 
XRuby_Overview_20070831
XRuby_Overview_20070831XRuby_Overview_20070831
XRuby_Overview_20070831dreamhead
 
Vc4c development of opencl compiler for videocore4
Vc4c  development of opencl compiler for videocore4Vc4c  development of opencl compiler for videocore4
Vc4c development of opencl compiler for videocore4nomaddo
 
Swift after one week of coding
Swift after one week of codingSwift after one week of coding
Swift after one week of codingSwiftWro
 
TRICK2013 Results
TRICK2013 ResultsTRICK2013 Results
TRICK2013 Resultsmametter
 
Grow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackGrow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackKeitaSugiyama1
 
To Swift 2...and Beyond!
To Swift 2...and Beyond!To Swift 2...and Beyond!
To Swift 2...and Beyond!Scott Gardner
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoaThilo Utke
 
LLJVM: LLVM bitcode to JVM bytecode
LLJVM: LLVM bitcode to JVM bytecodeLLJVM: LLVM bitcode to JVM bytecode
LLJVM: LLVM bitcode to JVM bytecodeTakeshi Yamamuro
 
C++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime NumbersC++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime NumbersAdam Feldscher
 
tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02Hiroshi SHIBATA
 
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014PyData
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the worldHiroshi SHIBATA
 
Using timed-release cryptography to mitigate the preservation risk of embargo...
Using timed-release cryptography to mitigate the preservation risk of embargo...Using timed-release cryptography to mitigate the preservation risk of embargo...
Using timed-release cryptography to mitigate the preservation risk of embargo...Michael Nelson
 
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...Stefan Marr
 

Mais procurados (20)

Autovectorization in llvm
Autovectorization in llvmAutovectorization in llvm
Autovectorization in llvm
 
[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent Programming[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent Programming
 
Ruby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3xRuby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3x
 
XRuby_Overview_20070831
XRuby_Overview_20070831XRuby_Overview_20070831
XRuby_Overview_20070831
 
Vc4c development of opencl compiler for videocore4
Vc4c  development of opencl compiler for videocore4Vc4c  development of opencl compiler for videocore4
Vc4c development of opencl compiler for videocore4
 
Introduction to .NET
Introduction to .NETIntroduction to .NET
Introduction to .NET
 
Swift after one week of coding
Swift after one week of codingSwift after one week of coding
Swift after one week of coding
 
TRICK2013 Results
TRICK2013 ResultsTRICK2013 Results
TRICK2013 Results
 
Grow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackGrow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM Stack
 
To Swift 2...and Beyond!
To Swift 2...and Beyond!To Swift 2...and Beyond!
To Swift 2...and Beyond!
 
MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoa
 
Openstack 簡介
Openstack 簡介Openstack 簡介
Openstack 簡介
 
LLJVM: LLVM bitcode to JVM bytecode
LLJVM: LLVM bitcode to JVM bytecodeLLJVM: LLVM bitcode to JVM bytecode
LLJVM: LLVM bitcode to JVM bytecode
 
C++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime NumbersC++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime Numbers
 
tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02
 
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
Pythran: Static compiler for high performance by Mehdi Amini PyData SV 2014
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the world
 
Using timed-release cryptography to mitigate the preservation risk of embargo...
Using timed-release cryptography to mitigate the preservation risk of embargo...Using timed-release cryptography to mitigate the preservation risk of embargo...
Using timed-release cryptography to mitigate the preservation risk of embargo...
 
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
 
Advanced cocos2d
Advanced cocos2dAdvanced cocos2d
Advanced cocos2d
 

Semelhante a MacRuby, an introduction

Mac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimMac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimThoughtWorks
 
MacRuby to The Max
MacRuby to The MaxMacRuby to The Max
MacRuby to The MaxBrendan Lim
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deploymentThilo Utke
 
Macruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMacruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMatt Aimonetti
 
GUI Programming with MacRuby
GUI Programming with MacRubyGUI Programming with MacRuby
GUI Programming with MacRubyErik Berlin
 
Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets CocoaRobbert
 
MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012Mark Villacampa
 
Objective-Cひとめぐり
Objective-CひとめぐりObjective-Cひとめぐり
Objective-CひとめぐりKenji Kinukawa
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsUsing Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsSerge Stinckwich
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012rivierarb
 
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Yandex
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?Joshua Ballanco
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Dirkjan Bussink
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVMJung Kim
 

Semelhante a MacRuby, an introduction (20)

Why MacRuby Matters
Why MacRuby MattersWhy MacRuby Matters
Why MacRuby Matters
 
Mac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimMac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. Lim
 
MacRuby to The Max
MacRuby to The MaxMacRuby to The Max
MacRuby to The Max
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deployment
 
Macruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich KilmerMacruby& Hotcocoa presentation by Rich Kilmer
Macruby& Hotcocoa presentation by Rich Kilmer
 
GUI Programming with MacRuby
GUI Programming with MacRubyGUI Programming with MacRuby
GUI Programming with MacRuby
 
Ruby Meets Cocoa
Ruby Meets CocoaRuby Meets Cocoa
Ruby Meets Cocoa
 
Macruby intro
Macruby introMacruby intro
Macruby intro
 
MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012MacRuby & RubyMotion - Madridrb May 2012
MacRuby & RubyMotion - Madridrb May 2012
 
RubyMotion
RubyMotionRubyMotion
RubyMotion
 
Objective-Cひとめぐり
Objective-CひとめぐりObjective-Cひとめぐり
Objective-Cひとめぐり
 
ruby-cocoa
ruby-cocoaruby-cocoa
ruby-cocoa
 
ruby-cocoa
ruby-cocoaruby-cocoa
ruby-cocoa
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsUsing Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systems
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
 
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
 

Último

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Último (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

MacRuby, an introduction

  • 1. A quick introduction to MacRuby Objective-C, Cocoa, LLVM, Grand Central and other musings Olivier Gutknecht - OSDC.fr - Oct. 3 2009
  • 2. Olivier Gutknecht olg@no-distance.net twitter : olg MacRuby iCal, iSync, [...] co-founder Active lurker Server Software
  • 3. Breaking News ! MacRuby developer attacked by raptors
  • 7. Mac OS X Stack Applications Application Frameworks Cocoa, WebKit, ... Core Technologies CoreGraphics, CoreFoundation, ... Darwin Kernel, userland, libdispatch, ...
  • 8. Ruby on 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 on OS X • Ruby, just on another unix platform • With some small improvements... e.g. mongrel_rails_persists on OS X Server launchd / bonjour integration • What about Cocoa ?
  • 10. Family business SmallTalk Objective-C Ruby
  • 11. A “true” OS X App in Ruby ? Sure. Check out Gitnub
  • 12. RubyCocoa • A ruby-objc bridge (FUJIMOTO Hisakuni, 2001) • Ruby 1.8 • Green threads, no reentrance • Two runtimes, two GC • ... interesting syntax • Ouch
  • 13.
  • 14. 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
  • 15. Easy. (when you’re proficient in Objective-C, Cocoa, Ruby and the bridge - here be dragons)
  • 17. MacRuby • One GC to release them all
  • 18. MacRuby • One GC to release them all • One runtime to bind them
  • 19. MacRuby • One GC to release them all • One runtime to bind them • In the land of Cocoa where Obj-C lie
  • 20. MacRuby Laurent Sansonetti (Apple) Vincent Isambart Kich Kilmer Eloy Duran Ben Stiglitz Matt Aimonetti ... http://www.macruby.org http://twitter.com/macruby
  • 21. Modest goals • The best platform for Ruby developers • A great platform for Cocoa developers
  • 22. Bridge, what 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, what bridge ? • A Ruby class is an Objective-C class • A Ruby method is an Objective-C method • A Ruby instance is an Objective-C instance
  • 24. Syntax 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 A thin layer by Rich Kilmer, providing a natural ruby experience when coding Cocoa apps
  • 26. Ruby 1.9 Parser Runtime Built-in classes YARV GC Stdlib
  • 27. MacRuby Runtime Parser Stdlib LLVM/Roxor libobjc Built-in Classes AOT JIT libauto CoreFoundation
  • 28. MacRuby 0.4 - 04/09 • XCode integration • Embedding / Runtime Control • HotCocoa • Threaded GC
  • 29. MacRuby 0.5 - xx/09 • YARV ? LLVM ! • RubySpec • AOT • GrandCentral • ...
  • 32. Everybody loves microbenchmarks (lies, damn lies and benchmarks) From a bench by Patrick Thomson @ C4
  • 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 execution time (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 execution time (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
  • 41. Why MacRuby ? • Ruby for “mac-like” desktop applications • A wonderful experimentation playground • ... Interesting perspectives
  • 42. Q&A • Ruby 1.9 compatibility • Right now, ≈ 80% on rubyspec • Other platforms, portability • No closed-source dependancies, no definitive technical blocker • ... Any takers ?