Learning Objective C without a Mac

2019-03-19 09:51发布

I do not have a Mac, or an iPhone. However, the concept of taking C and making it more dynamic towards the idea of smalltalk, python or ruby is really attractive to me. I'd love to start on objective C.

Is objective C just a syntax superset of C or is it really like C. As in, can it be compiled with gcc etc..?

I do most of my programming in Ruby. Objective C seems so much more forgiving than C. You can write native extensions for Ruby in C. Can you write native extensions for Ruby in Objective C?

How can I get started with Objective C outside of owning an Mac/iPhone and having XCode?

6条回答
贪生不怕死
2楼-- · 2019-03-19 10:30

You can you this page for simple experiments with ObjC: http://www.codesign.cz/LearnObjC/

查看更多
来,给爷笑一个
3楼-- · 2019-03-19 10:38

There's a difference between Objective-C the language, and the frameworks that Apple has built on top of it. Those frameworks consist of a bunch of objects which you can use in your code and are especially helpful if you're targeting the Mac or the iPhone. There are some similar objects for parts of it in GNUStep, but it's not a complete replacement for the Cocoa/etc library and especially doesn't cover anything iPhone related.

GNUStep and the Objective-C language (via gcc) are available for many platforms, and you can write your own programs that use Objective-C objects and interact with any C api from Objective-C.

Objective-C is a superset of C and so is not really more forgiving than C, but it is arguably more forgiving than C++ (an almost-superset of C). You can also mix Objective-C and C++ with GCC but that gets a little complicated, especially regarding exception handling.

For getting started and playing around with the language though, GNUStep and GCC would be a good way to go.

查看更多
男人必须洒脱
4楼-- · 2019-03-19 10:40

apple contributed the objective c changes back to gcc (not that they had much choice, being GPL). So wherever you can set up gcc, you can set up an objective-c compiler.

Beyond that, the Gnustep environment can give you a bit of the flavor of the original OpenStep/NextStep environment.

查看更多
你好瞎i
5楼-- · 2019-03-19 10:51

Wikipedia says

Today it is used primarily on Apple's Mac OS X and iPhone OS, two environments based on, although not compliant with, the OpenStep standard, and it is the primary language used for Apple's Cocoa API though it was originally used as the main language on NeXT's NeXTSTEP OS. Generic Objective-C programs which do not make use of these libraries can also be compiled for any system supported by gcc, which includes an Objective-C compiler.

Objective-C today is often used in tandem with a fixed library of standard objects (often known as a "kit" or "framework"), such as Cocoa or GNUstep.

Maybe you should get a Linux vm if you are mainly running Windows and get GNUStep running.

查看更多
在下西门庆
6楼-- · 2019-03-19 10:53

Yes, you can write, compile and run objective c programs outside a MAC/IPhone

Please check the link below for details http://www.otierney.net/objective-c.html#settingup http://www.faqs.org/faqs/computer-lang/Objective-C/faq/

查看更多
Root(大扎)
7楼-- · 2019-03-19 10:55

I don't see any compelling reason why you cannot use Objective C for native ruby extensions, except that you won't benefit much. You will still have to use the lower level C Api calls, since as far as i know, there aren't any ruby to objective-c bindings. Additionally, Objective C comes with a fairly substantial library of utility classes that, while helpful, won't easily justify their size and weight in the context of a ruby extension.

查看更多
登录 后发表回答