Hacker News new | ask | show | jobs
by moonchrome 3771 days ago
>but being able to develop libraries in one language and use them in both Android and iOS is huge

I have no doubt that there are mobile only apps that would find this valuable - but swift is still only linux/android and osx/ios - if you want truly portable code - that can compile to browser/mobile/server/desktop you're stuck with C++ for the foreseeable future.

3 comments

I've tried Haxe, Racket, TCL/tk, MOAI (Lua based), and others, but I am now using 8th, a Forth-like language that compiles to Android, iOS, Windows, OSX and Linux [1]. The only downside is that I still need a Mac to publish iOS apps. For Android, Windows and Linux, I am good to go. It uses the JUCE library for gui implementation. I have made two toy apps for Android so far, and I am still learning. It has a good library so far, but some people find Forth difficult. I find it concise, expressive and still readable after 6 months. The shortness makes code review a breeze.

  [1] http://8th-dev.com/
What a strange beast! A closed source language is always a tricky sell. Forth is never an easy sell in itself (unless you've already been bitten by the bug ;-) in which case it's a wonderful bonus). The tutorial is PDF only - which just seems a bit odd.

I'm intrigued by 8th - in a good way - and happy you've introduced me to it - but I do wonder what kind of uptake something like this will get.

It is a bit odd, but I am rocking with it. I have done Java and NDK in C++ tutorials to get simple programs running, but nothing original, or beyond what the tutorial provided. With 8th, I can whip up something quick with a GUI, using the sensors and other libs it comes with, and deploy it. It looks the same on Windows, Android and Linux. The developer makes him self available, and quite honestly, the code is succinct enough and the documentation good enough that I only asked a lot the first week. You should give it a try. I am by no means a 'Forth programmer', and 8th is not a compliant Forth.
How so? Doesn't this port to Android show that a Windows port is surely possible? Swift is already running on servers afaik. As for compiling to "browser," Swift is based on LLVM so should be just as capable of this as C++.
What's "possible" and what's available and tested in production right now are two very different things. These kinds of ports take at least a year to get over the initial troubles and become usable and then you're at least that time away from a decent size of community libraries to spring up for the mentioned platforms.

By that time Rust will also mature enough and webasm will land so Rust will probably be a better candidate (since it's OSS and developed by a browser company that needs to run on as many platforms as possible they have much better incentives to maintain ports than Apple).

Also in that time C++ will probably get modules working on clang and many c++17 features.

And you might see Xamarin merge into CoreCLR and rolled up into VS integration.

A lot of things are possible - but what's available right now is C++ on every platform and not much else.

What's the canonical way of targeting Android with C++?
Write shared logic in C++ and use JNI/JNA ? Or are you asking about something more specific ?
I guess I found what I was asking about, i.e. NDK: http://developer.android.com/ndk/index.html
I'm not sure about how mainstream/supported C++ is in the Android world.
Just as much as everywhere else, we're using it extensively for sharing code. If has a few qurks but it's easy better than windows for example.
Are you using NDK? I was reading about it earlier, it is something that I would like to look into, when I have some time.
Yes, NDK is after all just a name for preconfigured GCC and Clang package shipped by Google :)

We use Clang 3.5.