views:

692

answers:

12

We need to write some software that will compile and run on both an Mac OS X server and Ubuntu. We would love to use Objective-C with all of its Cocoa goodness, however the GNUstep implementations of the parts we are using are broken (in the latest Ubuntu package anyway.)

In light of this should we use C++ (I would really rather not), C or something else that we have not thought of?

It is a server/back-end process that is very resource intensive, Java and other interpreted versions of this software perform much worse than the Objective-C proof of concept we have written, hence we now wish to re-write in a "compiled[1]" language.

(NB: Some people might consider this subjective, however at the end of the day we do need to get a job done, there has to be a reasonably appropriate correct answer here).

[1] Compiled to native CPU instructions, not compiled into "byte codes" that then have to be run by an interpreter.

A: 

I would hazard a guess that C/C++ would be the most obvious platform independent languages.

(I would really rather not)

Why not? What sort of software do you plan on developing?

Nick Bedford
There is no such language as C/C++.
David Thornley
Haha thanks for pointing that out :P
Nick Bedford
+5  A: 

What sort of software are you trying to create?

The most likely answer is C/C++.

phoebus
There is no such language as C/C++.
David Thornley
You seriously voted me down for that? You've got issues, my friend.
phoebus
Yea but lol @ both of you (:
Jacob
I am not going to vote you down but it is a rather bad advice. The old C API (Carbon) is end-of-lifed for OSX making C (and/or) C++ an answer only if you want to stay in the 32-bit world and be sure to miss out all future development on the GUI front.The way to go is likely either to use some language that will eventually have a Cocoa backed implementation of its GUI layer (like java) or do like Skype and others and have a platform specific GUI using shared code.Unfortunately, I have yet to see a good cross platform library for C or C++ using Cocoa.
Fredrik
I guess I just thought it would be obvious to you that I mean implement the underlying logic in C or C++ and use Cocoa to do the UI on a Mac if you want. That's one of the nice things about Objective-C and Objective-C++, easy porting in of logic from other, vanilla-C and vanilla-C++ apps.
phoebus
A: 

It depends on what you want to do. If you are looking for very high performance application, your options are C/C++. If you are looking for quick development, your options are Java/Python.

rjoshi
java/python are not compiled
Jacob
@Jacob: I am quite sure I have to compile my java sources before using them. The result may not be the end binary as the final compilation is made by the JVM when it has all the information needed to optimize it right but it sure is compiled. But I guess you know that.
Fredrik
you have to compile java to use it.I agree on python but I focused on cross platform and for quick development.
rjoshi
+18  A: 

I would implement the core business logic in C and take the time to write GUI wrappers native To each platform's code -- Objective-C /Cocoa and GTK/gnome or whatever.

Devin Ceartas
This is exactly the advice that Apple would give you. Factor your code to separate the GUI from your application logic, and write a native GUI for each platform you want to run on. If you try to use a cross-platform GUI library like Qt, your app will suck.
NSResponder
@NSResponder - So Apple's solution to the problem of a portable cross-platform GUI library is to roll your own for every application you write? That sounds like an awful way to go about doing things.
Chris Lutz
Actually, it is probably ideal if you have unlimited time and budget. However, we don't really know whether the OP can actually afford to do this.
ConcernedOfTunbridgeWells
Im going to tick this as being the closest to correct answer. I am going to follow this advice except for that I will also use gcc's objective c support. All I have to do is avoid all of the NS* classes, boy will that be annoying (:
corydoras
@corydoras: If you use GNUstep you can make use of many of the NS* classes.
Amuck
+6  A: 

Consider using Python. You can write applications that are native in appearance on both platforms with wxPython.

Python comes with Max OS X and Ubuntu desktop and your application can be packaged to look and behave like any other native application on either platform.

Palo Verde
Python is not nearly as fast (to run) as C/C++, but if execution speed is not critical, it should be a good choice.
David Zaslavsky
Umm, not compiled
Jacob
@Jacob, not compiled to machine code, but it is byte-compiled.
dreamlax
@dreamlax - Most scripting languages these days are, but I'm pretty sure that's not what the OP means. When people say "compiled" language, they usually mean one that compiles to native machine code so that you don't need a runtime interpreter.
Chris Lutz
I did not realise that some people might interpret compiled to include a languages that is compiled into an intermediate byte code that then has to be run under a byte code interpreter.
corydoras
+5  A: 

I would recommend Objective-C for portability and ease of use. You don't get to use Cocoa if you want to run on Linux, but Objective-C is a really nice language and it let's you easily interface with regular C code.

Amuck
I agree, I use Objective-C all the time without Cocoa just because I find it easier to work with than C++.
dreamlax
+1 for this idea. Also, for Foundation/Cocoa stuff you think you might like, it's generally not terribly hard to write a class that quite closely mimics the functionality of it's Apple-only cousin.
alesplin
+4  A: 

How about java?

And if you need some really native thing, you can always use JNI.

Johan
+2  A: 

Assuming that you want to create an application with a graphical user interface, I think that C++/QT is the most likely candidate. I'm not aware of any other compiled[1] language with mature toolkit support on OSX and Linux.


  1. By 'compiled' I'm making the assumption that you mean 'produces a native executable'.
ConcernedOfTunbridgeWells
DO NOT use Qt for any app you plan to ship on OS X.
NSResponder
Why not? Have you got some personal experience of QT on OSX that you might like to share>
ConcernedOfTunbridgeWells
The only problem I've had with Qt is that it doesn't quite feel native on OS X, but that's a problem you will have with any cross-platform toolkit. Unless you want to write a custom interface for each platform you're not going to have a native look and feel.
Amuck
Not only will it not "feel native", or look native, it will have trouble with applescripting support, trouble with the document architecture which requires a Cocoa app to be truly document architecture compliant.
Warren P
A: 

I would vote for ANSI C or C++ coupled with POSIX.

mouviciel
A: 

My own preference would go to Python for portable applications. It's quite good both on Windows, all Linux distributions, *BSD stuff and even Mac OS. That's cool.

Plebraly
Not compiled at all
Jacob
http://effbot.org/zone/python-compile.htmOh yes!
Plebraly
A: 

Given the other answers below I think you need to make two choices

1) If you need a GUI not you need to choose the UI library either a cross platform one ee.g QT, wx etc or write different ones for OSX and Linux - Apples preferred way and I think gettting you the best look and feel on each platform

2) whether your application needs fast calculations as that could drive your language choice e.g. C++/C/Objective-C vs python

The two choices are separate as you can mix most GUI choices with different languages.

Mark
+1  A: 

How about FreePascal maybe with Lazarus if you're interested in GUI development?

RobS
Woah, that brings me down memory lane!
Jacob
I am a full time Delphi developer, and I think FreePascal is cool, and everything like that, but there's not a fully baked GUI binding that is cross-platform on both Linux and OS X. The GTK stuff requires X11 on Mac OS X. Ugly, and non-native looking.
Warren P