Android Application Development All-in-One For Dummies
Book image
Explore Book Buy On Amazon
You may be using functional programming to develop your Android apps. If so, you might consider Kotlin as your go-to programming language.

Functional programming is a paradigm, which means that it doesn’t have an implementation. The basis of functional programming is lambda calculus, which is actually a math abstraction. So when you want to perform tasks by using the functional programming paradigm, you're really looking for a programming language that implements functional programming in a way that meets your needs.

In fact, you may even be performing functional programming tasks in your current language without realizing it. Every time you create and use a lambda function, you’re likely using functional programming techniques (in an impure way, at least).

Kotlin has significantly more functional features that Java does, but Kotlin still shows its Java roots. For purists, the Java connection is a problem because Kotlin code can look too much like Java code. Developers often look at languages based on need, rather than on strict adherence to a set of principles.

Still, you can find discussions online that say Kotlin isn’t quite as functional as Python and not nearly as functional as languages such as Haskell. These theoretical discussions don’t actually matter in the real world. You want to use Kotlin for Android development when functional programming is important because Kotlin

  • Is suitable for Android and possibly system development, whereas Python focuses on data science and machine learning needs
  • Can execute relatively quickly, even on devices that have less robust processors
  • Uses a smaller number of lines of code when compared to Java due to the ability to use functional techniques
  • Is easier to read than Java code
  • Is easier to learn than Java, but not as easy as Python
  • Offers multi-statement lambdas
  • Has relatively compact collection comprehensions, which improve readability of collection manipulations
  • Uses receivers to create complex code manipulations with simple names
  • Has access to inline functions that actually do place the function into the surrounding code, making the application run faster (at the cost of size)
  • Includes special functions to handle potentially null input
With Kotlin, you gain all these features that require some level of functional programming without losing access to the Java libraries. Because Java libraries are important for Android development, an Android developer should see Kotlin functional capabilities as being more useful than Java.

When working with Kotlin, you also get a bonus for Android development; You can use C++ libraries, too. The articles at yalantis.com and developer.android.com tell how to use these libraries. Given how Kotlin works, you can use C++ to augment your applications in a number of ways, especially when it comes to obtaining the last bit of speed from your application.

Want to learn more about developing Android apps? Check out our cheat sheet.

About This Article

This article is from the book:

About the book authors:

Dr. Barry Burd holds an M.S. in Computer Science from Rutgers University and a Ph.D. in Mathematics from the University of Illinois. Barry is also the author of Beginning Programming with Java For Dummies, Java for Android For Dummies, and Flutter For Dummies.

John Mueller has produced 114 books and more than 600 articles on topics ranging from functional programming techniques to working with Amazon Web Services (AWS). Luca Massaron, a Google Developer Expert (GDE),??interprets big data and transforms it into smart data through simple and effective data mining and machine learning techniques.

This article can be found in the category: