TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Best language for cross-platform mobile (non-UI) code? (Go? Haxe? C++?)

5 点作者 _alastair超过 7 年前
I&#x27;m experimenting with making a cross-platform library (specifically for iOS and Android) and I&#x27;m curious to hear what languages other people who have done it ended up using.<p>The most obvious first thought is C++. I&#x27;ve only lightly dabbled in it, and the most frequent opinion I hear is that C++ is more &quot;necessary evil&quot; than &quot;a delight to work with&quot;. So I started looking at alternatives, having used none of them before.<p>Go has built-in functionality to make Go code callable from Objective C and Java. But it&#x27;s still the Go runtime underneath, just proxied out to native.<p>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 &quot;pure&quot; than Go would be.<p>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&#x27;m concerned that it doesn&#x27;t seem to let you explicitly handle threads, which has bitten me on iOS before), but everything I&#x27;m reading about how it&#x27;s structured, testing etc. just feels very <i>sensible</i>.<p>Has anyone used any of these options to make a cross-platform library? Or is there another one I haven&#x27;t thought of? I&#x27;m curious to hear any experiences.

2 条评论

ahlwong超过 7 年前
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.<p>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)<p>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.<p>C++ is definitely verbose but it is also very flexible and IMHO.
miguelrochefort超过 7 年前
Xamarin is the obvious choice (C#, F#).