How Transmission Does Cross-Platform
John Gruber went out of his way to mention that Transmission is a cross-platform app which is actually very good on the Mac. In other words, it feels like it was designed for the platform. I was curious about this, so I looked at the source. I found a pleasant surprise.Transmission doesn't just give the appearance of being a good Mac app, it actually is. There's real, solid Cocoa goodness here. Based on a quick survey of the project (so don't hold me to the details), it looks like the developers did this by separating the core application logic out into a library called libtransmission, which I assume is shared across the different platforms.
The Mac application project imports libtransmission and uses Objective-C's natural integration with ansi C to layer a Mac UI on top of the core library. The Torrent Objective-C class wraps the low-level C structs, acting as a bridge for the data model.
For example, the -checkForFiles: implementation calls tr_torrentGetFileDL() with the tr_torrent struct as an argument (edited slightly for formatting here):
- (int) checkForFiles: (NSIndexSet *) indexSet
{
BOOL onState = NO;
BOOL offState = NO;
int index;
for ( index = [indexSet firstIndex];
index != NSNotFound;
index = [indexSet indexGreaterThanIndex: index] )
{
if (tr_torrentGetFileDL(fHandle, index)
|| ![self canChangeDownloadCheckForFile: index])
onState = YES;
else
offState = YES;
if (onState && offState)
return NSMixedState;
}
return onState ? NSOnState : NSOffState;
}
(I believe I'm allowed to post snippets without inclding the entire copyright, but this chunk of code is essentially under an MIT license. See the project for details.)
As if the concept wasn't enough, even the actual code for Transmission is beautiful. Very well written and easy to understand. It even has a great icon. If you're wondering how to go about writing a cross-platform app that takes advange of all the Mac has to offer, this is a working model of how to do it. All of this in a 2.5MB download.
Also interesting is that the project is covered under two separate open source licenses, thanks to a special exemption.
How Transmission Does Cross-Platform
Posted Jan 31, 2008 — 17 comments below
Posted Jan 31, 2008 — 17 comments below
ACoolie — Jan 31, 08 5423
Oh and you can post snippets of MIT source code.
Kevin Ballard — Jan 31, 08 5424
Chris — Jan 31, 08 5425
Dirk Stoop — Jan 31, 08 5426
Funny coincidence that both are open source projects. Does anyone know of a closed-source app other than those in the huge suites (Office, Creative Suite) that has a proper Mac UI?
Jeff Greene — Feb 01, 08 5427
Transmission is really wonderful lightweight, yet powerful BitTorrent client. It just keeps getting better with each new version.
Jeff Greene — Feb 01, 08 5428
Does anyone know of a closed-source app other than those in the huge suites (Office, Creative Suite) that has a proper Mac UI?
Commercial software tends to be either originally developed for Windows and ported to Mac OS X using Carbon, or written to be cross-platform from the start. Usually the latter is written in Java. Mac OS X with Cocoa offers many unique features that are available solely for Mac OS X. It is hard to write a native Mac OS X application without writing it from the ground-up.
The only cross-platform commercial software that is written in Cocoa that I can think of is Skype. Skype did something similar to Transmission and uses the Skype framework as the back-end to the native Cocoa application.
Scott Stevenson — Feb 01, 08 5429
Does World of Warcraft count? Anyway, it looks like Quicken is heading that way.
Rob Keniger — Feb 01, 08 5430
It would seem to be straightforward to make the UI platform-specific and the underlying image processing code cross-platform. That way you'd have an app that looks and works great on Mac and Windows, the platform-specific teams could make use of platform-specific niceties and yet the application itself would be the same underneath. It's not like Adobe and Microsoft don't have enough programmers to be able to do this.
I did notice that Adobe Lightroom has a Cocoa wrapper around Lua guts and so obviously some parts of the company are moving this way.
George Sudarkoff — Feb 01, 08 5431
VMware Fusion has a proper Cocoa UI. Skype on the other hand is written with QT.
Jussi — Feb 01, 08 5432
It's the only way to go if a good UI is a priority (and it usually should be). Cross platform toolkits usually make the UI look and feel non native on *all* platforms.
Sure making the UI natively on all platforms may seem like a waste of developer resources and money, but I would argue it is not. Even with cross platform toolkits serious tweaking is needed if good UI is needed and the UI is the most important thing for the user and will increase sales
Fabio Mancinelli — Feb 01, 08 5434
The model il the internet and the BitTorrent "space". The controller is the libtorrent and the view is the UI (for Mac, Win, Linux, Whatever)
Not an easy thing to do though! :)
So kudos for the great design.
jjgod — Feb 01, 08 5435
j o a r — Feb 01, 08 5436
Vincent Murphy — Feb 01, 08 5437
Jeff Greene — Feb 01, 08 5438
The Mac OS X version of Skype is written in Cocoa, however you are right that Skype is written in Qt if you are talking about the Linux version.
Erik — Feb 02, 08 5440
Erik — Feb 02, 08 5441