views:

2519

answers:

19

Hello, I would like to build an application that runs on both Windows and Mac OS X. I would also like it to leverage the best of what the platform it runs on has to offer with regards to Frameworks, API's etc. Is there a way to do this without having to write Objective-C code and then C# code? I've been thinking of C++ as an alternative but I was wondering if there was anything else out there. The app will be GUI based (though I don't know exactly what it will do yet)

-G.

+3  A: 

For the GUI, I'd look into SDL or QT.

Also, check out mono http://mono-project.com/Main_Page

BenB
SDL is a great solution for games - but for a GUI app? Seriously?
Sherm Pendley
+1 for Qt. Dunno about SDL though.
jop
A: 

As long as you are not tied to languages, it looks like Java is a good candidate. Pair that up with SWT for the GUI, and you will have a native looking app on any OS you like.

James Van Huis
Except Java programs are notoriously "bad" on the Mac. File dialog boxes don't work as expected, and everything just feels wrong. (And I develop in Java, at least some of the time!)
Matthew Schinckel
Even with SWT? That would seem strange to me given the number of developers running Eclipse on Macs.
James Van Huis
>>File dialog boxes don't work as expectedThat's easily fixed, just use java.awt.FileDialog instead of javax.swing.JFileChooser
Tony Edgecombe
+11  A: 

Take a look at RealBasic. Seriously. You can write an app in RealBasic and deploy it on Windows, Mac OS X, and Linux.

Robert S.
It's amazing to me that this has been the only real option to target all 3 for several years.
bruceatk
I didn't know there was an OO, updated version of BASIC. NEAT!
EndangeredMassa
+28  A: 

It's good that you're thinking of portability early on - it's vastly more difficult to "bolt it on" after the fact.

There are various cross-platform kits available, but IMHO all of them fall a bit short of providing a "native" look and feel on all the supported platforms. On the Mac (what I use), proponents of such kits always want to mention that they're using native controls. That's a good start, but it's not the whole journey. Other issues addressed by Apple's Human Interface Guidelines include how the controls should be arranged, how button labels should be phrased, what standard shortcut keys should be used, etc.

Even Microsoft had to learn the hard way about the dangers of trying to write a cross-platform GUI, with the ill-fated Word 6.0 for Mac.

IMHO, a better approach is to use an MVC design, with the model layer written in standard, portable C++, and the view and controller layers using the native toolkit for each platform. Your Mac version, for instance, could use Carbon and C++ throughout, or you could use Cocoa, using Objective-C in the view and Objective-C++ in your controllers to bridge the language gap. Your Windows version could likewise compile your model as "managed C++", and use any .NET language for controllers and views.

Sherm Pendley
This one says it all.
jop
I would suggest staying away from Carbon/C++ for the Mac version, since Apple isn't porting Carbon to 64-bit. While that might not matter now, it shows that Cocoa/Objective-C is the future of Mac programming IMO.
Andy
Do you have, or know of any links to sample projects written this way?
GONeale
Hmm, the pattern is more complex, and you have to write larger parts of the app twice. Nice in theory, but it comes at a cost.
Marco van de Voort
Unfortunately ~75% of the logic of a GUI app is in the GUI, not the model (I have verified this in own app).
Andy Brice
+2  A: 

If you're a Windows developer, use either Qt or C# Winforms; if you're a Mac developer, you could try Cocotron (http://www.cocotron.org/), but it's not 100% finished yet, though commercial apps have been shipped with it.

Paul Betts
I'm seriously looking into Cocotron now too. Looks very promising.
Matthew Schinckel
+6  A: 

wxWidgets is a cross platform C++ library, which is a practical choice. But I agree with Sherm - all cross platform libraries do create an inferior UI to native applications.

It's made harder by each OS having different UI semantics (button orders etc), so while you may achieve a good look, getting the 'feel' right on each platform via one view layer is almost bound to be impossible.

Depending on what you end up doing, you may find a web interface better (e.g. embed a web server in your app and serve HTTP pages to a browser). You avoid the L&F issues then!

Alternatively, you can decide you're just going to have a completely non-standard L&F, and go for something like wxWidgets, or Tcl/Tk.

Jamie Love
That last is a great point. For some specialized "vertical" apps, self-consistency may be more important than platform consistency.
Sherm Pendley
If you're going to build a web app, skip the web server and use Adobe AIR
John Sheehan
While I'm not fond of non-standard LAF's, they're ok, provided they're not ugly and awful to use. IMHO wxWidgets and Tcl/Tk are both ugly and awful to use... Beware
Orion Edwards
A: 

I'm planning to do a similar thing, and I'm considering creating a C#/.NET Windows application and then porting it to OS X using Mono. My application already has a completely (except for the title bar and corner buttons) custom-drawn user interface, so the cosmetic OS differences shouldn't affect me too much.

I'm not sure what you mean by leveraging the best of each platform in terms of frameworks and APIs and so forth. In general, writing a cross-platform application means writing to a least common denominator, and thus means not getting the best out of each platform.

MusiGenesis
+3  A: 

If you do decide to go with C++ there are a number of good cross-platform GUI libraries that will allow you to avoid having to duplicate the GUI code for each platform. For example:

There are a number of other similar projects but those are some of the better and more well-known ones. For the remainder of your code, anything system-specific will of course have to be written using separate C++ code to interface with Win32 APIs or OS X's system API where necessary. That being said, you may find you're able to avoid much of the system-specific code by using extensive libraries like Boost.

Other suggestions would be things like using a configuration file instead of the Windows registry or a plist file on the mac. Instead, shoot for platform-agnostic approaches wherever possible to minimize the places where you have to write code using system APIs.

Jay
+3  A: 

You should use the best tools available for each OS.

C/C++ code can be separated from the GUI and used in each separately developed program.

Before you make a decision, take a look at cross-platform apps that have been developed with portable toolkits such as Qt or wxWidgets. In my experience they are never as polished as their native counterparts, especially on the mac.

titaniumdecoy
+3  A: 

Adobe Flex, with the AIR libraries, does a good job of giving you a single, highlevel development environment for this sort of thing. I've written several utilities that people use on both platforms interchangeably.

You also get reasonable portability to a browser thrown in, too, if that's of interest. But I think it's a pretty good solution without considering that benefit.

le dorfier
A: 

Java or Mono come to my mind. Some people may argue that java graphical toolkits are not the cuttest out there but it seems to be, at least to me, the easiest way to port your application to several platforms and avoid deployment difficulties.

Mono, on the other hand, could be a little bit more difficult to port as you would have to write at least the gui twice if you plan to have native widgets (either winforms or GTK for windows and CocoaSharp for Max) but you could write the backend only once and develop a frontend for each platform.

As I said, Java GUI toolkits might not feel "native" inside OSX or even on Windows but they sure work on both platforms, you could use either Swing or AWT.

As for mono, you can use GTK or Winforms for both windows and OSX but they still will not feel native, you can, however use CocoaSharp which are bindings to the Cocoa framework but Im not sure about the status of the project (read: functionality support)

Gustavo Rubio
A: 

I second Java. It is designed as a cross-platform solution.

Others have mentioned Adobe Air.

Similar to Adobe Air is Silverlight. I believe it is (or will be) completely cross platform.

Atømix
+1  A: 

Also check out fltk , wxWidgets is very good & rich but also very big...

Malkocoglu
A: 

You can create fantastic looking cross platform applications with Java Swing. It just requires slightly more effort to learn to do so.

Here, take a look at some of these links.

  1. http://jidesoft.com/products/component.htm
  2. http://www.xerto.com/imagery.php
  3. http://www.jgraph.com/screenshots.html
  4. http://www.javootoo.com/
  5. http://www.formdev.com/screenshots/
  6. http://www.jidesoft.com/products/oss.htm
swapnonil
+1  A: 

As others have mentioned is is definitely possible to create good looking cross platform GUI in Java on both Windows and Mac. However if you want your app to blend in and behave in a way that makes it "feel" like an application designed from the ground up for the platform it is running on, you really have to develop the GUI and user experience for each version of the application separately.

If you analyze what your application is going to do and figure that there is a significant portion of code/logic that could be shared between platforms then write that portion in a portable way in a language that is available on both systems. C, C++, Java, Python, Ruby, etc. If there isn't a significant portion, ie most of the code is going to be for the GUI then there is less of a case for sharing any code at all.

In the case that there is a significant portion of common code, I would suggest looking into Python and Ruby as implementation languages as there are Cocoa bindings for those languages on the Mac and on Windows with the use of IronPython and IronRuby you could use reuse that code in a .Net application as well.

orj
+3  A: 

The upcoming QT-Creator might be worth a look: link text

TheMarko
A: 

The guys at Magnetism Studios have a nice write up on using Cocotron to build a Windows executable with Xcode.

I have no experience with Cocotron, but if I needed to write a windows app —with a Mac development background— this would be the first thing I'd try.

Dirk Stoop
+2  A: 

thanks for all your answers. I've been doing some research and playing around with WPF and CAnimation etc. It looks like using a C/C++ model and doing the GUI individually for each platform is the best way to go. Thanks for all your help.

armahg
+2  A: 

My suggestion, use Python. Python integrates with both Objective-C and C# (IronPython). Just avoid a lot of the brand new bleeding edge features of the language and you're ok.

Granted, it won't be mindlessly easy. But I'd argue that it shouldn't be mindlessly easy. It becomes very apparent when designers don't take into consideration how their application will work when it gets ported to another platform.

Jason Baker