InfoQ

News

Ruby on Mac OS X Leopard with DTrace, XCode and Interface Builder support

Posted by Werner Schuster on Oct 26, 2007 10:00 AM

Community
Ruby
Topics
Technology,
Dynamic Languages,
Operating Systems
Tags
DTrace,
Apple
The long awaited Mac OS X Leopard is released today, and it ships with support for Ruby development - quite extensive support. The MacOS forge Wiki lists the new Ruby features of Leopard
Ruby itself was upgraded to 1.8.6 p36, which was the latest stable release that we could grab. We additionally merged patches for important bugs that were discovered after p36, but could not be part of an official Ruby patch release at that time (they actually were, but after our deadline).
[..]
The Ruby libruby.1.dylib library, which contains the core of the interpreter, is available as a 4-way fat universal binary, for the ppc, i386, ppc64 and x86_64 architectures. You can therefore embed Ruby in a 64-bit application. All C extensions are also available for both 32-bit and 64-bit architectures, except Tk which cannot go 64-bit. The Ruby interpreter launcher, /usr/bin/ruby, was therefore left 32-bit only to not break scripts that use the Tk extension, or any other 32-bit only dependency.
Ruby C extensions will by default compile 2-way fat, for ppc and i386. You can set the ARCHFLAGS environment variable to configure the build of an extension, if for example it links against a non-universal library (like the mysql.com binaries which are delivered per processor architecture).

Next to all these details, an interesting addition to the Ruby interpreter is support for DTrace static probes. DTrace was originally developed by Sun for Solaris, but is now being ported to other Unix versions as well. It allows to do low-overhead tracing and profiling of applications and even Operating System code. The Mac OS X Ruby interpreter includes these probes:

Probes

The probes that are currently in Ruby-DTrace

Probe name Description
function-entry Probe that fires when a Ruby method is entered
function-return Probe that fires when a Ruby method returns
raise Probe that fires when a Ruby exception is raised
rescue Probe that fires when a Ruby exception is rescued
line Probe that fires for every line of Ruby executed
gc-begin Probe that fires right before a GC cycle begins
gc-end Probe that fires right after a GC cycle finishes
object-create-start Probe that fires directly before a Ruby object is allocated
object-create-done Probe that fires when Ruby is finished allocating an object
object-free Probe that fires every time a Ruby object is freed
ruby-probe Probe that can be fired from Ruby code (see below)
These were ported from Joyents Ruby DTrace project. Mac OS X Leopard also includes a tool called Instrument, which allows to visualize tracing and profiling events.

Apple also included Ruby support for XCode and the GUI Builder Interface Builder:
Xcode in Leopard comes with the RubyCocoa project templates, but also with a template to generate a Test/Unit target. Xcode also supports better Ruby auto-completion, driven by the BridgeSupport mechanism.
Interface Builder now officially supports Ruby. For example, you can write a Ruby class in Xcode, with outlets and/or actions, and everything will automatically appears in IB. IB uses RubyCocoa's rb_nibtool utility to synchronize the metadata. On the other way, you can manually define outlets and/or actions in IB, drag-and-drop them in an Xcode Ruby file, and the corresponding Ruby code will be pasted in it.
Mac OS X Leopard also includes a new framework called Scripting Bridge which allows to script applications. Ruby is also supported:
ScriptingBridge is a new Leopard framework that provides access to the AppleEvent infrastructure, on which AppleScript is based. ScriptingBridge will dynamically generate an Objective-C interface that corresponds to the scriptable dictionary of a given application. You can then send messages and control this application from Objective-C.
Thanks to RubyCocoa, it is also possible to use ScriptingBridge from Ruby. Some scripting elements are not yet accessible though, like enumerations, but most of the functionality should be available.

No comments

Reply

Exclusive Content

Tapestry for Nonbelievers

A new article by I. Drobiazko and R. Zubairov introduces v. 5 of the Apache Tapestry component-oriented web framework. The tutorial shows how to create a component and covers IoC in Tapestry and Ajax.

Pete Lacey on REST and Web Services

In this interview, Burton Group consultant Pete Lacey talks to Stefan Tilkov about his disillusionment with SOAP, his opinion on REST, and addresses some of the perceived shortcomings REST vs. WS-*.

Business Natural Languages Development in Ruby

Jay Fields presents his concept of Business Natural Languages - a type of Domain Specific Languages geared towards being readable by domain experts.

Distributed Version Control Systems: A Not-So-Quick Guide Through

Adoption and interest for Distributed Version Control Systems is constantly rising. We will introduce the concept of DVCS and have a look at 3 actors in the area: git, Mercurial and Bazaar.

Segundo Velasquez and Agile as Seen Through the Customer's Eyes

Deborah Hartmann interviewed Segundo Velasquez about his experience as customer with an Agile team during the initial phase of software design of a product.

Fine Grained Versioning with ClickOnce

David Cooksey shows how to fine grained versioning to a ClickOnce deployment using an HttpHandler written with ASP.NET, making partial rollouts to a test audience much easier.

Implementing Manual Activities in Windows Workflow

Windows workflow (WF) is an excellent framework for implementing business processes, but lacks support for human activities. This article describes a completely generic approach for changing this.

Markus Voelter about Software Architecture Documentation

In this interview taken during OOPSLA 2007, Markus Voelter talks about the importance of documenting the software architecture, and gives some good and also bad examples on how it could be done.