PDA

View Full Version : Cappuccino


maximile
2008.09.04, 09:05 PM
You might know about a web framework called Cappuccino (http://cappuccino.org/) which is pretty much Cocoa for the web - Objective-J and AppKit and most of the important (and relevant) classes. I didn't pay much attention until recently, but you have to check out the Hello World tutorial (http://cappuccino.org/learn/tutorials/starter-tutorial.php) if you haven't already - it's almost completely compatible with Objective-C. I didn't realise how similar it could be.

It works on all major browsers. For a demo of how it could be applied to a game, check out the Puzzle (http://cappuccino.org/learn/demos/puzzle/). And to see how complex it can get, have a look at 280 Slides (http://280slides.com/).

This won't interest everybody, but it's just made the web a thousand times easier for Objective-C developers to get into, and I know there are more than a few here.

Edit: Here, look at some source:

import <Foundation/CPObject.j>


@implementation AppController : CPObject
{
}

- (void)applicationDidFinishLaunching:(CPNotificatio n)aNotification
{
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];

var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];

[label setStringValue:@"Hello World!"];
[label setFont:[CPFont boldSystemFontOfSize:24.0]];

[label sizeToFit];

[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
[label setFrameOrigin:CGPointMake((CGRectGetWidth([contentView bounds]) - CGRectGetWidth([label frame])) / 2.0, (CGRectGetHeight([contentView bounds]) - CGRectGetHeight([label frame])) / 2.0)];

[contentView addSubview:label];

[theWindow orderFront:self];

// Uncomment the following line to turn on the standard menu bar.
//[CPMenu setMenuBarVisible:YES];
}

@end

Feels pretty comfortable.

Cochrane
2008.09.05, 07:13 AM
I've heard about it and I like the idea, but I can't help but feel that this is a little (or more like very) weird. Yes, it feels comfortable if you already know Cocoa, but I'm not sure whether Cocoa programming is actually the best way to go on the web. V8 nonwithstanding, there's a lot of overhead in having an additional preprocessing step before the script can be executed*. Whether all that Objective-C syntax is really needed for the few things that it has that Javascript doesn't, I don't know. I'm also not convinced that Cocoa without nibs is really the most comfortable way to do web application development.

Still, it is a cool idea, and I'll certainly try it out. I'm just not convinced it was really necessary.

*) I know I can preprocess it on my computer before uploading, but it's an additional step either way.

Blacktiger
2008.09.06, 02:28 AM
I would definitely like to see some sort of nib file loading for Cappuccino, but this initial release looks sweet. If you are worried about the overhead of preprocessing your app, Cappuccino is supposed to have a build tool that will compile your app into straight javascript.

maximile
2008.09.06, 03:34 AM
An interface builder would be nice, that's true. And I hadn't considered Cocoa as a good model for the web before, but they make it pretty clear that it's for writing desktop-class web applications rather than web pages, so for me it begins to make sense.

Anyway, I'm looking forward to seeing who (if anyone) starts to use it.