Which Language Wins Android Development? Java vs Groovy vs Scala vs Kotlin

This article compares Java, Groovy, Scala, and Kotlin for Android development by examining minimal dependencies, code snippets for view lookup, click listeners, callbacks, community support, and preliminary metrics such as line count and compile speed, concluding that further analysis is needed.

21CTO
21CTO
21CTO
Which Language Wins Android Development? Java vs Groovy vs Scala vs Kotlin

Comparison Method

Each language implementation uses minimal dependencies.

Dependency Report

Required packages per language:

Java : com.android.support:appcompat-v7:23.1.1

Groovy : com.android.support:appcompat-v7:23.1.1, org.codehaus.groovy:groovy:2.4.5:grooid, org.codehaus.groovy:groovy-json:2.4.5

Scala : com.android.support:appcompat-v7:23.1.1, org.scala-lang:scala-library:2.11.7, org.scaloid:scaloid_2.11:4.0

Kotlin : com.android.support:appcompat-v7:23.1.1, org.jetbrains.kotlin:kotlin-stdlib:1.0.0-beta-4584

Analysis Report

Statistics on line count, size, compile speed, and method count are illustrated (images shown below).

Code Comparison

Find View

TextView title = (TextView) view.findViewById(android.R.id.text1);
def title = view.findViewById(android.R.id.text1) as TextView
val title = view.findViewById(android.R.id.text1).asInstanceOf[TextView]
val title = view.findViewById(android.R.id.text1) as TextView

OnClickListener

button.setOnClickListener(new View.OnClickListener() { @Override void onClick(final View v) { /* do something */ } })
button.onClickListener = { /* do something */ }
button.onClick((v: View) => { /* do something */ })
button.setOnClickListener { /* do something */ }

Callback

public interface FindCallback { void onFinish(List<String> results, Exception e); }
private void findCountries(FindCallback doneCallback) { try { /* long task */ doneCallback.onFinish(results, null); } catch (Exception e) { doneCallback.onFinish(null, e); } }
findCountries(new FindCallback(){ void onFinish(List<String> results, Exception e){ /* handle result */ } });
def findCountries(Closure doneCallback) { try { /* long task */ doneCallback(results, null) } catch (e) { doneCallback(null, e) } }
findCountries{ List<String> results, Exception e -> /* handle result */ }
def findCountries(doneCallback: (ArrayBuffer[String], Exception) => Unit): Unit = { try { /* long task */ doneCallback(results, null) } catch { case e: Exception => doneCallback(null, e) } }
findCountries((names: ArrayBuffer[String], e: Exception) => { /* handle result */ })
fun findCountries(doneCallback: (List<String>?, Exception?) -> Unit) { try { /* long task */ doneCallback(results, null) } catch (e: Exception) { doneCallback(null, e) } }
findCountries{ list, e -> /* handle result */ }

Community Support

Java: native support

Groovy: official support

Scala: none

Kotlin: official support

Conclusion

Further comparison data is needed; the article invites additional testing and analysis.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AndroidKotlinGroovyScala
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.