GUI Programming with MacRuby
-
Upload
erik-michaels-ober -
Category
Documents
-
view
360 -
download
4
description
Transcript of GUI Programming with MacRuby
MacRubyGUI Programming with
GUI Programming with
MacRubyWho?
What?
When?
Where?
Why?
How?
Who?
Erik Michaels-Ober?
sferikon Twitter, GitHub, Gmail, IRC, &c.
Code for AmericaAPPLY WITHIN
I’ve committed to...rails
rails_admin
merb_admin
twurl
simple_oauth
oauth2
faraday
thor
multi_json
multi_xml
octokit
rvm
bunder
travis-ci
dummy_data
git-pulls
mlb
HubCap
Who else?
@lrz
@merbist
@rich_kilmer
@alloy
@vincentisambart
@macruby
@benstiglitz
@importantshock
@naixn
@watson1978
@Psychs
macruby-devel
What?
1. A complete implementation of Ruby 1.9
What
MacRuby
MacRuby apps Ruby apps
DEMO
1. A complete implementation of Ruby 1.9
2. Allows you to script existing Mac apps
3. Allows you to create new Mac apps
What
MacRuby
Let me tell you a secret...
AppleScript
Objective-C
object.method parameter
Ruby Method Invocation
Objective-C Method Invocation
[object method:parameter];
array = []
Ruby Array Initialization and Assignment
NSMutableArray *array = [[NSMutableArray alloc] init];
Objective-C Array Initialization and Assignment
RubyCocoa
require 'hotcocoa'include HotCocoa
application do |app| win = window :size => [100,50] b = button :title => 'Hello' b.on_action { puts 'World!' } win << bend
MacRuby Hello World
require 'osx/cocoa'include OSX
app = NSApplication.sharedApplicationwin = 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 = NSRoundedBezelStylebutton.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 World!"end
button.target = button_controllerbutton.action = 'sayHello:'win.displaywin.orderFrontRegardless
app.run
RubyCocoa Hello World
Java
Objective-J
When?
When
MacRuby
NOW!Version 0.10
Version 1.0 coming soon
MacRuby will be included with Mac OS X 10.7 Lion**currently as a private framework :(
When
MacRuby
Why?
Why
MacRuby
• You already know Ruby
• Use existing Ruby gems
• Ruby 1.9.2
• No GIL
• Multi-threaded generational GC
• Fast!
Performance Benchmarks
1
2
3
4
5
6
7
8
app_answer app_tarai so_object vm1_ivar_set vm2_proc vm2_zsuper
Ruby 1.9 MacRuby
Average Selling Price
$2.00
$4.00
$6.00
$8.00
$10.00
$12.00
iPhone iPad Mac
$11.21
$4.19
$1.57
How?
macruby.com
How
MacRuby
rvm get headrvm install macruby
How
MacRuby
brew install llvmport install llvm
How
MacRuby
How
MacRubyFree with ADC account at developer.apple.com/tools/xcodeor $4.99 on the Mac App Store
sferikon Twitter, GitHub, Gmail, IRC, &c.