I am trying to test Objective-C on Linux (Ubuntu 10.04), mainly to decide if it's worth it to get a Mac and XCode. I have to like a language before I seriously consider programming in it (even more so when I have to pay a lot for it)
I am using gcc (with gobjc++). But this of course does not include the Foundation Kit and the rest of the Cocoa API (not overly concerned about this one).
Short of GNUStep, what is the best way for me to get into Obj-C programming in Linux or Windows? I want to get at least class in the FoundationKit.
You have two options:
GNUstep, which is focused on Linux
Cocotron, which is focused on Windows
Those are the only freely available implementations of Foundation that I'm aware of.
Honestly, the language is hardly ever used outside of the Apple ecosystem, so you're not going to get a first-class experience here. Not knocking those groups' efforts, but if you're looking for something comparable to what you get on OS X, it just isn't there.
Related
Is it true :
Cocoa is an application environment that consist of several Frameworks
and each framework consist of several API
Application Environment -> Framework -> API
Is Carbon the other application environment in OSX?
All things that allow an application to talk to a computer are an "API." That's a very broad term. It may refer to something as small as malloc, or as large as Cocoa. All of these are "APIs" in the broadest sense of the term.
On Mac and iOS, "framework" can have a specific meaning, which is a dynamically loadable bundle in a specific format. It can also have a broad meaning of "a collection of libraries that work together." There is a Cocoa.framework, but there is also the broader architecture of "Cocoa" which is a way of attacking problems together with a set of tools for attacking problems in that way.
An "Application Environment" is any environment that applications can run in. So Mac OS X could be considered an App Environment, or you might consider Darwin to be an App Environment, or Cocoa, or Carbon. It depends on what you're comparing it to.
The point in all of this are that these are not industry-wide well-defined terms. They're used to mean a lot of overlapping things, and they are sometimes used slightly different ways even within the Apple docs.
If you're looking for a good reference on general terms and how Apple uses them, you want to read Cocoa Core Competencies.
What the wiki says :
Carbon is one of Apple Inc.'s procedural application programming
interfaces (APIs) for the Macintosh operating system. It provides C
programming language access to Macintosh system services. Carbon
provides a good degree of backward compatibility for programs to run
on the now-obsolete Mac OS 8 and 9, however these systems are no
longer actively supported since Apple released the final OS 9 update
in December 2001.
In a few words, BOTH Cocoa and Carbon are considered APIs.
Sidenote : Why do you care so much about terminology? I definitely wouldn't. IMHO, it's the inner logic and concepts that matter; and not, necessarily, how we call it. Just my 2 cents....
I might be asking something strange here, but I'm unsure where to begin. The thing is that I am considering writing a command line tool on a Mac using Obj-C and the Foundation classes.
But there is a very big risk that I would like to be able to compile it for different Linux distributions to run as a server app in the future.
I understand that it is not a problem in itself to compile Objective-C for Linux, but what I don't understand is the API coverage.
As I have understood it so far I can use GNUStep to compile for linux, but is there a good way for me to get an overview of the API coverage? What I mean is, if I use a class that has been added to the Foundation framework in OSX Lion lets say, how big is the risk of that not being available in GNUStep at that time?
I hope I am asking a question that you guys can understand, basically I want to avoid writing an app that can theoretically be compiled for linux, but not in practice because of missing classes etc.
Thanks!
An opinion: The risk is fairly high. GNU Step is an open source project and dependant on its volunteers to keep it up to date. OS X Lion has a small number of additions to Foundation and AppKit.
Your best option if you want it for *nix in the future will be to write it in generic C/C++ and then thinly wrap it in an NSTask if you want a GUI.
You should be able to check if the API's you're using are available by consulting the GNUStep base API docs.
You may want to target GNUStep as your base if compatibillity is a big concern. Compiling for mac should then be rather trivial, compared to moving the code the other way. Of course you always have the option of helping inplement whatever is missing from GNUStep too.
If you are not developing for an Apple platform, are there reasons to choose Objective-C? I know of GNUstep (which I do not find visually pleasing), but what else is there?
If you want to develop for multiple platforms, including OS X or iOS but also Linux or Windows, when might Objective-C be a good choice?
Outside Apple, The only major Objective-C environment is GNUSTEP/Windowmaker.
It's a shame, since Objective-C is a much nicer and saner language than C++.
Take a look at Cocotron, which is a port of Cocoa to Windows. If the Mac is your main target, this may be a way to get Windows as well. But, Apple platforms are the best place for ObjC -- if you aren't targeting Apple, I wouldn't use it.
There is The Cocotron
Clozure Common Lisp (CCL) on 32-bit Windows platforms now includes experimental support for the Cocoa frameworks using the Cocotron open source project.
Is there any other scripting language that can be used to embed scripts inside applications, which can access Mac OS X, or application classes with the same features, or most of the features seen in F-script?
The scripting language with the best support on the Mac is still AppleScript. But unlike F-Script, it cannot directly access the Objective-C level, it can only use what the target application chooses to expose for scripting.
There are Objective-C bridges for Perl, Python, and Ruby. I suppose those can embedded to provide scripting to your application.
Nu is an interesting option, although it isn't very popular yet.
A lot of people seem to like JSTalk.
But probably Applescript is your best bet: integrated into the system and all that.
I would say F-Script for many reasons. It has many unique features and is extremely tightly integrated with Cocoa and the Objective-C runtime. You can for example inspect various Finder classes (windows, icons, coverflow view...) and it's very easy (one or two lines of code) to start or control other processes. I don't think there is any good reason to prefer AppleScript. It's good for very short scripts, but will probably drive you crazy if you want to do something more complex.
Also, MacRuby is going to rock when it's a bit more stable, and some serious stuff has been accomplished using PyObjC as well, although I don't think it's very actively maintained anymore.
If you don't need F-Script graphical introspection tools, which are quite unique, there are some decent scripting languages that you can embed in applications. See in Particular RubyCocoa (for Ruby), PyObjC (for Python), JSTalk (for JavaScript) and CamelBones (for Perl). They are based on bridges between Cocoa and a foreign object model, which leads to some complexities. This is different from F-Script, which is directly built for the Cocoa object model. When ready, MacRuby might be an option too, but the syntax for manipulating Objective-C objects is not very nice (it improves on RubyCocoa, though). Nu is also an option: directly built for Cocoa like F-Script, but with a strong Lisp flavor.
MacRuby is an implementation of Ruby 1.9 that uses the Objective-C runtime and garbage collector. It can be embedded in a Objective-C application.
Even if the last available version is only 0.6, it is reported to be stable enough to be used in applications.
It seems that Cocoa seems to be the main platform for Objective-C. GCC (which Xcode uses) supports Objective-C so it must be available on a wide range of platforms.
Are there any notable cross-platform projects that use Objective-C but not Cocoa (or its open source cousin GNUStep)? Is it really used outside the Apple ecosystem?
Objective-C has also been popular in the scientific and financial services communities. There are still many Objective-C based applications deployed in banking, mostly on the trading analysis front. A friend works on a nearly million line of code Objective-C based analysis and trading engine for which they have written their own class hierarchy from scratch.
At one point, one of the more popular Linux window managers was written in Objective-C. That was a few years ago and may no longer be the case.
The LLVM compiler also compiles Objective-C, including having full support for Blocks. It is quite portable, too.
There is also David Stes's Portable Object Compiler. It compiles Objective-C to C and uses a class hierarchy that is based quite directly upon the original ICPak class hierarchy from StepStone.
It seems what you're asking is if Objective-C is ever used without Cocoa, or GNUstep, or Cocotron, or any API like them.
The answer is basically no. Without an API like Cocoa (or GNUstep, etc.), Objective-C isn't very useful. For example, without NSObject, retain and release wouldn't even exist. A ton of very important features are built into these APIs, so it's somewhat pointless to use Obj-C without one of them.
Yep, there sure are. The one I can think of from the top of my head is Cocotron. An effort to port AppKit to Windows.
http://www.cocotron.org/
Aside from that, Objective-C can be used on any platform that gcc will run on. You won't have the wealth of frameworks that are available in Cocoa on OS X or the iPhone, although as you mentioned, GNUStep does a pretty good effort.