MacRuby: Ruby For Your Mac
MacRuby: Ruby For Your Mac
Laurent Sansonetti
Ruby Ninja
lsansonetti@[Link]
こういうのを見てると「RubyでOS
Xで(or のために)作られたんじゃないだろ
うか」と感じてしまう
Source: [Link]
In 10-2006, Matz Said
Source: [Link]
In 10-2006, Matz Said
Not a Mac
Source: [Link]
Mac OS X Stack
Mac OS X Stack
User Experience
Application Frameworks
Darwin
RubyCocoa
• A bridge between C / Objective-C and Ruby 1.8
• Created in 2001 by FUJIMOTO Hisakuni
• Bundled and supported since Mac OS X 10.5
• Stable
Mac development with Ruby?
Mac development with Ruby?
Web development with Ruby?
Web development with Ruby?
Why?
• Cocoa is hard to apprehend for Ruby developers
• Ruby 1.8 and RubyCocoa have performance and design
issues to be used inside Cocoa
Why?
• Cocoa is hard to apprehend for Ruby developers
• Ruby 1.8 and RubyCocoa have performance and design
issues to be used inside Cocoa
RubyCocoa Hello World
RubyCocoa Hello World
require 'osx/cocoa'; include OSX
app = [Link]
win = [Link].initWithContentRect_styleMask_backing_defer(
[0, 0, 200, 60],
NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask,
NSBackingStoreBuffered,
false)
[Link] = 'Hello World'
button = [Link](NSZeroRect)
[Link](button)
[Link] = NSRoundedBezelStyle
[Link] = 'Hello!'
[Link]
[Link] = NSMakePoint(([Link] / 2.0) - ([Link] / 2.0),
([Link] / 2.0) - ([Link] / 2.0))
button_controller = [Link]
def button_controller.sayHello(sender)
puts "Hello World!"
end
[Link] = button_controller
[Link] = 'sayHello:'
[Link]
[Link]
[Link]
Why?
• Cocoa is hard to apprehend for Ruby developers
• Ruby 1.8 and RubyCocoa have performance and design
issues to be used inside Cocoa
Problem #1
It’s a bridge!
Problem #2
これが成功すればRubyは名実
ともにOSXの公式スクリプト言語とし
て定着するに違いない
Text
Source: [Link]
In 02-2008, Matz Said
If this (MacRuby)
succeeds, there is no doubt Ruby
will establish itself, both in name and in
reality, as the official scripting
language for OS X.
Text
Source: [Link]
In 02-2008, Matz Said
Still the same look
If this (MacRuby)
succeeds, there is no doubt Ruby
will establish itself, both in name and in
reality, as the official scripting
language for OS X.
Text
Source: [Link]
MRI 1.9
MRI 1.9
Parser
Stdlib
YARV
Builtin Classes
Runtime
MacRuby (Today)
Parser
Stdlib
YARV
Builtin Classes
Runtime
MacRuby (Today)
HotCocoa
Parser
Stdlib
YARV
Builtin Classes
Runtime CoreFoundation
libobjc libauto
Demos
app = [Link]
win = [Link].initWithContentRect_styleMask_backing_defer(
[0, 0, 200, 60],
NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask,
NSBackingStoreBuffered,
false)
[Link] = 'Hello World'
button = [Link](NSZeroRect)
[Link](button)
[Link] = NSRoundedBezelStyle
[Link] = 'Hello!'
[Link]
[Link] = NSMakePoint(([Link] / 2.0) - ([Link] / 2.0),
([Link] / 2.0) - ([Link] / 2.0))
button_controller = [Link]
def button_controller.sayHello(sender)
puts "Hello World!"
end
[Link] = button_controller
[Link] = 'sayHello:'
[Link]
[Link]
[Link]
MacRuby Hello World
framework 'Cocoa'
app = [Link]
button = [Link](NSZeroRect)
[Link](button)
[Link] = NSRoundedBezelStyle
[Link] = 'Hello!'
[Link]
[Link] = NSMakePoint(([Link] / 2.0) - ([Link] / 2.0),
([Link] / 2.0) - ([Link] / 2.0))
button_controller = [Link]
def button_controller.sayHello(sender)
puts "Hello World!"
end
[Link] = button_controller
[Link] = 'sayHello:'
[Link]
[Link]
[Link]
HotCocoa Hello World
HotCocoa Hello World
require 'hotcocoa'
include HotCocoa
application do
w = window :title => 'Hello World', :frame => [0, 0, 120, 120]
b = button :title => 'Click me'
b.on_action { puts 'Hello World!' }
w << b
end
MacRuby in the Future
• Multicore support
• JIT compilation
• OSA+AppleEvent
In 2010, maybe...
Room 3
OS X Application Development with HotCocoa Tomorrow 5:15PM
Laurent Sansonetti
Ruby Ninja
lsansonetti@[Link]