F# Native App Development on iOS and Android
F# has supported both iOS and Android native programming through Xamarin since at least Xamarin 4.8 and can be efficiently used to create native apps on both platforms. Let's give a look at some experience reports.
Rachel Reese, senior software engineer at Firefly Logic, recently gave a talk at the Nashville .NET User Group showing how to write fully native, cross-platform mobile apps entirely in F#. Rachel also provided an interesting feature comparison between F#'s and Apple's new Swift language. According to Rachel, while it is true that several F# features, such as discriminated unions, pattern matching, custom operators, optional type, and the REPL, can be found also in Swift, Apple's new language for iOS and OS X, the latter is still missing out on important F# features such as type providers, type inference, parallelism and async support at the language level, and more. She remarks that:
With each new release of Xamarin Studio, the mobile story gets even better for functional programming.
Faisal Waris, iOS and Android consultant, recently summarized his experience developing a complex app for Android using F#. Faisal's app has more that six thousands lines of code, with a complex UI including custom controls, and non-trivial background processing. He says:
Xamarin F# support is now very good and I will gladly recommend that for production use. When I started out, F# support was still in beta and I ran into many issues. However the Xamarin team was super responsive and have rapidly advanced the plug-in to where it is it now stable and very usable ... Instead of 6K, equivalent Java code would be in the 50K LOC range and of untenable complexity. I think F# is a great language for mobile computing.
Faisal is also the author of VL, a DSL in F# that allows to specify Auto Layout constraints on the layout of iOS controls. Thanks to VL, Auto Layout constraints are specified in strongly typed manner, which allows to catch some layout issues early on, says Faisal. VL makes use of F# Algebraic Data Types, pattern matching and operator overloading to offer a good example of the flexibility and expressiveness that F# can provide.
Neil Danson, software engineer, gave a nice introduction to developing apps for iOS with F# at a recent F#unctional Londoners Meetup. F# is fast, says Neil, since it compiles to native code, and it's complete, providing all the available APIs. Anyway, adds Neil, it is not as fast as Objective-C and F# apps have slower startup time. Neil also mentions that F# is particularly well suited to mobile app development thanks its async behaviour that allows to easily exploit non-blocking I/O and multicore CPUs, and portability across mobile platforms. On his BitBucket account, full implementations of two games for iOS and Android, Pacman and Pissed off owls, are available for download.
F# is a strongly typed functional-first language that uses type inference and additionally supports both the imperative and OO paradigm. F# is developed by the F# Software Foundation, which includes Microsoft and open contributors. An open source, cross-platform compiler for F# is available from the F# Software Foundation.
Anatole Tresch Mar 03, 2015