PyObjc vs RubyCocoa for Mac development: Which is more mature?

。_饼干妹妹 提交于 2019-11-30 13:46:21
Barry Wark

I would echo Chris' assesment and will expand a bit on why you should learn Objective-C to learn Cocoa. As Chris says, Objective-C is the foundation and native language of Cocoa and many of its paradigms are inextricably linked with that lineage. In particular, selectors and dynamic message resolution and ability to modify classes at run time are required to implement Cocoa technologies such as Distributed Objects and bindings. Although these features are available in other dynamic languages such as Ruby and Python, there is enough of a mismatch in the language models that you will have to at least understand Objective-C to understand Cocoa. I suggest you take a look at this previous question for further discussion: Do I have to learn Objective-C for professional Mac Development?

Fortunately, Objective-C is very easy to learn. I often tell people it will take them a day to learn Objective-C coming from C/C++/Java or LISP, Scheme, or any of the 'newer' dynamic languages such as Ruby and Python. In addition to expanding your mind a bit, you'll learn to at least read the code that is used in virtually all of the Cocoa documentation and examples.

As for Ruby vs. Python, the bridge capabilities are very similar. In fact, they both use Apple's BridgeSupport (shipped with Leopard) to provide the bridge description. Both are supported by Apple and ship with Leopard. It's a matter of personal taste which language you prefer. If you choose Ruby, I suggest you give MacRuby a look. It's definitely the future of Ruby on OS X, as it reimplements the Ruby runtime on top of the Objective-C run time. This provides some nice performance and conceptual advantages (including integration with the Objective-C garbage collection system, a feature currently lacking in PyObjC which uses the native python gc). MacRuby also includes a custom parser that makes the syntax of bridged objective-c methods a little nicer. The downside of MacRuby is that it's not quite ready for production-level use at the time of this writing (June 2009). Since it sounds like this is a learning project for you, that's probably not an issue.

While you say you "don't have time" to learn technologies independently the fastest route to learning Cocoa will still be to learn it in its native language: Objective-C. Once you understand Objective-C and have gotten over the initial learning curve of the Cocoa frameworks you'll have a much easier time picking up either PyObjC or RubyCocoa.

Both are roughly equal, I'd say. Better in some places, worse in others. But I wouldn't recommend learning Cocoa with either. Like Chris said, Cocoa requires some understanding of Objective-C. I like Ruby better than Objective-C, but I still don't recommend using it to learn Cocoa. Once you have a solid foundation (no pun intended) in Cocoa/Objective-C, then the bridges can be useful to you.

Apple seems to be getting behind Ruby scripting for Cocoa but not RubyCocoa. They are hosting and I believe supporting MacRuby. I often wonder if MacRuby is Apple's answer to a higher level language for OSX prototyping and full on application development.

ObjectiveC is nowhere near as much fun or as productive as either Python or Ruby. That is why people want to pick a python or ruby with good Objective C access. Advising them to learn Objective C first misses the point imo. I have really good things to say about pyobjc. Its ability to interoperate painlessly with Objective C frameworks is superb. I have less experience with Ruby Cocoa and that was partly because when I last looked it didn't seem to have as clean and relatively painless interoperability. I feel hesitant about MacRuby because it seems to go too far. In pyobjc you can write plain python and only subclass/use Foundation and Cocoa objects when you really want/mean to. From what I understand of MacRuby it is a Ruby on top of Cocoa. So a string is always an NSString. I am less happy with that. YMMV.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!