10

I want to build a SyncML parsing library (no UI) which should be able to build up messages based on information provided by the host application, fed in by the library's methods. Also, the library should to be able to do callbacks to methods in the host application.

I want to be able to compile this and have it available on as many platforms as possible: Windows, Windows Phone 7 OS, OSX, iOS, Linux, Android, BlackBerry. Basically as many platforms as possible.

The priority is to have this available on mobile devices.

Questions:

  1. What setup should I use? (programming languages, compilers, IDE etc.)
  2. How would I compile this library for these different platforms and how would I connect to it?
  3. Any other info? e.g. articles that cover the subject of cross-platform development?

I haven't done this sort of a cross-platform project before, so any available information to put me in the right direction would be welcomed.

Myself, I have a background in C#/.NET and Objective-C.

Alex
  • 587
  • 1
  • 5
  • 12

4 Answers4

8

Using the Java platform / JVM would be the obvious choice - it has the widest cross-platform coverage of any language, and if you have a C#/.Net background the concepts will be very familiar.

Note that you don't have to use Java language to gain the benefits of the Java platform - in fact nowadays, if starting a project from scratch I'd probably recomemnd one of the following:

  • Scala - if you want a powerful, statically typed, multi-paradigm langauge with great performance on the JVM. Could suit you if you have a C# background.
  • Clojure - if you prefer functional programming, like dynamic languages and enjoy living on the cutting edge. Clojure has truly excellent concurrency capabilities which may be appealing - the linked video is well worth watching for some deep insights.
  • Groovy - if you want a simple-but-effective dynamic object oriented scripting language that will feel very familiar to C#/Java developers.

All these languages get all the benefits of being on the JVM (fantastic JIT compiler, very effective garbage collection, a huge set of libraries) but are much more productive languages to work in.

By the way, there's already an open source SyncML library available in Java called Funambol. Not sure of the extent to which this is useful directly to you but it's an example of the fact that there is usually an open source Java library for pretty much anything.......

Thoughts on other options:

  • C/C++ can certainly work cross-platform, but it requires a recompile (and subsequent testing) into native code for each platform. With JVM languages that isn't necessary as the compiled bytecode itself is portable. Unless you absolutely need C/C++ for performance or access to raw hardware features, I think it is a headache you should avoid.
  • C# in the form of Mono could work (witness the success of Unity as a cross-platform library for example), but it's nowhere the JVM ecosystem in terms of maturity, library availability or even raw performance. Also it's never going to be 100% compatible with Microsoft .Net since .Net has windows-specific features which are a nightmare for portability. Still, worth considering if you are determined to stick with C#.
  • Javascript might be an outside option if you are interested in using the library on both the client and server side.
mikera
  • 20,617
  • 5
  • 75
  • 80
  • 1
    Thanks for the great answer. Do you know how well one can port Java to the iPhone, in the form of a library or framework? Also, can't use Funambol, the point is to make my own library. – Alex Nov 25 '11 at 11:04
  • 2
    I understand Apple are being quite restrictive about Java on the iPhone at present. I expect market pressure will cause it to happen more in the future - this article http://www.theserverside.com/discussions/thread.tss?thread_id=63072 for example talks about Oracle demonstrating a Java-based app in the iPod Touch. – mikera Nov 25 '11 at 11:21
  • +1 for educating me on not needing to use Java per se, but one can use Scala, Clojure, Groovy. Fascinating answer. – Anthony Aug 25 '12 at 09:29
4

.NET is hardly available on many platforms, and Objective-C is even worse, plus .NET is kinda slow and ObjC has basically no support outside Apple. C as a language is basically not even worth considering unless some external factor makes you use it.

The only result viable language is C++.

