学习 Objective-C、Ruby 还是 Python?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/550474/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 20:21:40  来源:igfitidea点击:

Study Objective-C , Ruby OR Python?

pythonobjective-crubyprogramming-languages

提问by anand

I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.

自过去 4-5 年以来,我一直在研究 C++。最近我买了iphone和macbook,想为iphone做一些编程。

So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.

所以我开始阅读一本关于 Objective-C 的书。我还了解到我们可以在 MAC 上使用 Ruby 和 Python 进行编程。

So my question is which one to study? Which language you guys see the FUTURE???

所以我的问题是学习哪一个?你们看到哪种语言的未来???

Can we program with these languages on other platforms? Or are these only limited on MAC?

我们可以在其他平台上使用这些语言进行编程吗?或者这些仅限于MAC?

I am just a beginner in objective-C.Need some expert thoughts which way to go.

我只是Objective-C的初学者。需要一些专家的想法。

AC

交流电

回答by Himadri Choudhury

If you want to program for iphone then you should use objective-C. The entire iphone API is based on objective-C, and you have the benefits of using interface builder and IDE support from Xcode.

如果你想为 iphone 编程,那么你应该使用 Objective-C。整个 iphone API 都基于 Objective-C,并且您可以使用 Xcode 的界面构建器和 IDE 支持。

回答by Erik Engheim

I use all the languages C++, Ruby, Python and Objective-C. I like each one in different ways. If you want to get into Mac and iPhone development as others I recommend Objective-C.

我使用所有语言 C++、Ruby、Python 和 Objective-C。我以不同的方式喜欢每一个。如果你想像其他人一样进入 Mac 和 iPhone 开发,我推荐 Objective-C。

One of the benefits not mentioned is that Objective-C is a proper superset of C (C++ is almost a superset), that means you can bring over all your C programming knowledge from doing C++ to Objective-C programming. In fact you can also mix in C++ code in Objective-C code.

没有提到的好处之一是,Objective-C 是 C 的适当超集(C++ 几乎是超集),这意味着您可以将所有 C 编程知识从 C++ 带到 Objective-C 编程。事实上,你也可以在 Objective-C 代码中混入 C++ 代码。

You can't do that in a seamless way in Python and Ruby. The reason why you can do this is that Objective-C is actually a very simple language.

你不能在 Python 和 Ruby 中以无缝的方式做到这一点。之所以可以这样做,是因为Objective-C 实际上是一种非常简单的语言。

Originally it was just C with a custom made preprocessor which took statements like this:

最初它只是带有定制预处理器的 C 语言,它采用如下语句:

[rectangle setX: 10 y: 10 width: 20 height: 20];

and converted it to this before compiling:

并在编译之前将其转换为:

  objc_msgSend(rectangle, "setX:y:width:height:", 10, 10, 20, 20);

Apart from that Ruby, Python and Objective-C are very similar in their object model at least compared to C++. In C++ classes are created at compile time. In Objective-C, Ruby and Python classes are things created at runtime.

除了 Ruby 之外,至少与 C++ 相比,Python 和 Objective-C 在对象模型上非常相似。在 C++ 中,类是在编译时创建的。在 Objective-C 中,Ruby 和 Python 类是在运行时创建的。

I wrote some stuff on why Obj-C is cool here

我写了一些关于为什么 Obj-C 很酷的东西

回答by Andy Dent

Objective-C is the only way to program an iPhone if you want to produce native programs that can be sold in the App Store.

如果您想制作可在 App Store 中销售的本机程序,Objective-C 是对 iPhone 进行编程的唯一方法。

Some of the more advanced concepts in Objective-C are now being added to languages like C# (eg: extension methods in C# v3.0). Learning to think in Objective-C will be useful, the OO model you learn will be applicable to most other languages and environments as an addition to your C++ experience.

Objective-C 中的一些更高级的概念现在被添加到像 C# 这样的语言中(例如:C# v3.0 中的扩展方法)。学习在 Objective-C 中思考会很有用,您学习的 OO 模型将适用于大多数其他语言和环境,作为您 C++ 经验的补充。

Ruby's object model is closer to that of Objective-C than is Python so I suggest also learning Ruby but not until you have your Objective-C skills down solidly.

Ruby 的对象模型比 Python 更接近于 Objective-C,所以我建议你也学习 Ruby,但在你的 Objective-C 技能扎实之前不要学习。

Note that you can use Objective-C++ and use C++ for all but your GUI code by having .mm suffixes on your files - this works on both iPhone and Mac. Given your C++ experience, that help you be productive.

