“Groovy is the Swift-alternative for Android
Java derivative language creator sees Groovy as the Swift-alike for Android programmers – and after all, the two have a lot in common.
When fruit falls from the Apple tree, everyone’s got an opinion – as we saw with Tuesday’s big reveal of glossy proprietary language Swift, designed to make certain aspects of programming for OS X onwards Macs, iPhones and iPads easier to grasp and faster than with old stalwart Objective C.
One of the first to publish their thoughts was Groovy creator Guillaume Laforge, who blogged that, “an acquainted Groovy eye would immediately notice the inspiration the Swift designers took from Groovy.” Akin to Swift, Groovy is also derived from a major language – in this case Java. There’s a very meagre learning curve for Java devs, and, whilst there’s a welcome lack of Java’s verbosity, there are a host of additional features for Groovy users to enjoy like (similar to lambdas in Java 8, but, as Laforge notes, Android developers don’t have Java 8), “builders, runtime and compile-time metaprogramming.”
Laforge’s colleague and fellow Groovy committer Cédric Champeau has taken the love-in one step further, emphatically recommending Groovy as Android’s respective Swift counterpart. In a recent post, Champeau recommends that anyone impressed by Swift take a good long look at Groovy. He writes that Android users yearning for a language which is “as modern as Swift is, but running on Android” need look no further than the “Groovy language.”
Rubyists: Swift looks like Ruby Groovy devs: Swift looks like groovy Scala devs: Swift looks like scala Java devs: WTH is a closure?— roberto.guerra (@robertoguerra19) June 5, 2014
Lest anyone accuse Laforge and and Champeau of merely jumping on the “we-did-it-first” bandwagon (with the diverse functionalities within Swift, there’s plenty of fodder for multiple communities to make these sort of claims), Apple did in fact make a direct reference to Groovy during Swift’s big reveal – however Laforge does dispute Apple’s less-than-flattering assessment of his progeny in terms of performance.
Side by side, there are indeed some clear similarities between Groovy and Swift, namely; syntax for lists and maps, similar closures, syntactic rules and safe navigation. A full assessment, slides and code examples can be found in Cédric’s original post. Those who want to be further persuaded why Groovy is so fab should also take a look at our interview with Guillaume Laforge, recorded at JAX 2014: