BT

Groovy 2.4 Released, Brings Full Android support

| by James Chesters Follow 1 Followers on Jan 27, 2015. Estimated reading time: 2 minutes |

Guillaume Laforge has released Groovy 2.4, bringing with it full Android support.

Head of Groovy development, LaForge says with the new Android support Groovy is being opened up to a wider range of developers.

Speaking to InfoQ, LaForge elaborated:

We're hoping Android developers will be happy to see their code being streamlined thanks to our various language shortcuts, and our closures that are helping to get rid of the verbose anonymous inner classes plaguing the Android SDK.

Going forward, we're interested in applying the same boilerplate-killer attitude towards simplifying the development of Android mobile apps with Groovy.

To that end, there's a community project called SwissKnife, offering several Groovy code transformations that will allow developers to focus on the business at hand rather than on that boilerplate technical code (handling UI vs background threads, dealing with event handling, with "parcelable" entities, etc).

Cédric Champeau, author of the static compiler for Groovy, in his June 2014 blog post introduced Groovy on Android and demonstrated how Groovy can be used to reduce the verbiosity of Java on Android with the example of Asynchronous tasks.

To parse a JSON feed, and then update the UI accordingly, in Groovy a developer needs to only write:

public class FeedActivity {
    TextView mTextView

    ...

    void updateFeed() {
    	Fluent.async {
            def json = new JsonSlurper().parse([:], new URL('http://path/to/feed'), 'utf-8')
            json.speakers.join(' ')
        } then {
	    mTextView.setText(it)
        }
    }
}

Because Google has also settled on Gradle for build automation, to build Android apps with Groovy support developers will also be able to use the Gradle Groovy Android plugin.

In the Groovy 2.4 getting started guide, more information is given on the Android support.

It says:

It is possible to write an Android application in Groovy. However, this requires a special version of the compiler, meaning that you cannot use the regular groovyc tool to target Android bytecode. In particular, Groovy provides specific JAR files for Android, which have a classifier of grooid.

Other notable improvements to Groovy in 2.4 relate to performance, including efforts to "reduce the quantity of bytecode produced, to lower memory consumption of internal data structures, and fine tune bytecode for better performance."

Groovy 2.5 promises for developers improvements to the dynamic runtime, updated grammar with a newer parser, and support for some Java 8 features. LaForge says the most visible aspect is the Java 8 support, and the decisions around which features of Java 8 to support.

The Groovy team worked with the New York Times dev team to refine Android support, and it has been announced the next New York Times Android application will be based on Groovy and RxJava.

As reported by Victor Grazi for InfoQ on January 19 ("Pivotal Pulls Groovy/Grails Funding") the Groovy and Grails teams are still looking for new homes and sponsors. While LaForge says development on Groovy will continue, he notes that  it will likely evolve at a slower pace, with the team only able to work on it in their spare time.

Any InfoQ readers who would like to support Groovy, are encouraged to reach out to their managers and CEOs to see if their companies would be interested in funding the development of the Groovy project.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT