Best compiled language for Mac OS X and Linux compatibility [closed]
Asked Answered
X

11

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.

Xiphisternum answered 28/9, 2009 at 4:27 Comment(6)
Why does it have to be a compiled language, out of curiosity?Vinnievinnitsa
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.Kaiserdom
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.Byrnes
@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.Stench
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.Xiphisternum
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.Xiphisternum
B
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.

Bustamante answered 28/9, 2009 at 4:40 Comment(5)
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.Flummery
@Flummery - 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.Kaiserdom
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.Outrageous
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 (:Xiphisternum
@corydoras: If you use GNUstep you can make use of many of the NS* classes.Elinorelinore
N
6

What sort of software are you trying to create?

The most likely answer is C/C++.

Nalley answered 28/9, 2009 at 4:34 Comment(4)
There is no such language as C/C++.Sharpen
You seriously voted me down for that? You've got issues, my friend.Nalley
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.Hoofer
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.Nalley
S
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.

Socorrosocotra answered 28/9, 2009 at 4:49 Comment(4)
Python is not nearly as fast (to run) as C/C++, but if execution speed is not critical, it should be a good choice.Carmagnole
@Jacob, not compiled to machine code, but it is byte-compiled.Stench
@Stench - 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.Kaiserdom
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.Xiphisternum
E
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.

Elinorelinore answered 28/9, 2009 at 5:9 Comment(2)
I agree, I use Objective-C all the time without Cocoa just because I find it easier to work with than C++.Stench
+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.Goolsby
U
4

How about java?

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

Upswell answered 28/9, 2009 at 5:13 Comment(0)
V
3

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

Vernverna answered 28/9, 2009 at 15:53 Comment(2)
Woah, that brings me down memory lane!Marlowe
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.Scary
O
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'.
Outrageous answered 28/9, 2009 at 6:38 Comment(4)
DO NOT use Qt for any app you plan to ship on OS X.Flummery
Why not? Have you got some personal experience of QT on OSX that you might like to share>Outrageous
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.Elinorelinore
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.Scary
P
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?

Peake answered 28/9, 2009 at 4:30 Comment(1)
There is no such language as C/C++.Sharpen
S
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.

Scherle answered 28/9, 2009 at 4:40 Comment(2)
@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.Hoofer
you have to compile java to use it. I agree on python but I focused on cross platform and for quick development.Scherle
C
0

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

Compatriot answered 28/9, 2009 at 9:4 Comment(0)
P
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.

Perspex answered 28/9, 2009 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.