8

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
corydoras
  • 7,130
  • 12
  • 55
  • 58
  • 3
    Why does it have to be a **compiled** language, out of curiosity? – Mark Rushakoff Sep 28 '09 at 04:32
  • 4
    You can use Objective-C on any platform - the Objective-C compiler is part of the GCC distribution. The portability problem is Apple's Cocoa libraries. – Chris Lutz Sep 28 '09 at 04:51
  • 2
    What makes you think GNUstep will not cut it? It sounds like you want to write some kind of server back-end, and you shouldn't have a problem doing this using GNUstep. – Felixyz Sep 28 '09 at 11:42
  • @Sir Lord Mighty: GNUstep is a horrible hack. If you look at the source code for GNUstep it literally says "this is a hack" all over the source code. It's because the GNU Objective-C runtime is crap and has really fallen behind. The build system that GNUstep imposes on developers is nowhere near as nice as using Apple's extra GCC flag `-framework`. – dreamlax Sep 28 '09 at 22:09
  • 1
    It is looking like the best answer would be to use objective-c as an extension to c, but not use any of the apple/cocoa framework stuff, (ie NS* stuff) and write stuff like NSURLConnection ourself. – corydoras Sep 29 '09 at 04:58
  • We tried GNUStep and some things are quite simply broken. NSUrlConnection simply does not work properly at all. A simple test case that works on OS/X causes segmentation fault under ubuntu. – corydoras Sep 29 '09 at 04:58

11 Answers11

20

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
  • 4,743
  • 1
  • 20
  • 33
  • 6
    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 Sep 28 '09 at 07:51
  • 1
    @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 Sep 28 '09 at 16:02
  • 3
    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 Sep 28 '09 at 16:55
  • 1
    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 Sep 29 '09 at 05:51
  • @corydoras: If you use GNUstep you can make use of many of the NS* classes. – Amok Sep 29 '09 at 14:03
6

What sort of software are you trying to create?

The most likely answer is C/C++.

phoebus
  • 14,673
  • 2
  • 33
  • 35
  • 7
    There is no such language as C/C++. – David Thornley Sep 28 '09 at 15:51
  • 2
    You seriously voted me down for that? You've got issues, my friend. – phoebus Sep 28 '09 at 16:15
  • 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 Sep 28 '09 at 22:13
  • 1
    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 Sep 29 '09 at 03:50
6

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Palo Verde
  • 387
  • 2
  • 8
  • 1
    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 Z Sep 28 '09 at 06:04
  • @Jacob, not compiled to machine code, but it is byte-compiled. – dreamlax Sep 28 '09 at 22:10
  • @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 Sep 29 '09 at 05:00
  • 1
    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 Sep 29 '09 at 05:12
6

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.

Amok
  • 1,279
  • 9
  • 10
  • 1
    I agree, I use Objective-C all the time without Cocoa just because I find it easier to work with than C++. – dreamlax Sep 28 '09 at 22:12
  • +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 Sep 29 '09 at 19:44
4

How about java?

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

Johan
  • 20,067
  • 28
  • 92
  • 110
3

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

RobS
  • 3,807
  • 27
  • 34
  • Woah, that brings me down memory lane! – Jay Sep 28 '09 at 22:10
  • 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 May 17 '10 at 01:35
2

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
  • 64,444
  • 15
  • 143
  • 197
  • 2
    DO NOT use Qt for any app you plan to ship on OS X. – NSResponder Sep 28 '09 at 07:49
  • 2
    Why not? Have you got some personal experience of QT on OSX that you might like to share> – ConcernedOfTunbridgeWells Sep 28 '09 at 16:48
  • 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. – Amok Sep 29 '09 at 16:28
  • 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 May 17 '10 at 01:36
0

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
  • 4,365
  • 30
  • 36
0

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
rjoshi
  • 1,645
  • 1
  • 20
  • 31
  • @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 Sep 29 '09 at 06:02
  • you have to compile java to use it. I agree on python but I focused on cross platform and for quick development. – rjoshi Sep 29 '09 at 18:30
0

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

mouviciel
  • 66,855
  • 13
  • 106
  • 140
0

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.

mmmmmm
  • 32,227
  • 27
  • 88
  • 117