Ask HN: Safe languages available on all major platforms?

5 points by cottonseed ↗ HN
I'm thinking about an application that I'd like to deploy on all major platforms (OSX, Linux, Windows, iOS, Android). My go to language is C++, but I'd like to use a type- and memory-safe language (goodbye, buffer overflows). What are my realistic options? Rust, golang and ocaml come to mind, although it doesn't look like there is official ocaml support for iOS/Android. Any other good options I'm overlooking? Any experience you can share? How is integration with native libraries and services (e.g., UI, networking, file system)? Thanks!

17 comments

[ 2.9 ms ] story [ 85.7 ms ] thread
GUI, CLI, or both?
Both, although the core application could be CLI only, and the UI written separately.
I honestly don't know of anything that fits your criteria. I know Go recently got an iOS port, though. Rust is definitely too young. No idea about OCaml.

Unfortunately, the most portable language is JavaScript, and that isn't what you're looking for.

.NET fits his entire criteria. Memory safe, type safety, open source, runs on all desktop and mobile platforms, available in either OOP (C#) or functional (F#) and has fantastic tooling.
When you say .NET runs on all operating systems, are you referring to Xamarin? If not, I'd be very curious what else is out there.
I'm referring to Mono; Xamarin = targeting of iOS/Android via commercial license.

.NET is now licensed under MIT and is being developed out in the open by Microsoft on GitHub. vNext (5.0) is being concurrently developed/tested on linux (mono), osx (mono) and windows. https://github.com/aspnet/home which also means the platform is being unshackled from IIS via project OWIN (http://whereslou.com/2014/06/10/asp-net-vnext-moving-parts-o...) and the SDK is no longer a system wide installation, instead it ships with your application (https://github.com/aspnet/XRE) which enables .NET to be dockerized. Visual Studio is no longer required (it's preferred) but there are other options -> http://www.omnisharp.net/

Check out http://www.hanselman.com/blog/IntroducingASPNETVNext.aspx for a overview.

(comment deleted)
C# via Mono using Xamarin tooling is realistic.

https://xamarin.com/platform

This looks like a good suggestion, but I'm planning to make parts of this free software and it looks like the Xamarin platform is not.
The Xamarin tooling isn't all free, but Miguel de Icaza [1] is a major figure in open source. I'd be surprised if any Xamarin product necessitates closed source.

Even if it did, helping to put food on his table would benefit the open source community. There aren't many people about whom that can be said with less doubt.

https://en.m.wikipedia.org/wiki/Miguel_de_Icaza

The free version of the Xamarin tools seem to have limited app size and doesn't include their UI integration (Xamarin.Forms):

https://store.xamarin.com/

$25 for Indie which includes Xamarin.Forms
I misunderstood. I thought your objective was to produce free as in speech and beer software.

One reason cross platform tools often require payment is that Apple's terms for the iOS app store require the use of Apple products for development. Part of the cost goes to maintaining remote services on Macs to comply with those terms.

The alternative for iOS development is to purchase, rent, or borrow a Mac and develop in Objective-C, Swift, or JavaScript. That's probably less optimized for type safety, cost, and cross platform deployment.

If you drop iOS, the JVM and Java is an alternative.

Haskell claims cross-compiler support for iOS and lists some ways to get it to work on Android.

Probably be easier for the non-GUI parts. Networking and filesystem is probably trivial. It doesn't sound like you need much access to the device otherwise, but that would be something I would check before using -- they probably do some kind of native-bridge.

.NET - if you're into OOP use C# and if functional is your thing use F#

Fantastic employment prospects, completely open source, runs on all desktop and mobile platforms.

I forgot about F# on Mono. It's probably a bigger leap from C++ though.