请注意,通过在文件上添加 .mm 后缀,您可以使用 Objective-C++ 并将 C++ 用于除 GUI 代码之外的所有代码 - 这适用于 iPhone 和 Mac。鉴于您的 C++ 经验,这可以帮助您提高工作效率。

If you want to program iPhone, don't bother learning the new Objective-C 2.0 memory management but you can still use the Properties model (iPhone effectively has a subset of the Objective-C 2.0 runtime).

如果你想给 iPhone 编程,不要费心学习新的 Objective-C 2.0 内存管理,但你仍然可以使用 Properties 模型(iPhone 实际上有一个 Objective-C 2.0 运行时的子集)。

回答by S.Lott

Which language you guys see the FUTURE???

你们看到哪种语言的未来???

Future of what? iPhone development? Objective-C.

未来何去何从?iPhone开发?目标-C。

Web Services? Python/Ruby in parallel for a while. At least until people start trying to do maintenance on large Ruby applications and get frustrated with it's opacity.

网页服务?Python/Ruby 并行一段时间。至少在人们开始尝试维护大型 Rub​​y 应用程序并对其不透明感到沮丧之前。

Real-time game engine development? Embedded applications? Future of what?

实时游戏引擎开发?嵌入式应用?未来何去何从?

"Can we program with these languages on other platforms? Or are these only limited on MAC?"

“我们可以在其他平台上使用这些语言进行编程吗?或者这些仅限于 MAC?”

Ruby and Python: Yes. These are designed to run on any platform that supports C.

Ruby 和 Python:是的。这些旨在运行在任何支持 C 的平台上。

Objective-C: Yes. It's open source, it's in the GCC, it shouldwork almost anywhere.

目标-C:是的。它是开源的,它是在海湾合作委员会,它应该工作的几乎任何地方。

Learning a new language is nota zero-sum game. You can learn more than one language; learning Objective-C now does not prevent you from learning Python or Ruby in the future.

学习一门新语言不是零和游戏。你可以学习不止一种语言;现在学习 Objective-C 并不妨碍你将来学习 Python 或 Ruby。

回答by Chris Lutz

As a Perlite, I'm just going to point out that OS X has Perl as well as Python or Ruby.

作为 Perlite,我只想指出 OS X 具有 Perl 以及 Python 或 Ruby。

As far as Perl/Python/Ruby goes, programs are almost completely cross-platform. It is fairly easy to run a Perl/Python/Ruby program on any platform and it works more or less the same. There may be some minor differences, but they're not major.

就 Perl/Python/Ruby 而言,程序几乎是完全跨平台的。在任何平台上运行 Perl/Python/Ruby 程序都相当容易,而且工作方式大致相同。可能有一些细微的差别,但它们不是主要的。

Objective-C, while not strictly confined to OS X, is only really used in OpenStep-based environments, which generally means OS X and the iPhone. The only Objective-C compiler I know of is gcc, and I imagine you can write Objective-C on Linux, but I don't know if Windows support is very good (if it exists).

Objective-C 虽然不严格限制在 OS X 中,但仅在基于 OpenStep 的环境中真正使用,这通常意味着 OS X 和 iPhone。我所知道的唯一的 Objective-C 编译器是 gcc,我想你可以在 Linux 上编写 Objective-C,但我不知道 Windows 支持是否很好(如果存在)。

As for which is the language of the "future", all 3 (or 4) languages will be used very widely in the future. No one can really predict this kind of thing, and none of the languages are really going to die off (unless Apple switches to a new language as a "standard" for making Mac programs), so you'll be pretty safe with any of them.

至于哪个是“未来”的语言,所有的3(​​或4)种语言在未来都会被非常广泛地使用。没有人能真正预测这种事情,而且没有一种语言真的会消亡(除非 Apple 切换到一种新语言作为制作 Mac 程序的“标准”),因此您对任何一种语言都非常安全他们。

My advice: try them all out and see which one you think most suits your style, and learn that one.

我的建议是:全部尝试一下,看看你认为哪一种最适合你的风格,然后学习那个。

回答by Johan

As has been noted by others, if you want to program the iPhone, Objective-C is the way to go.

正如其他人所指出的,如果您想对 iPhone 进行编程,Objective-C 是您要走的路。

Objective-C is pretty Mac-specific; of course, the Gnu Objective-C compiler is avaialble for other platforms as well, and there is also GnuStep, but I think the main applicability of Objective-C today is for programming Macs and iPhones.

Objective-C 是 Mac 特有的;当然,Gnu Objective-C 编译器也适用于其他平台,也有GnuStep,但我认为 Objective-C 的主要适用性是在 Mac 和 iPhone 上编程。

