Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

What are the New Language Features in Kotlin 1.4.30 for Roadmap to 1.5?

Mobile app development industry has completely changed in the last few years, changing the way businesses operate across the globe. With enterprises taking keen interest in investing in mobile apps to their productivity in recent times, and with the major innovation in mobile devices, it calls for mobile app developers to write different versions of an application for different platforms using a single Language and different pieces of reusable code.

Once you get to know your mobile app idea, it’s time to validate it, learn about the target market, and on which you ideally would like to design your mobile app. As soon as that is planned, it’s time to start app programming in Kotlin language, keeping in mind your business strategy to build native, hybrid, or cross-platform apps.

Kotlin is a statistically typed and cross-platform language used to build latest Android applications. It is a top-rated language for app development and has the potential to influence other programming languages as well including Java to build high-performing and robust apps. Some renowned apps built by Android app development company are Trello, Coursera, Evernote, and many more.

• Clean, crisp, and perceptive syntax boosts team efficiency.
• Has full support from Google and IDE’s installation packages.
• Interoperable and adaptable and easily overrule the Java shortcomings.
• Generates compact, simple, and cleaner code as compared to JAVA.

Kotlin 1.4.30 is already available for Android developers with remarkable features that are going to be integrated in Kotlin 1.5 when release in 2021 spring.

Major Features to Watch Out in Kotlin 1.5 for App Development

1. Stabilization of inline value classes

Inline classes have been present in Alpha since Kotlin 1.3, and in 1.4.30 they are available to Beta. The Kotlin 1.5 version stabilizes the process of inline classes but makes it a relevant part of a more general feature, value classes, which we will discuss later.

We’ll begin with a small recap on how inline classes work. If you have knowledge regarding the same with inline classes, then it will help you to know directly the new changes.

As a quick reminder, the inline class removes a wrapper around a value:

inline class Color(val rgb: Int)
An inline class can be a wrapper both for a primitive type and for any reference type, including String.
The compiler has the feature to replace inline class instances with the underlying type (Int) in the bytecode, when possible:

fun changeBackground(color: Color)
val blue = Color(255)
changeBackground(blue)
Under the hood, the compiler builds the changeBackground function with a mangled name taking Int as a parameter, and it passes the 255 constant without building a wrapper at the call site:

fun changeBackground-euwHqFQ(color: Int)
changeBackground-euwHqFQ(255) // no extra object is allocated!

2. Replacing JVM Name for Java Calls

Starting from 1.4.30 edition, the JVM name of a function is easily replaceable taking an inline class as a parameter to make it accessible from Java. By default, such names are mangled to eliminate accidental usages during Kotlin App Development from Java or conflicting overloads.

If you mention a function with @JvmName, it changes the name of this function in the bytecode and makes it simple to call it from Java and pass a value easily:

// Kotlin declarations
inline class Timeout(val millis: Long)
val Int.millis get() = Timeout(this.toLong())
val Int.seconds get() = Timeout(this * 1000L)
@JvmName(“greetAfterTimeoutMillis”)
fun greetAfterTimeout(timeout: Timeout)
// Kotlin usage
greetAfterTimeout(2.seconds)
// Java usage
greetAfterTimeoutMillis(2000);

As always with a function mentioned with @JvmName, from Kotlin you mention it by its Kotlin name. Kotlin usage is type-safe, the value is passed during the Timeout type as an argument, and the units are obvious from the usage.

3. Support for JVM records

Another upcoming improvement in the JVM ecosystem is Java records. They are analogous to Kotlin data classes and are basically simple holders of information.

Java records don’t follow the JavaBeans convention, and they have x() and y() methods rather than the familiar getX() and getY().

Interoperability with Java always was and remains a major priority for Kotlin. Hence, Kotlin code “understands” new Java records and consider them as classes with Kotlin properties. This works similarly to regular Java classes following the JavaBeans convention:

// Java
record Point(int x, int y) { }
// Kotlin
fun foo(point: Point) {
point.x // seen as property
point.x() // also works
}
So, these are the most important features of Kotlin 1.4.30 that are going to be inherit into Kotlin 1.5 release in the next few months.

Wrapping Up

The blog post covered major features for choosing Kotlin 1.5 and why it is a perfect choice for mobile application development for your business. So, what are you waiting for? Simply hire Android app developers, which offers app development services to get desired business results. You can consult experienced team to build a Kotlin-based mobile app at a cost-effective price.

Frequently Asked Questions

1. What is Kotlin programming language used for?

Kotlin is an open-source statically typed programming language that targets the JVM, Android, JavaScript and Native. It’s developed by JetBrains. The project started in 2010 and was open source from very early on.

2. What is Kotlin written in?

Kotlin is a general purpose, free, open source, statically typed “pragmatic” programming language initially designed for the JVM (Java Virtual Machine) and Android that combines object-oriented and functional programming features.

3. Is Kotlin frontend or backend?

Kotlin compiles to Java bytecode and runs on the JVM so it’s suitable for all environments where Java is used. This includes Android as well as back-end server applications. The idea of implementing the back-end, front-end, and build script all in one language is very promising.

4. Why is Kotlin so popular?

There are a lot more mobile apps compared to enterprise apps or apps where Java is entrenched as the language of choice. It also helps if the platform in question has declared first class support for the language. Hence the popularity of Kotlin for Android dev.

The post What are the New Language Features in Kotlin 1.4.30 for Roadmap to 1.5? appeared first on Android Developer.



This post first appeared on Make A Jewelry App For Your Online Shop, please read the originial post: here

Share the post

What are the New Language Features in Kotlin 1.4.30 for Roadmap to 1.5?

×

Subscribe to Make A Jewelry App For Your Online Shop

Get updates delivered right to your inbox!

Thank you for your subscription

×