DeadMG
  • 36,794
  • 8
  • 70
  • 139
  • 2
    Do you know anything about the advantages of using the Mono project in combination with C#? Why isn't C worth considering? – Alex Nov 24 '11 at 16:23
  • 2
    @Andrei: As far as I know, Mono is hardly the picture of availability on all the platforms you've listed. And C isn't worth considering because it's just like C++, but with all the good features cut, which is obviously a stupid thing to do if you can use C++. – DeadMG Nov 24 '11 at 16:32
  • 4
    @DeadMG: I'd love to see you debate that point with Linus Torvalds: http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918 - not saying that he must be 100% right, I'd just like to watch the flamewar. – Michael Borgwardt Nov 24 '11 at 17:15
  • 1
    @Michael: I will not, in fact, have a flamewar. – DeadMG Nov 24 '11 at 18:30
  • 2
    @DeadMG C isn't C++ with the good features cut; C++ is C with horrible features added. There is nothing wrong with C. –  Nov 24 '11 at 21:13
  • -1 for poorly argumented statements. –  Nov 24 '11 at 21:25
  • 2
    @WTP: He asked for a recommendation, not my life story. The simple fact is that whatever you think of C++'s extra features, the fact is that they exist and they make C++-only code accessible, which is a bonus, and C is nothing C++ isn't- the reverse is not true. When you use C++ over C, you only *add* choices. Therefore, by definition, C++ is a superior language, and you can always *choose* not to use the C++ features. Which would be insanity, but you can. – DeadMG Nov 24 '11 at 22:16
  • 1
    It's hard to vote for an answer that says "C... is basically not even worth considering". Seriously? C is a fine language, still worth considering for many projects. It's considerably better than just "C++ with all the good features cut out" – Bryan Oakley Aug 24 '12 at 20:25
  • The biggest problem with C is it has no automatic resource management whatsoever, meaning your code is going to be littered with hard-to-maintain init()/destroy() calls in every code path, or goto statements everywhere which jump to cleanup code. That alone is reason enough to prefer C++, which gives you RAII (automatic resource initialization/cleanup). C also has no good way to write generic code. (void* and function pointers are absurdly inferior to C++ templates or even polymorphism) – Charles Salvia Aug 25 '12 at 01:33
  • -1 for not mentioning Java, which is much more practical to use than C++ for writing cross-platform software. – Giorgio Aug 25 '12 at 07:58
  • You're right. It's shitty generics, no lambdas, no decent resource cleanup, etc make it so great for libraries. How could I *not* have included it? – DeadMG Aug 26 '12 at 15:48
  • @DeadMG: The topic of the question is what language to use for cross-platform development, not what language has a better set of features. C++ may have more features than Java but in my experience it is not as easy to port between different platforms or compilers. In Java you can develop a product on Linux and deploy on Windows or another platform without changing a line of code. – Giorgio Aug 26 '12 at 20:38
3

You might want to try Java - Java Runtime Environment (the virtual machine) is cross platform, Java may be used in mobile devices with Android (or with Java ME) and .NET is very simillar to it.

malejpavouk
  • 279
  • 1
  • 6
3

This is not one choice but many. While it is tempting to find one thing that goes everywhere, it is not always the best way to do.

  1. For example, while it may be possible to squeeze a C++ code in Windows mobile platform, anything .NET will always be easier here than its' counter part from the point of view of support.

  2. Similarly, one needs to make a major choice whether you want it to be native or under run time and are you strictly limited to Web centric or more generic powerful one? For example, Adobe Runtime is more omnipresent but it will limit to what you can do compared to with core programming languages.

  3. Most important thing i guess, is the type and level of GUI you want to built.

Now comming to most promissing choices.

a. For Symbian, Blackberry, Android, BREW and Bada (samsung) Java/J2ME is the commonest way. Though, you might be better of with C/C++ in many cases, for native core stuff in some platform.

b. For Windows .NET with any supported language would be good.

c. For iOS - there is no choice but Objective C. This is NOT very much C++ so i won't count it as a objective

Here is a wiki reference which shows set of all platforms that shows you all options and where they apply.

Thanks to your question, i learned from the above wiki link that there are now SDKs, that try to solve above problem. The two that comes closest are:

  1. Marmalade : http://www.madewithmarmalade.com/marmalade/supported-platforms this interestingly support almost all platforms. Windows is just about getting added to make complete circle.

  2. Particle Code : http://www.particlecode.com/

I have not used them yet, but sounds interesting work.

Dipan Mehta
  • 10,542
  • 2
  • 33
  • 67