Kotlin 1.8.0, the latest version of the popular statically-typed language, brings exciting new features for Kotlin app development, multiplatform mobile, web, and native development. This version adds experimental functions for JVM to recursively copy or delete directory content, stabilizes extension functions for working with Optional classes in Java, and introduces some standard library enhancements. Additionally, Kotlin 1.8.0 is now compatible with Java 19 and Gradle 7.3. In this blog, we’ll take a closer look at the new features in Kotlin 1.8.0 and explore how they can enhance your app development experience. So let’s just get started!
One of the most significant additions to Kotlin 1.8.0 is the experimental functions for recursively copying or deleting directory content on the JVM. This feature allows developers to copy or delete an entire directory and its subdirectories with just one function call. Kotlin 1.8.0 now includes novel functions for java.nio.file.path in its standard library, which facilitate the recursive copying and deletion of directory contents. Developers can opt-in to use this new functionality, which can help save time and streamline the development process.
Kotlin 1.8.0 stabilizes extension functions for working with Optional classes in Java, which simplifies the process of working with Java APIs that return optional values. The new extension functions enable developers to work with Java Optional objects as if they were native Kotlin nullable types, making code more concise and easier to read.
Another noteworthy update in Kotlin 1.8.0 is the TimeMarks experimental functionality that allows elapseNow to read from multiple TimeMarks simultaneously. This feature enhances the performance of time measurements in Kotlin applications, which can be crucial for mission-critical applications that require accurate time tracking.
Here are some of the features of TimeMarks functionality in Kotlin new version 1.8.0:
Gradle 7.3 Compatibility
Kotlin 1.8.0 drops support for the old JVM back end, with the -Xuse-old-backend compiler option no longer supported. However, the new version adds Gradle 7.3 compatibility, which provides developers with better support for building and managing Kotlin projects.
Gradle is a popular build automation tool used by developers to automate and streamline the build process of their applications. Kotlin 1.8.0 offers full support for Gradle versions 7.2 and 7.3, enabling developers to leverage the latest Gradle features in their Kotlin projects. Here are some of the features available in Gradle:
Kotlin 1.8.0 comes with improved kotlin-reflect performance, which is now compiled with JVM target 1.8. One of the major reasons for this improvement is the migration of the internal cache mechanism to Java’s ClassValue. Previously, only KClass was cached, but now KType and KDeclarationContainer are also cached, resulting in significant performance improvements when invoking typeOf(). These changes ensure that developers can now work with kotlin-reflect more efficiently, without having to worry about performance bottlenecks.
The use of Java’s ClassValue also brings other benefits, such as improved thread-safety and the ability to cache values in a more fine-grained manner. This means that developers can now use kotlin-reflect more effectively for Android and iOS app development projects and infuse this feature in their applications, regardless of the complexity or size of their projects.
Kotlin 1.8.0 brings new annotations to improve interoperability with Objective-C and Swift. The @ObjCName annotation lets developers specify a more natural name for Swift or Objective-C instead of renaming Kotlin declaration. This customization is useful for developers who want to use a custom Objective-C and Swift name for a class, property, parameter, or function.
The @HiddenFromObjC annotation helps hide a Kotlin declaration from Objective-C, making Kotlin code more Objective-C/Swift-friendly. On the other hand, the @ShouldRefineInSwift annotation is handy for replacing a Kotlin declaration with a wrapper written in Swift. This annotation instructs the Kotlin compiler to mark a function or property as swift_private in the generated Objective-C API.
These new annotations allow developers to create Swift-friendly APIs while still using declarations in Swift code, making Kotlin more interoperable with Objective-C and Swift. By taking advantage of these new annotations, developers can improve their Kotlin code’s interoperability with Swift and Objective-C.
In conclusion, Kotlin 1.8.0 is a major update that brings exciting new features and improvements for app developers. From Java 19 support to experimental functions for JVM, this update offers a host of tools and enhancements that can enhance your development experience. Whether you’re working on multiplatform mobile, web, or native development, Kotlin 1.8.0 is sure to be a valuable addition to your toolkit.
As a leading Kotlin app development company, Whitelotus Corporation has been at the forefront of this powerful language’s adoption and has delivered numerous pathbreaking projects to help startups and companies accelerate their businesses. With a team of skilled and experienced Kotlin developers, Whitelotus Corporation is well-equipped to handle projects of any size and complexity. If you’re looking to hire Kotlin developers for your next project, get in touch with us today!
Also, Go Through
Sunil Chavda