Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Best language for cross-platform mobile (non-UI) code? (Go? Haxe? C++?)
5 points by _alastair on Nov 1, 2017 | hide | past | favorite | 2 comments
I'm experimenting with making a cross-platform library (specifically for iOS and Android) and I'm curious to hear what languages other people who have done it ended up using.

The most obvious first thought is C++. I've only lightly dabbled in it, and the most frequent opinion I hear is that C++ is more "necessary evil" than "a delight to work with". So I started looking at alternatives, having used none of them before.

Go has built-in functionality to make Go code callable from Objective C and Java. But it's still the Go runtime underneath, just proxied out to native.

By comparison, Haxe can output both C++ and Java. Presumably it has some cleverness built into C++ to handle garbage collection, but it sounds like the output is more "pure" than Go would be.

But does that even matter? Haxe definitely feels like a more familiar language to write, but a more obscure language in terms of raw popularity (but it has generics!). Go feels more alien (and I'm concerned that it doesn't seem to let you explicitly handle threads, which has bitten me on iOS before), but everything I'm reading about how it's structured, testing etc. just feels very sensible.

Has anyone used any of these options to make a cross-platform library? Or is there another one I haven't thought of? I'm curious to hear any experiences.




I’ve worked extensively in C++ for cross platform on iOS and Android. It’s well supported - you cal C++ natively from Obj-C and use JNI patterns for Java. Cocos2d-x is a cross platform game engine built on C++ as well that has wide adoption and is production ready.

I also have not run into any task yet I haven’t been able to accomplish in C++ (threading, etc is well documented and you have a few options)

I’ve actually written a UI framework on top of Cocos2d-x (essentially C++ and OpenGL) which we use in production that has also been robust and allows us to just write it once and compile for iOS and Android.

C++ is definitely verbose but it is also very flexible and IMHO.


Xamarin is the obvious choice (C#, F#).




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: