Core Data Explorer is an interactive tool for browsing, manipulating and querying Core Data, the new object-oriented persistence layer in Mac OS X Tiger. It provides full object introspection, graphical browsers for objects and collections and a graphical interface for querying the Mac OS X persistent stores.
This is very cool, very powerful stuff. But unfortunately, it uses F-Script instead of using a language that more folks would be familiar with and that more folks might like.
OS X seems to be a very powerful platform. There’s no denying that folks are innovating at a tremendous pace on OS X. So, apparently there are enough folks who like languages such as F-Script that they are able to happily write code.
However, every time that I try to force my self to like OS X enough to switch over to it from Windows/Linux, I find myself being repelled by OS X’s languages such as Objective-C, Applescript and now F-Script. I’m already familiar with and like C, C++ and Javascript but I don’t like Objective C, Applescript or F-Script and so don’t foresee being able to enjoy using them enough to become proficient with any of them. To me, Objective-C, Applescript and F-Script seem like they don’t offer any compelling advantages over C, C++ or Javascript. And frankly, Objective-C, Applescript and F-Script all seem a little gross to me.
In my opinion, OS X would be a much more attractive platform if it would use C for kernel stuff, C++ for widget and application frameworks (like Qt/KDE) and Javascript for platform-wide scripting (maybe via something like QSA). Platform switchers would be able to leverage their existing language skills. And those folks who are inexperienced and don’t yet have any language skills could leverage the vast amount of C/C++/Javascript documentation that is available. At this point, I’m still considering switching to OS X, but only because Trolltech’s Qt4 and QSA will be available for OS X.
If Cocoa was C++-based and if the F-Script framework was Javascript-based, I’d order a Mac today.
So why would you like C++ over Objective C? When reading articles about C++ I keep getting the impression it’s a massive kludge, that throws out a number of important features of true object-oriented programming, while Obj-C is a much cleaner implementation.
So what does C++ offer over Obj-C?
“So what does C++ offer over Obj-C?”
Speed?
/Megol
I’m certainly not going to defend C++ for being elegant, although I probably wouldn’t go so far as to call it a “massive kludge.”
I’m really not interested in whether or not C++ is “true”ly object oriented. What I care about is that it is fast, well-documented, has strong library support and has cross-platform compiler support.
The last two items in that list are especially important to me as they mean that I can apply my C++ skills across several platforms. Objective-C seems to be favored only by Apple and is therefore mostly an OS-X technology.
Much/most of the code that I would like to write would be scientific/engineering in nature and so would be dependent upon C/C++ math/matrix/etc. libraries that I would employ. While using those libraries I would prefer very much to only have to think about a single language in my code. Having to juggle between C/C++ and Objective-C would be annoying.
When it comes to scripting, given that Javascript is the defacto standard for web page scripting and that I would have to provide web interfaces for some of my stuff, I would prefer to just use Javascript for all of my scripting needs.
In short, since I would already have to use C++ and Javascript for my efforts, I would really prefer to not have to use additional languages such as Objective-C or F-Script. Having to use additional languages mostly just complicates my efforts.
Again, my ideal platform would make it as easy as possible for me to write code. That means that the platform has to make it as easy as possible for me to reuse existing libraries (e.g. C++ math libraries) as well as existing infrastructure (e.g. Javascript-based browsers). That’s why I <sigh>ed about “yet another language.” I don’t want more languages. I want to simply use the ones that we’ve already got. In my opinion, we don’t need more languages. We need more libraries, such as Core Image and Core Data.
> “I don’t want more languages”
C’mon, Objective-C was there before C++ and Javascript. F-Script is actually Smalltalk, which was there long before C++ and Javascript.
Beside, you want C++/Javascript, but this gives you two completely different object models whereas Objective-C and F-Script use the very same object model (i.e., F-Script uses the native Mac OS X Objective-C object model). This is quite powerful and opens a lots of interesting possibilities: CoreData/CoreData Explorer is a good example of the power of the dynamic, scriptable object model we have in Mac OS X.
Obj-C is just standard C with a very light object layer on top of it. If you are used to C then moving to Obj-C is easy.
Apple also supports Obj-C++ which is the Object extentions on top of standard C++.
You can use any C or C++ libraries you like with your Obj-C/C++ program. If you are doing command line program, then you don’t even need the Obj-C/C++ language.
The only place Apple forces you to use Obj-C is for the GUI. The reason for this is that Obj-C’s object model is very simular (and better) then MSFT’s COM and DCOM model. Also, note that with Obj-C any class can be exported just by compiling the source code into a DynLib (DLL). COM & DCOM requires you to write massive interfaces. Windows DLL’s don’t count here since they only export procedures and not classes.
As for cross-platform support, GNUStep is about 90% compatable with Cocoa and supports Windows & Linux environments.
IT huRt my brains!
If Objective-C where C++ Cocoa could not exist, as it relies on the highly dynamic nature of Objective-C. Not all languages are the same, some are better certain things than others. Objective-C happens to excel at GUI’s, whilst allowing you to use standard C where speed is imperative.
fast, well-documented, has strong library support and has cross-platform compiler support
Fast? Objective-C is fast enough on a 68030. People got the impression that it was not fast because the original NeXT boxes ran everything from a magneto-optical disk rather than an (expensive) harddrive. This made them feel slow which was wrongly attributed to the language overhead. There is a small overhead for the dynamism of the language, but most of the time it is insignificant.
Apples documentation is pretty good. Quite frankly I find it much easier to get around than either MSDN or the documentation that came with Visual Studio.
Have you seen Cocoa? An extremely powerful library, and an open specification so that people like GNUStep can clone it without any legal uncertainties.
As for a cross platfrom compiler, there is this thing call the GCC. You may have heard of it. Apple has, and uses it as the compiler for XCode.
Still think C++ is better, trying doing this. A function that takes an object of unknown type as an argument and then calls the doStuff method of that object.
-(void) myFunction:(id) obj
{
@try { [obj doStuff]; }
@catch { NSLog(“an error happened”); }
}
I started with
template<T> myFunction(T& obj)
{
obj.doStuff();
}
And skipped the exception handling because I didn’t feel like typing it out. Then I figure, goly I bet he means that the type shouldn’t be determined statically anywhere in the whole program. You never know when you might want to pay the memory and lookup overhead of really-late binding just in case your program loads objects dynamically everywhere. I guess I should use COM, XCOM, or just plain old CORBA, but those are verbose and if I wanted every single method call in my program to first involving querying the type of an object that would take up a lot typing.
So I went back to Objective-C where I thought you meant:
void myFunction(id obj)
{
@try
{
[obj doStuff];
}
@catch
{
NSLog(“An error occurred.”);
}
}
But every time I try:
myFunction(3); and myFunction(“Hi, everybody!”); I get an error. I guess 3 can’t have a method called doStuff?
But then I tried:
void myFunction2(id l, id r)
{
if(l < r)
doOne(r);
else
doTwo(r);
}
myFunction2(5, 6);
myFunction2(point1, point2);
But I can’t get that to work, either. I guess there aren’t any ad-hoc polymorphic functions? Or polymorphic operators?
As much as I love writing satire, and would love to address other things, I think that I’ll have to stop here.
Apple should have just created or simply purchased an efficient Smalltalk implementation. It’s a much more elegant, safer language than Objective-C, and through an FFI it could still provide interoperability with C for things deemed “performance critical.” Or they could have continued the Dylan project. If you’re going to use a fringe language that isn’t going to see widespread adoption on other platforms, it might as well be a good one.
C++ is an incredibly over-complicated language. There are so many nuances, gotchas, corner cases, etc, it is just silly.
Objective-C offers dynamic typing and binding, and it’s method syntax is worlds easier to read. Consider the following methods:
C++: if (x.intersectsArc(35.0, 19.0, 23.0, 90.0, 120)) { … }
Objective-C: if ([x intersectsArcWithRadius:35.0
centeredAtX:19.0
Y:23.0
fromAngle:90.0
toAngle:120.0]) { … }
As several readers have mentioned, Objective-C can be compiled on any machine that has gcc. Additionally, the Cocoa Framework is mostly supported by the FSF. (It is an open specification).
It has also already been pointed out, but I will say again, that you can use your existing C++ libraries and classes in an Objective-C program. It has some silly name like Objective-C++.
Frankly, if Cocoa were based on C++, I would certainly not program with it. I would probably be programming with Smalltalk or Lisp. Objective-C is one of the reasons it is so fun to program on Mac OS X instead of, for instance, Linux. Where C++ is limited, complex, non-extensible, etc. Objective-C is powerful, simple, dynamic, and agile. In one word: refreshing! Combined with interactive tools like Interface Builder and F-Script, it really offers a great programming experience. Furthermore, it let you reuse all your C and C++ code directly, with zero effort, and is extremely easy to learn for a C or C++ programmer.