开发者

Alternative paradigm for Mac OS X development

The current standard way of developing Mac OS X apps is with XCode开发者_如何学Go/Objective-C/Interface Builder using the MVC paradigm.

Is there an alternative?

I'd like to use Interface Builder (XCode too) however I would rather use a different programming language. I come from .NET programming where you can delegate a click to a certain function, etc.. Is there something like that for Mac? I would rather stay away from bootstrapped apps like Titanium or Qt or RealBASIC.


Objective-c is very powerful and together with Cocoa and Interface Builder allow you to develop UI on Mac OS X.

You can associate target in UI with action in code that gets executed and so on.

You can check out IB guide, connections and bindings and Introduction to Cocoa Application Tutorial which builds example application (check out the Bridging the Model and View: The Controller section for how UI elements get hooked up to code) - that is if you are interested in Objective-c/Cocoa.


You can already assign clicks to methods in Objective-C - you define a method with a return type of IBAction and you can wire that to a number of possible events in a button, or many other controls for that matter.

Learn to use the tools before you decide to wander off to other languages, because there is a lot of depth here from decades of evolution.


There are so many of these questions on SO. Especially in the mac/iphone tags. Someone posts asking how to make mac/iphone development more like some IDE/paradigm they already know.

Mac development is different from C#, .NET, etc. It is not less powerful, it's just different. Cocoa has many strengths which might not be apparent when you are trying to apply your old way of thinking.

Not to diss any of projects mentioned here (PyObjC, MacRuby, etc.) but they are going to be just as confusing, because they are a thin (and leaky) abstraction layer over the native developer tools.

If you're going to develop on the Mac, take some time and learn Objective-C/Cocoa/Xcode/IB. It's not the way you know, but it's a good way if you give it a chance. Once you know it you will have criticisms still, but you will also have undoubtedly found things you really like about it.

If you don't like to learn new platforms/paradigms/environments learn java or qt once and be done with it.


Depending on your language experience, and target requirements you might find MacRuby very interesting.

There is also PyObjC and a older ruby bridge named RubyCocoa.

However, if you're looking for iphone development, the only thing I've heard about is MonoTouch from Novell, and requires licensing fees.

Please note that all of the above techs allow pretty seamless integration with both their native language libraries as well as the libraries and frameworks found in Cocoa and Carbon.

Using these techs will give you a fairly clean native feeling app. However, many if not all will still require you to use Interface Builder. Which I know took me a while to get used to too.


There are lots of bridges. PyObjC, CamelBones (Perl), JSCocoa (JavaScript), Cocoa#, HOC (Haskell), etc. The only one that's really even close to seamless is MacRuby, a Ruby implementation on top of core Mac OS X technologies like LLVM and the Objective-C runtime and garbage collector that's designed to be a peer language to Objective-C for Cocoa development. It's still in beta, though. It does let you assign a Ruby block as the action handler for UI elements, which I gather is something you like doing.


It's hard to say whether you prefer elaboration on language or design patterns.

See Objective-C++, Python, or Ruby (the java bridge is deprecated). Remember that ObjC is a superset of C, you can use C, C++ and ObjC in the same app/sources. Soo... you may be most comfortable using Objective-C++. It sounds like a hybrid object, but it is merely support for the objects and syntaxes in the same program (i.e. you do not base a ObjC class on a C++ class, but you can use members). This is a big topic, actually, though I've never seen writings on it beyond a few pages.

As far as design patterns, well, you're the programmer :)


Your best bet, would be to use Cocoa Sharp support for winforms. There are some tutorials on the cocoasharp site. That would give you a head start, but I'm afraid you won't get very far with this approach, Cocoa is not really suited to that approach and in the end, code would end up difficult to manage.

What you can do, if you don't mind the Cocoa conventions but are not really into Objective-C, is to use Cocoa Sharp (i.e, C#) to code using Cocoa's MVC paradigm. That way, you still get to use Interface Builder (I'm not so sure of XCode support in Snow Leopard) and use a familiar language.

Looks like this approach is productive, as people are even doing iPhone applications that way.


Check out the mono project http://www.mono-project.com/Main_Page

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