 |
 |
The merits of ObjC without Cocoa?
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status:
Offline
|
|
Is it stupid to use ObjC if I don't want to write a full GUI?
I mean, since ObjC has a runtime environment, will it be slower and more pathetic than an equivalent C++ app for command-line only environments?
How is ObjC as a language of it's own right, compared to C++, when each are separated from their respective APIs?
------------------
"This works that doesn't apple locked root out will it come back this hardware no longer kernal panics means apple going backwards this or that software now crashes..... build 4k29 ak47 On and on." -Scott_H, the one and only English mutilating, word modulating, Mac OS X moderator.
All that matters to me is the Dock perversion.
|
|
you are not your signature
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status:
Offline
|
|
I wouldn't use ObjC for sections of code where you're trying to conserve every possible machine cycle, but other than that there should be no problem. Part of Cocoa is the Foundation framework, which has lots of useful classes for any program, be it GUI or command line.
As for portability, the GNUSTEP equivalent of Foundation seems pretty stable and complete, which should get you to several platforms. C++ might currently be portable to more systems, though -- not sure. I've heard of some projects out there that use ObjC, like www.swarm.org (I don't think they use anything from GNUSTEP though -- they have their own stuff).
As for comparing the languages directly, well, that's more of a religious issue. I personally prefer ObjC as I feel it provides an awful lot more design flexibility (as demonstrated by the Cocoa APIs) leading to easier-to-read and more maintainable code, but others will differ. In the end, both languages should get the job done, so pick whichever one you prefer. Don't avoid ObjC simply because you're writing a command-line tool, that's all :-)
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Sep 2000
Status:
Offline
|
|
Objective-C runtime is actually pretty small. The "cost" of Objective-C is actually more in all of the class information, as the classes, categories, etc are all registered in the runtime.
An Objective-C program that links only against the Foundation framework (which provides NSObject, NSString, collection classes, distributed objects,etc) would be quite small and fast, so the answer is "it's not stupid".
Ali
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Norfolk, Va
Status:
Offline
|
|
thanks ali, that's exactly what I'm asking.
that said, I just wrote a very basic C app to test out ObjC minus Cocoa, but i can't run it in the terminal. the dev tools compile it to a .app and then it opens and closes as if it were a real app. I just want a basic command-line ObjC app, and I read in the documentation that ObjC will definetely run all C apps.
My project was a Cocoa app (no docs) from the dev tool menu.
Can you help?
------------------
"This works that doesn't apple locked root out will it come back this hardware no longer kernal panics means apple going backwards this or that software now crashes..... build 4k29 ak47 On and on." -Scott_H, the one and only English mutilating, word modulating, Mac OS X moderator.
All that matters to me is the Dock perversion.
|
|
you are not your signature
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Feb 2001
Location: San Francisco, CA, USA
Status:
Offline
|
|
Here's a start. If you're using ProjectBuilder, try creating a new "Cocoa Tool" project instead of a "Cocoa Application" project.
sybarite> cat >foo.m
#import <Foundation/Foundation.h>
main ()
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSString *msg = [NSString stringWithFormat:@"Hello, %@!", @"world"];
NSLog(msg);
}
^D
sybarite> cc -g foo.m -framework Foundation
sybarite> a.out
Hello, world!
sybarite>
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2001
Location: Rochester, uk
Status:
Offline
|
|
ali said:
An Objective-C program that links only against the Foundation framework... would be quite small and fast, so the answer is "it's not stupid".
Forget the foundation, link against the ObjC core! not only does it avoid any of the overheads of cocoa, you can also copy it onto any linux machine and compile with no change.
Instead of:
#import <Foundation/Foundation.h>
You instead say:
#import <objc/objc.h>
Or for the really minimalist
#import <objc/Object.h>
Then you just need to find the correct framework (somewhere in System), and add it to your project. I found it still needed to Foundation framework in the project to compile, but you don't have to use it at all.
|
|
All words are lies. Including these ones.
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Oct 1999
Location: Brookline, Massachusetts, USA
Status:
Offline
|
|
If you stick to Foundation, your command line tool will work just fine and will also port to other flavors of UNIX, using GNUstep. I just wrote a multithreaded SNMP-based web server load monitor in Objective-C, using the UCD SNMP library. I developed and debugged it on MacOS X PB. I was pleasantly surprised to find that, once I downloaded and installed GNUstep, the code just compiled and worked on RedHat Linux without a hitch.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|