PyObjC / Ruby 桥。值得吗?

发布于 2024-10-04 08:32:55 字数 312 浏览 8 评论 0原文

几年前,我想编写 Mac 软件,并且拥有大量 Java WebObjects 经验,因此尝试了 java 桥,但决定硬着头皮学习 Objective-C(幸运的是,因为我讨厌我的软件因桥而被弃用)。后来我就玩弄了RubyCocoa。我学习了 Ruby(确实很有趣),但艰难地发现这个桥梁还远未成熟或稳定,最后我结束了将代码移植回 Objective-C。

几年过去了,我想知道是否值得花一些时间使用 MacRuby,甚至学习 Python 来使用 PyObjC。尽管我很喜欢 Objective-C,但我记得当 Ruby 桥没有崩溃时,它的工作效率会更高。我只是不想再投入时间去使用崩溃的软件。

Years ago wanting to write Mac software and having loads of experience with Java WebObjects I tried the java bridge but decided to bite the bullet and learn Objective-C (fortunately since I would have hated having my software deprecated with the bridge). Later I fooled around with RubyCocoa. I learnt Ruby (found it interesting indeed), but found out the hard way that the bridge was far from mature or stable and at the end I ended porting the code back to Objective-C.

Since years have passed, I'm wondering if it is worthwhile investing some time with MacRuby, or even learning Python to use PyObjC. As much as I like Objective-C, I recall being way more productive with the Ruby bridge when it didn't crash. I just would hate investing time to end up with crashy software again.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

誰ツ都不明白 2024-10-11 08:32:55

我想说,如果您想尝试其中一个桥梁,MacRuby 是您的最佳选择。它是由 Laurent Sansonetti 开发的,他是 Apple 负责 Ruby 的高级软件工程师。

它现在功能齐全,并且与本机框架很好地集成。值得一看,特别是如果您已经有 Ruby 经验的话。

I would say MacRuby is the way to go if you want to try one of the bridges. It's being developed by Laurent Sansonetti, who's a Senior Software Engineer at Apple working on Ruby.

It's quite functional now, and integrates nicely with the native frameworks. Worth a look, particularly if you already have Ruby experience.

东风软 2024-10-11 08:32:55

如果你想学习 Cocoa 编程,请忽略桥梁。它们只会使编写 Cocoa 应用程序变得更加困难,并且您会浪费大量时间来加快速度。

具体来说,您需要学习 Objective-C 才能理解系统框架的 API 和设计模式。此外,所有文档和工具都是专门为支持 Objective-C 而编写的。

你学习 Cocoa 编程的大部分时间将花在上述 API 和设计模式上;相比之下,实际的语言部分相对较小。

还要注意的是,在尝试将不完全相同的功能从一种语言映射到另一种语言时,桥必然会导致阻抗不匹配。

坦率地说,如果你了解 Ruby,那么 Objective-C 应该很简单;对象模型非常相似。

If you want to learn Cocoa programming, ignore the bridges. They will only make writing Cocoa applications more difficult and you will waste a bunch of time getting up to speed.

Specifically, you will need to learn Objective-C to be able to understand both the APIs and design patterns of the system frameworks. Furthermore, all of the documentation and tools are written specifically to support Objective-C.

The bulk of your time in learning Cocoa programming will be spent on said APIs and design patterns; the actual language part is relatively small, by comparison.

Note also that the bridges necessarily incur an impedance mismatch in an attempt to map not-quite-the-same functionality from one language to another.

Frankly, if you know Ruby, then Objective-C should be trivially easy; the object models are very similar.

帥小哥 2024-10-11 08:32:55

我个人的观点是对 Mac 原生应用程序使用 ObjC。

使用 Ruby/Python,它们本来应该可以很好地工作,而无需不可靠的接口和有问题的支持。

My personal opinion is use ObjC for Mac native apps.

Use Ruby/Python where they supposed to work good natively without unreliable interfaces with questionable support.

深居我梦 2024-10-11 08:32:55

这就是为什么这不是浪费时间。在某些情况下,Ruby 和 Python 拥有出色且开发良好的库,这些库在 Objective-C 中不可用,而且也不可能可用。
这是最好的用例之一。

示例:您不想在 Objective-C 中重新实现 Rails(有些人可能),但您可以轻松地使用它,其中的一部分通过 MacRuby 为 Cocoa 应用程序提供支持。

好吧,麦克鲁比已经死了。有商业版的 RubyMotion。

还有 PyObjc、RubyCocoa 和 mruby。

其他有趣的用例之一是提供不像 AppleScript 和 OSA 那样糟糕的脚本功能。

有充分的理由。

Here is why it is NOT a waste of time. In some cases, Ruby and Python have awesome and well developed libraries that are not available in Objective-C and would not likely be.
That is one of the best use cases.

Example: you wouldn't want to reimplement Rails in Objective-C, (some people might) but you could easily use it, parts of it to power a Cocoa app with MacRuby.

Well MacRuby is dead. There is the commercial RubyMotion.

There is still PyObjc, RubyCocoa and mruby.

One of the other intriguing use-cases is to provide script ability that doesn't stink like AppleScript and OSA.

There are valid reasons.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文