Python and Ruby on the other hand are available on a large number of platforms (including both Windows and many Unix-dialects). Personally, I prefer Python, but I would say both languages are very usable and pretty easy to approach.

另一方面,Python 和 Ruby 可用于大量平台(包括 Windows 和许多 Unix 方言)。就我个人而言,我更喜欢 Python,但我会说这两种语言都非常有用并且很容易上手。

Note also that both Pythonand Rubyhave Objective-C bridges available, which allows you to write quite fancy Cococa applications in any of those languages.

另请注意,PythonRuby都有可用的 Objective-C 桥接器,这使您可以使用其中任何一种语言编写非常漂亮的 Cococa 应用程序。

回答by Johan

Ruby. With Ruby you will be able to do both web development (Rails/Sinatra/etc.) and very soon program on the MAC/Iphone platform with the Macruby project. Why not get the best of both worlds?

红宝石。使用 Ruby,您将能够进行 Web 开发(Rails/Sinatra/等),并很快通过 Macruby 项目在 MAC/Iphone 平台上进行编程。为什么不两全其美呢?

Tommy

汤米

回答by Mark

Just my two cents...As I'm sure you're aware, Apple and others in the respective communities are doing a lot of work with Ruby and Python, for both Mac and iPhone development. Objective-C will pretty much get you into Apple arenas only these days (though maybe that's not a bad thing;) However, if you are only going to learn one language in the foreseeable future, think about where you will be using it, and what for. Ruby and Python will get you a lot further if you are looking beyond solely Mac desktop and iPhone.

只是我的两分钱……我相信你知道,Apple 和各自社区中的其他人正在使用 Ruby 和 Python 进行大量工作,用于 Mac 和 iPhone 开发。现在,Objective-C 几乎会让你进入 Apple 领域(尽管这也许不是一件坏事;)但是,如果你在可预见的未来只学习一种语言,请考虑你将在哪里使用它,并且做什么的。如果您不仅仅关注 Mac 桌面和 iPhone,Ruby 和 Python 会让您走得更远。

回答by José Joel.

I have written small games, interpreters, and tons of awessome stuff in Ruby. I Wouldn't recommend It to write intensive AI programs for instance, but It's fun to learn and powerful for most applications. Even when I do most of my work in C++ Ruby is my favorite language for subjective reasons.

我用 Ruby 编写了小游戏、解释器和大量很棒的东西。例如,我不建议用它来编写密集的 AI 程序,但是对于大多数应用程序来说,它学习起来很有趣并且功能强大。即使我使用 C++ 完成大部分工作,出于主观原因,Ruby 仍然是我最喜欢的语言。

Objective C as most people said Is a must in iPhone development, and fun if You're enthusiastic about learning languages.

正如大多数人所说的那样,Objective C 是 iPhone 开发的必需品,如果您热衷于学习语言,那么它会很有趣。

I haven't tried Python, but I hear nothing but good things about It, and PyGames Is quite popular.

我没有尝试过 Python,但我只听到关于它的好消息,而且 PyGames 很受欢迎。

I would learn the three ( well...I would skip objective C unless You're curious about getting into iPhone development), the most languages you know, the best professional You will be. As a good professor of mine always said..It's not about being the master in just one language, It's about knowing the pros and cons of each one to choose the right one according to the particular problem You want to solve.

我会学习这三种语言(嗯……我会跳过目标 C,除非你对进入 iPhone 开发感到好奇),你知道的最多的语言,你将成为的最好的专业人士。正如我的一位好教授常说的那样……这不是仅仅掌握一种语言,而是要了解每种语言的优缺点,然后根据您要解决的特定问题选择合适的语言。

Cheers !

干杯!

回答by alamodey

If you program with Objective-C, your main goal should be writing Cocoa applications on the Mac. Beyond that, it has little use. Ruby and Python are useful scripting languages, and there are also bridges to write Cocoa applications.

如果您使用 Objective-C 编程,您的主要目标应该是在 Mac 上编写 Cocoa 应用程序。除此之外,它几乎没有用。Ruby 和 Python 是有用的脚本语言,也有编写 Cocoa 应用程序的桥梁。

If you want to write apps on the Mac, I would start with Objective-C. There is more support available.

如果你想在 Mac 上编写应用程序,我会从 Objective-C 开始。有更多可用的支持。

In terms of the future, it seems like a lot of people are jumping on the Ruby bandwagon at the moment. Good luck.

就未来而言,目前似乎很多人都在加入 Ruby 的行列。祝你好运。