
10 Oct 2016 YOW! Connected 2016: The typed-functional future of UI platforms
I just spent a couple of days at the YOW! Connected conference and had a great time, despite nursing a bit of a cold. There were a tonne of great talks at the conference covering a wide range of topics, but in this post I’m going to briefly reflect on one specific trend that interested me at the event: the way in which UI platforms are advancing to adopt modern languages, and are even influencing each other in the process. The end-result: they’re all moving towards languages that are both functional and statically typed.
Full disclosure: This year I was a member of the programme committee for the conference. So in writing this post, there’s a bit of a risk that I’m creating an echo chamber for myself. All I can really say in my defence is that I hadn’t consciously made these connections in advance – it was only afterwards that I saw a trend!
Swift
These days I’m more of a Javascript developer than anything else, but I always like to keep an eye on what the native mobile developers are up to. To be honest I’m actually a bit jealous of Swift developers, as Swift looks like a fantastic language for getting into typed functional programming.
Manuel Chakraverty’s talk ‘A Type is Worth a Thousand Tests’ exemplified this, and also won my vote for best talk title of the conference. It was an engaging introduction to the power of Swift’s type system. As a JS developer I have to write a lot of tests to have confidence that my code isn’t going to die at any moment. Manuel’s main point was that a type system can take some of the burden off of you, especially when it is seen as a design tool which can disallow code that would cause your system to go into an invalid state.
I was a Java developer for 10 years so I was already aware of the benefits of a static type system. The problem with Java’s type system is that it’s overly verbose, and using higher-level type abstractions is clunky, to the point that it’s not really practical.
Newer languages let you use types far more concisely, and a modern type-inference engine can infer a lot from your code. Modern type systems also let you use far more powerful type abstractions. The end result is that you’ll still need to write tests, but not nearly so many, as the compiler will do much more of the leg-work for you. I like to think of it as another tool for the code-quality toolbox.
Finally, the good news for JavaScript developers like me is that JS type checkers like TypeScript and Flow are rapidly gaining adoption. I’m hoping to see them used more and more in the JavaScript projects I work on.
Unidirectional Data Flow
It was appropriate that Manuel’s talk was immediately followed by Sam Ritchie’s ‘Unidirectional Data Flow for Mobile‘. It was exciting to see how Sam has evolved the work he presented with me last year as part of our ‘Rethinking MVC with React Native and ReactiveCocoa‘ talk at YOW 2015.
In that talk, I spoke about how the underlying programming model of React allows us to write UI code that is easier to comprehend and reason about by letting us describe components within our UIs as functions whose output will always be the same for a particular set of inputs. Mutable state can be tightly controlled, and even in some cases completely eliminated.
Inspired by React Native but determined not to use JavaScript, Sam followed up by embarking on a journey to introduce one-way data flow techniques to Swift programming. The upside of his approach is that, rather than just looking like a weird port of React, Sam’s work more fully leverages Swift’s type system and looks much more Swift-like than any React clone could be. Furthermore, he seems to be accomplishing it without having to use a virtual view hierarchy, which will in-turn help him avoid some of the more gnarly impedance mismatches that exist between Cocoa and the React model.
Whilst acknowledging that his work was still very much in-progress, Sam nevertheless impressed me with what he has managed to accomplish so far. He also continued his hilarious/appalling tradition of inserting the worst puns and dad-jokes he can find into his conference presentations. Nice work Sam!
Kotlin and Anko
Whilst an officially-sanctioned language revolution is leading to all sorts of innovation in the iOS development space, an unofficial revolution is happening over in Android-land. I wonder whether a similar wave of innovation will follow in its wake.
Disillusioned with the verbosity of Java – especially pre-version 8 – Android developers are now looking at Kotlin as a viable alternative, especially since it went to version 1.0 at the start of the year. Such is the level of interest that we had at least 5 proposals for Kotlin related talks at YOW! Connected this year.
Sadly, to avoid skewing the programme too much, we could only pick two of them. First was an introductory talk entitled ‘Kotlin: The Pragmatic Language for Android‘ by Mike Gouline. I didn’t go to this talk because I’m already familiar with the basic principles of Kotlin. However, I think the title of the talk summarises perfectly the appeal of this language for Android developers. It’s modern, accessible and practical.
The second, more advanced Kotlin talk was Kai Koenig’s ‘Anko – The Ultimate Ninja of Kotlin Libraries‘. In this talk Kai introduced Anko, an official JetBrains Kotlin library for simplifying Android app development. Its headline feature is a DSL for describing user interfaces. This is a massive improvement over the traditional XML-based approaches used by Android for describing user interfaces. I was also reminded of React’s approach of using a DSL to declaratively describe a UI, which led to a bunch of innovation across the whole JavaScript framework space. Maybe Kotlin and Anko (or something like it) will inspire a similar wave of innovation in the Android space?
Linking it all together
So wrapping all of this up, I see two interesting things happening with UI development at the moment:
- All of the platforms are moving towards typed-functional languages of one form or another. Furthest along the track is iOS with Swift. Who’s coming next is a matter of debate: the web community is seeing increased adoption of TypeScript and Flow, whilst Android developers seem to be getting pretty excited about Kotlin and the frameworks that it enables.
- Platforms are starting to embrace different functional paradigms for building UIs. JavaScript has undoubtedly driven this, in particular the React framework. Now, enabled by modern functional languages of their own, iOS and Android are starting to move in that direction too. I’m hoping that Kotlin will be able to enable some real innovation in the Android space too.
Whilst purists may argue about how ‘functional’ each of these new languages is, the real question is this: are they ‘functional enough’ to enable new functional paradigms for building UIs? Generally speaking, I think the answer is yes. The future of UX development will be both functional and typed, irrespective of which platform you use.
No Comments