Kotlin Multiplatform (KMP) is an open-source technology built by JetBrains that allows you to share code across multiple platforms while retaining the benefits of native programming. Supported platforms include iOS, Android, desktop, web, and others.
Today, we’re launching a preview for Kotlin Multiplatform support in Fleet, which simplifies the development of multiplatform applications, adding to the already extensive Kotlin support in Fleet. Please note that if you’re targeting iOS and macOS, you will need Xcode.
When you open a multiplatform project, Fleet will automatically create Run Configurations for the Android and/or iOS platforms, as declared in the project build file. You can use these to execute your application on an Android Virtual Device or the iOS Simulator.
Polyglot Programming
Because Fleet is a polyglot IDE, you don’t have to switch to a different editor or compromise usability when working with the native code in your multiplatform project. When editing Swift code, you have the same rich functionality you would expect in Kotlin and Java, as well as full support for Xcode projects.
Code navigation
Fleet supports cross-language navigation between Swift and Kotlin. For example, when you use the Show Usages action on a Kotlin function, any invocations from Swift code will feature in the results. If there is a single match, then the associated file is displayed.
Refactoring
Refactoring in Fleet is also cross-language. In the example below, if we use Rename Refactoring on the MainViewController type, then the refactoring will apply across both Kotlin and Swift modules.
Debugging
Debugging in Fleet is also cross-language. You can set a breakpoint in Swift code, view values and the call stack in that environment, step into a Kotlin call, and then continue as required.
A single IDE
As you may be aware or have experienced, creating Kotlin Multiplatform applications has oftentimes involved needing to use multiple IDEs in combination. This is still the case when targeting mobile, as Android Studio and Xcode are required. However, our goal with Fleet is to provide a single IDE where you can develop applications without needing to switch tools (Xcode will still be required to be installed when targeting Apple devices, but will not be necessary for daily work).
Pricing model
During the Preview period, Fleet, including the Kotlin Multiplatform Tooling, will remain free. Once we release the tooling, we anticipate the pricing model will be in line with that of Fleet itself. We’ll provide more information closer to the release date.
Our commitment to IntelliJ IDEA and the IntelliJ Platform
Fleet uses the IntelliJ code-processing engine for Swift and all of our Kotlin support, and consequently, we will continue to provide support for Kotlin in IntelliJ IDEA and on the IntelliJ Platform (thus also Android Studio). In addition, we have an ever-increasing base of developers using Kotlin in IntelliJ IDEA, and we want to assure you that innovation and support will continue on this platform.
Having said that, the target audience for IntelliJ IDEA will primarily remain that of server-side developers targeting the JVM. While it will be possible to open, navigate, and build Kotlin Multiplatform projects in IntelliJ IDEA and Android Studio, other features such as platform-specific run configurations, Compose Multiplatform features, and many other things that facilitate multiplatform development will be supported in Fleet only.
How to get started
To get started with Kotlin Multiplatform development and try out all of the cool features we have been working on, you can install the latest version of Fleet via the JetBrains Toolbox App. We also have a brand new online Web Wizard for creating Kotlin Multiplatform projects.
It’s still very early days for Kotlin Multiplatform Tooling in Fleet, and we would love to hear your feedback. Let us know what works, what doesn’t, what is missing, and what you just can’t do without. Leave us a comment on this blog post or use our issue tracker. You can also share any feedback you have on Kotlin Multiplatform, including the tooling, on the #fleet channel on the Kotlin Slack.
Compose Multiplatform is a declarative UI framework built by JetBrains that allows developers to share their applications’ UIs across different platforms. It enables you to reuse up to 100% of your codebase across Android, iOS, desktop, and web. The framework leverages the code-sharing capabilities of the core Kotlin Multiplatform technology, which just became Stable in Kotlin 1.9.20.
This 1.5.10 release of Compose Multiplatform provides support for Kotlin 1.9.20, offers simplified onboarding, introduces a new portal for documentation, and provides the features listed below:
Table of Contents
With these across-the-board improvements, it has never been easier to adopt Compose Multiplatform. Now is a great time for you to start using Compose Multiplatform for cross-platform development, and if you are an existing user, these improvements will make your work more effective than ever.
Easier to get started
If you want to dive into Compose Multiplatform and Kotlin Multiplatform, then we have some great news for you:
The Kotlin Multiplatform Web Wizard lets you easily create new projects in a few clicks. The project contains both shared logic and a Compose Multiplatform UI for multiple platforms.
New onboarding tutorials are available for Android, iOS, and desktop. These will bring you up to speed on the core concepts of Kotlin Multiplatform and Compose Multiplatform.
The Compose Multiplatform documentation has been integrated into the Kotlin Multiplatform Development portal, making it easier and simpler for you to find the information you need.
This release features multiple enhancements to TextFields on iOS. A new Fast Delete mode is available, handling of double and triple taps has been improved, scroll physics includes the ‘rubber band effect’, and a crossfade animation improves interoperability.
Starting with this release, when you hold down Backspace, a new Fast Delete mode activates after the first 21 characters. In this mode each deletion removes two words. This aligns with the default iOS behavior and is what users expect.
Starting with this release, double and triple taps in a TextField are always handled consistently. Double-tapping will always select the current word, while triple-tapping always selects the entire text.
Compose Multiplatform 1.5.0 introduced support for native scroll physics. This release adds support for overscroll (the “rubber band effect”) within large text fields. Your Compose Multiplatform UI will now provide the bounciness that iOS users expect.
Crossfade animation for UIKit interoperability
When you target iOS, Compose Multiplatform allows you to embed composables within a UIKit component hierarchy. This enables you to combine your Kotlin UI components with existing Swift or Objective-C widgets.
Starting with this release, when embedding composables within a UIKit hierarchy, a crossfade animation is applied to the screen as the orientation transitions. This prevents components from temporarily appearing stretched.
Increased compilation speed
In Kotlin 1.9.20, compiler caching and Compose Multiplatform are compatible. So, starting from this release, compiler caching is automatically enabled for Compose Multiplatform applications that use the Kotlin 1.9.20 compiler. Compilation is much faster for all compilations after the initial one.
Caching remains disabled when you use Compose Multiplatform with an earlier version of the Kotlin compiler. Manually setting kotlin.native.cacheKind to none causes the Gradle compiler plugin to produce an error, so please remove this if present.
Basic support for the K2 compiler
In this release, we introduce partial support for the K2 compiler in Compose Multiplatform. You can use the Compose Compiler and K2 in combination to build basic applications. Full support for K2 is scheduled for the next CMP release, so stay tuned.
Enhanced rendering performance on iOS
In this release, we’ve improved performance on iOS by eliminating any instances of redundant or overly eager processing. In addition, the commands to be run on the GPU for rendering are prepared in a separate thread.
These changes mean that Compose Multiplatform apps running on iOS will have fewer missed frames. Any stutters or lags caused by missed frames will be reduced or removed.
New documentation portal
The new Kotlin Multiplatform Development Portal features tutorials, a FAQ, brand new samples, and other helpful documentation. This means getting started with Compose Multiplatform is easier than ever!
Grouping Compose Multiplatform materials with other multiplatform documentation, on a dedicated portal, makes them easier to find and consume. While some documentation remains on the Compose Multiplatform GitHub, our aim is to transfer it to the new portal soon.
There has never been a better time to get started with Compose Multiplatform! You can use the Compose Material 3 widgets to build beautiful user interfaces that behave consistently on Android, iOS, desktop, and web. Using the Kotlin Multiplatform Web Wizard you can be up and running in minutes, with the new onboarding tutorials to guide you as you build your first Compose Multiplatform applications.
We hope you’ll find building applications with Compose Multiplatform a fun and rewarding experience. Please provide feedback on how you get on. We invite you to join the discussion on the Kotlin Slack in the #compose channel, where you can discuss general topics related to Compose Multiplatform and Jetpack Compose.
In a highly anticipated move, Kotlin Multiplatform, an open-source technology built by JetBrains that allows developers to share code across platforms while retaining the benefits of native programming, has become Stable and is now 100% ready for use in production.
Read on to learn about the evolution of Kotlin Multiplatform (KMP), how it can streamline your development process, and what educational resources are available for you to get the most out of the technology.
Designed with a core focus on flexibility and adaptability, Kotlin Multiplatform (KMP) blurs the boundaries between cross-platform and native development. It allows developers to reuse as much code as they want, write native code if and as needed, and seamlessly integrate shared Kotlin code into any project.
Since the first release of KMP, its flexibility has attracted many prominent companies, such as Netflix, Philips, McDonald’s, 9GAG, and Baidu. Many teams have already been capitalizing on KMP’s ability to be gradually integrated, as well as its low adoption risk. Some of them share isolated critical parts of their existing Kotlin code to improve the stability of their apps. Others, aiming to reuse as much code as possible without compromising app quality, share all application logic across mobile, desktop, web, and TV while maintaining native UIs.
With KMP being widely used in production since its Alpha release, JetBrains has been able to gather extensive feedback and refine the technology to provide a better multiplatform development experience in the Stable version, including the following.
Strict compatibility guarantees
The core of the Kotlin Multiplatform technology consists of many parts, such as compiler support, language features, the libraries API, IDEs, build tooling, and more. All of these cover the most popular code-sharing use-cases and are stable in Kotlin 1.9.20. “Stable” means that we will evolve those parts following strict compatibility rules, so you can confidently use them in your code.
Going beyond the core, KMP also has some more advanced parts that we’re still continuing to work on. Expect/actual classes are an example of such functionality (not to be confused with expect/actual functions, which are fully stable in Kotlin 1.9.20). Such features are explicitly marked as non-stable, and Kotlin will inform you when you’re using them. Please pay attention to the experimentality warnings and the corresponding documentation to make an informed decision about using or not using such features in your projects.
Better build setup user experience
To simplify project setup and maintenance, we’ve introduced the default hierarchy template. This new feature of the Kotlin Gradle plugin automatically configures Kotlin Source Sets for popular scenarios and reduces the amount of boilerplate in typical build scripts.
To help you diagnose build misconfigurations and errors, KMP delivers a couple of improvements in Stable:
Approximately 50 diagnostics were added to the Kotlin Gradle plugin, helping to detect common build issues and providing quick tips on how to fix them.
Moving Kotlin/Native compiler cache management from the Kotlin Gradle plugin to the compiler makes possible further improvements to compilation times and compiler cache flexibility.
Thanks to all of these advancements, Kotlin Multiplatform can be used without hesitation for sharing code in production across Android, iOS, desktop (JVM), server-Side (JVM), and web, even in the most conservative usage scenarios.
Use the power of the growing Kotlin Multiplatform ecosystem
The evolution of Kotlin Multiplatform isn’t limited to the technology itself, but extends to its thriving ecosystem cultivated by thousands of Kotlin developers worldwide. Since Beta, the number of KMP libraries has multiplied, offering diverse tools for networking, data storage, arithmetics, analytics, and more, enabling swift and confident app development.
The Android team at Google is continuing to support KMP users by providing the experimental multiplatform versions of Jetpack libraries, and they’ve already made the Collections, DataStore, Annotations, and Paging libraries compatible with Kotlin Multiplatform.
The KMP ecosystem also offers a range of tools for the iOS developer experience, with SKIE by Touchlab standing out. It generates Swift code that provides a Swift-friendly API layer, which bridges important Kotlin types, and implements seamless Coroutines interoperability.
Get even more code-sharing freedom with Compose Multiplatform
Compose Multiplatform, a modern declarative cross-platform UI framework by JetBrains, is a significant part of the ever-expanding KMP ecosystem. With Compose Multiplatform, you now have full code-sharing flexibility. Share just one piece of logic, all application logic, or both the logic and the UI, depending on your project’s and team’s requirements:
Compose Multiplatform for Android and desktop (JVM) is already Stable, while support for iOS is currently in Alpha and support for web (Wasm) is Experimental.
Explore the future of Kotlin Multiplatform
JetBrains continues to enhance multiplatform development with Kotlin, aiming to make it the ultimate choice for sharing code across platforms:
Future updates for the core Kotlin Multiplatform technology will improve the iOS developer experience, including direct Kotlin-to-Swift interoperability and SwiftPM support.
The next milestone for Compose Multiplatform for iOS is Beta support in 2024.
JetBrains is actively developing Kotlin/Wasm to facilitate modern web development with KMP, aiming to deliver the Alpha version of Compose Multiplatform for Web (Wasm) next year.
And that’s not all. In the upcoming weeks, get ready for some thrilling announcements regarding the evolution of Kotlin Multiplatform tooling!
Get started with Kotlin Multiplatform
Begin your journey with our extensive, user-friendly educational resources.
Participate in our Kotlin Multiplatform Webinar November Series to get insights directly from JetBrains experts! Explore Kotlin Multiplatform features, build KMP apps with both native and shared UIs, and uncover iOS development tips and tricks:
The new Kotlin Multiplatform Development Portal offers detailed documentation, getting-started guides, and step-by-step tutorials covering all aspects of building apps with Kotlin Multiplatform and Compose Multiplatform:
In this new edition of the Kotlin digest, you’ll learn about the new releases, finalists whose work has stood out in the latest round of Kotlin Multiplatform Content Creators Recognition Campaign, and the current state of Kotlin support in Fleet, a new IDE from JetBrains.
Kotlin Multiplatform user survey
If you’re a Kotlin Multiplatform developer, we want to hear from you! We’re conducting a Kotlin Multiplatform user survey to collect insights that will help us shape the future of the technology. Complete the survey and contribute to a better developer experience for our community!
By participating, you will also have the chance to win a one-year JetBrains All Products Pack subscription or a $100 Amazon Gift Card.
The Compose Multiplatform 1.5.10 release is just around the corner. The release candidate includes all features and performance improvements from the beta releases, compatibility with Kotlin 1.9.20-RC2, bug fixes, and more:
New Material 3 components (ModalBottomSheet, ExposedDropdownMenuBox, SearchBar, and DockedSearchBar) in common code.
Enhancements to TextField for iOS.
Improved UIKit interoperability.
Compatibility with Kotlin 1.9.20-RC2.
Increased compilation speed for iOS with Kotlin 1.9.20.
JetBrains Fleet is a lightweight code editor and IDE that uses the IntelliJ code-processing engine. Fleet allows you to develop in Python, TypeScript / JavaScript, Go, Java, PHP, C#, and other popular languages with the most advanced support for Kotlin. The product is now in public preview so everyone can try it!
To recognize and celebrate the dedication and efforts of community members who create educational content about Kotlin Multiplatform, we regularly organize Kotlin Multiplatform Content Creators Recognition Campaigns. These content pieces will serve as a source of inspiration for learners:
If you missed our educational livestreams, the recordings are now available to watch online.
Practice technical interview algorithms in Kotlin
In this livestream, Alexander S. Kulikov, Head of the Laboratory of Algorithms and Complexity Theory at JetBrains Research, and Pavel Mavrin, Tutor and Researcher at JetBrains and 2004 ICPC World Champion, introduce the Algorithmic Challenges in Kotlin course. Watch the video to see solutions to some popular coding interview problems, like “Opposite Values” and “Collecting Signatures” coding challenges.
If you want to learn more about service mesh and its transformative potential, be sure to watch the livestream recording with Viktor Gamov, a Developer Advocate with Kong. You will learn how to set up a service mesh in Kubernetes, deploy demo Kotlin microservices, enable declarative traffic policies, and more.
As the Kotlin Multiplatform stable release emerges on the horizon, its ecosystem continues to evolve and flourish, thanks in no small part to the enthusiastic Kotlin community. What’s more, the Compose Multiplatform 1.5.10 release is around the corner, which has only added to the excitement surrounding this technology’s capabilities. With that said, we want to announce the new round of the Kotlin Multiplatform Content Creators Recognition Campaign, highlighting the contributions of those passionate individuals who have been instrumental in keeping the community informed, engaged, and inspired.
Kotlin Multiplatform has captured the imagination of developers worldwide and has motivated content creators to share their how-tos, various articles packed with actionable tips, video tutorials, and sample projects. We want to shine a spotlight on this content that provides valuable insights, guidance, and inspiration to learners, enthusiasts, and professionals in the field.
Let’s introduce the latest round of finalists whose work has stood out in this Recognition Campaign.
[📖 Article] Writing Swift-friendly Kotlin Multiplatform APIs – This is a whole series of articles covering how to write Kotlin Multiplatform libraries that work smoothly with Swift by André Oriani.
[📖 Article] Configurable Features using Kotlin Multiplatform – Artem Zasypalov discusses the YAZIO team’s approach to creating configurable features in their app using Kotlin Multiplatform in an effort to make their Onboarding feature flexible and fully configurable.
[📖 Article] Implementing a 2-month Large-scale Banking POC with Kotlin Multiplatform – Imre Kaszab talks about how the Apter team developed a Proof of Concept (POC) for a banking application using KMP, taking their client’s needs into account, like maximum code sharing, extensive test coverage, modular structure, and rapid feature delivery.
[📖 Article] Meet “Y-Charts”: an Open-source Jetpack Compose chart library – Codeangi introduces Y-Charts, a Jetpack Compose-based charts library that enables developers to easily integrate various types of charts and graphs into their existing UI to visually represent statistical data.
Whether you’re a seasoned developer looking to expand your skillset or a newcomer eager to learn more about the Kotlin Multiplatform technology, we encourage you to explore this content, which provides a treasure trove of information.
And if you also have ideas to share, seize the opportunity to become a part of the Kotlin Multiplatform community of content creators! We choose our favorite new content once every three months and highlight it in the official Kotlin resources:
Are you struggling to come up with ideas for content? Use the following list of the most requested Kotlin Multiplatform topics for inspiration:
Use cases of what you have shared with Kotlin Multiplatform.
Experiments with cutting-edge Kotlin Multiplatform tools and libraries
Experience with Compose Multiplatform for iOS.
Migrating large projects to Kotlin Multiplatform.
Don’t limit yourself to these topics! Feel free to share your expertise and experience on another subject. Just don’t forget to add the #kotlinmultiplatform tag if the media platform you’re using allows it.
We’re excited to see how our community will continue to shape the Kotlin Multiplatform landscape in the future. Cheers to the creators who keep our community vibrant and thriving!
Are you preparing for technical interviews, or do you simply want to master algorithms? Join us for a practical livestream where we’ll introduce the Algorithmic Challenges in Kotlin course!
In this session, we’ll cover the main topics from the Algorithmic Challenges in Kotlin course, which prepares participants for coding interviews and provides a solid understanding of algorithmic techniques.
Watch this livestream to:
Elevate your understanding of algorithms and hone your skills to excel in technical interviews.
See solutions to the ‘Opposite Values’ and ‘Collecting Signatures’ coding challenges, which are popular coding interview problems.
Learn how to implement these solutions in Kotlin, a modern multiplatform programming language.
Join us to prepare for success in your next technical interview!
Pavel Mavrin is a Tutor and Researcher at JetBrains, expert in algorithms and data structures. Pavel has participated in many programming competitions. His most prestigious title is ICPC World Champion 2004.
In this new edition of the Kotlin digest, we’re bringing you the most exciting news and updates from July and August.
KotlinConf 2024 tickets are now available!
KotlinConf is bringing the Kotlin community together for the fifth time on May 22–24, 2024, at the Bella Center in Copenhagen, Denmark! There will be workshops, talks, networking opportunities, expo booths, and other fun activities. Learn more in our blog post and book your tickets to take part in the biggest Kotlin event around.
You can win a trip to KotlinConf 2024 in the Kotlin Multiplatform Contest!
Seize this opportunity to practice your multiplatform coding skills by taking part in the Kotlin Multiplatform Contest. Create a cross-platform project in Kotlin, and if your entry takes one of the top three spots, you’ll win a trip to the biggest Kotlin event of the year! For more information about the contest, check out this blog post.
Stay up to date with our regular digest, featuring the most important news about the Kotlin ecosystem! Subscribe here.
Compose Multiplatform 1.5.0 release
Compose Multiplatform 1.5.0 is out! This release builds on top of Jetpack Compose 1.5, which was focused on performance improvements. Here are some of the highlights:
Option to use Dialog, Popup, and WindowInsets APIs in common code.
iOS-like scrolling physics.
Improved resource management on iOS.
Test framework stabilization for Desktop.
Read this blog post to learn about these and other improvements.
The performance of Compose Multiplatform apps is one of our key priorities. We would appreciate it if you could test Compose Multiplatform in your projects targeting iOS and share information about any performance issues that you encounter. Your help will allow us to make sure the technology meets the true performance needs of your projects.
From now on, “Kotlin Multiplatform” (KMP) is the preferred term when referring to the Kotlin technology for sharing code, regardless of the combination of platforms being discussed. We are deprecating the “Kotlin Multiplatform Mobile” (KMM) product name to resolve long-standing issues of term inconsistency and abbreviation confusion. Please adopt the name “Kotlin Multiplatform” (KMP) in your existing and future content and libraries.
There’s some great news for Jetpack Compose users! Google has released version 1.5.0 of the Jetpack Compose Compiler plugin, which is compatible with Kotlin 1.9.0 and includes experimental support for the K2 compiler. K2 is now in Beta for the JVM, and your feedback is crucial at this stage of development. We want to ensure that the K2 Compiler aligns perfectly with the needs of your Android projects.
The Kotlin Foundation announced Grants Program winners
In July, the Kotlin Foundation Ecosystem Committee announced the winners of the first round of its Grants Program. Out of 109 applications, the committee selected the five winners:
Coil – an image loading library for Android backed by Kotlin coroutines.
Store – a Kotlin Multiplatform library for building network-resilient applications.
http4k – a functional toolkit for Kotlin HTTP applications.
KMP-NativeCoroutines – a library for using Kotlin coroutines from Swift code in KMP apps.
Lyricist – an internationalization and localization multiplatform library for Compose.
Harnessing the power of the Kotlin DSL for documentation
Discover how the JetBrains team is using Kotlin to create a DSL for writing documentation. By leveraging Kotlin’s strengths and IDE support, along with the inherent extensibility of the DSL, the team made documentation a dynamic, integrated part of the development process.
Exposed, a lightweight SQL library on top of a JDBC driver for the Kotlin language, is taking a significant leap forward. The growing usage of the library has led us to hire full-time developers and a technical lead. We’ll continue working on making Exposed a first-class product. Learn more about our upcoming plans in the blog post.
If you missed the latest episodes of our streaming series Koding in Kotlin, the recordings are now available for you to enjoy! Pasha Finkelshteyn, a Developer Advocate at JetBrains, dives into Kotlin and game development, embracing every misstep and triumph along the way.
Are you a student or recent graduate? Have you already tried building projects with Kotlin Multiplatform, a trending technology that lets you build apps for Android, iOS, desktop, web, and server while sharing Kotlin code between all the platforms?
If so, don’t miss this opportunity to practice your multiplatform coding skills by taking part in the Kotlin Multiplatform Contest. Create a cross-platform project in Kotlin, and if your entry takes one of the top three spots, you’ll win a trip to the biggest Kotlin event of the year – KotlinConf’24 in Copenhagen, Denmark!
The top 3 winners will get an all-expenses-paid KotlinConf’24 participant package, covering KotlinConf tickets, travel, accommodation, and cool Kotlin swag.
The authors of all other valid entries will receive neat Kotlin souvenirs, in addition to valuable experience.
Don’t forget to join our #kotlin-multiplatform-contest channel on Slack. Here you can ask questions, connect with fellow contestants, and share your insights.
Exposed started out a few years back at JetBrains, as a lightweight ORM/DAO written in Kotlin. It has since been used internally on a number of critical products at JetBrains, and despite being classified as a Team project on GitHub, it has garnered a large number of external users.
While the main person on the project was doing his best to provide support and move it forward, we decided it was time to dedicate more resources to it. As a consequence, we hired full-time developers, a technical lead, and we’re working on making Exposed a first-class product.
Today, we’d like to share our plans moving forward.
Product
A uniform API for 1.0
One of the benefits of Exposed is that it provides a statically-typed language which is similar to SQL, allowing you to easily query databases without the downside of using SQL strings in your code. The keyword here however is similar. There are cases when there is a significant deviation from SQL.
We want to try and bring the syntax as close as possible to SQL as well as remove some inconsistencies between the DAO and DSL approaches of Exposed.
While this will introduce breaking changes, we believe that it is the right thing to do to set a strong foundation for Exposed moving forward.
Reducing boilerplate
Much like with Kotlin, our goal is to reduce the amount of boilerplate code that needs to be written when working with Exposed. Currently this is not the case. There are definitely areas where we could reduce the overhead of having to write repeatable code.
While we could certainly introduce annotations, much like Ktor, we want to avoid magic. It’s important for developers to know what exactly is happening, and how it’s taking place. We’re looking at approaches to meet these criteria.
Long-standing issues
In addition to some bigger changes, there are a number of long-standing issues that need to be addressed. Our goal is to get to as many of these as possible over the coming months. Those that require breaking changes will be postponed to 1.0 or after.
Release Process
Similar to what we did with Ktor, we’ll be moving Exposed to Semantic Versioning. We want to release 1.0 as soon as we have addressed some concerns around the API. The current timeframe is Q1 2024. Independently though, we’ll be moving to monthly releases to make sure that as issues are resolved, they are made available to you.
Documentation and Samples
One of the main pain-points of Exposed is the lack of extensive documentation. To this end, we’re in the process of reviewing the existing documentation, restructuring and enhancing it, and we’ll be publishing it on the new Exposed website (which is also in the works). In addition we want to provide more self-contained samples that are easy to follow and learn from.
Moving to YouTrack
As part of processes being put in place, we’re moving the issue reporting to YouTrack. This will provide us with better ability to track, classify, and attend to issues. Existing issues on GitHub won’t be migrated as per our previous experience doing this with Ktor, we lose the author of the comments. In addition, there are a bunch of stale and outdated issues on GitHub that we’ll review and remove. New issues however should be logged in YouTrack.
We’re very excited about the many possibilities that Exposed can offer developers, and eager to continue to build on this library and provide the best user experience to you, our users. Remember that you can reach out to members of the team, as well as get support, on the Exposed channel on the Kotlin Slack. If you’re not on there, you can sign up using the form.
This material was initially presented at the API The Docs Conference in Amsterdam, an event focused on developer success and how API documentation and developer portals help businesses. We highly recommend this conference to those who want to boost the technical aspect of their technical writer role. All talks are practical, informative, and include live demonstrations.
Sometimes, a few lines of code can help you complete a documentation task. However, docs aren’t code, and it can be harder to add external functionality or automations when writing documentation. If only you could write docs as if they were code, complete that particular task, and then turn the code back into docs!
In this blog post, we explore how to do just that using the Kotlin DSL to write documentation.
DSL? What DSL?
Let’s define “domain-specific language” or DSL.
Simply put, it’s a specialized programming language designed to solve specific problems. The concepts and rules of these languages are specific to a particular domain.
DSLs are also called little languages or problem-oriented languages. These definitions better describe their essence – DSLs are tailored to solve specific problems.
There are two types of DSLs. External DSLs are separate languages with their own grammar, lexer, and parser. SQL is an example of such a language. On the other hand, internal DSLs reuse the grammar and parser of a general-purpose language and make use of that language’s available extension options.
The Kotlin DSL for documentation falls into the category of internal DSLs.
With Kotlin, you can build an internal DSL with the look and feel of an external DSL. So, what we have developed is an internal DSL tailored specifically for documentation.
Read more about the differences between external and internal DSLs on the JetBrains MPS website.
The essence of the Kotlin DSL
The Kotlin DSL for documentation is a framework specifically designed for creating documentation and static websites.
The framework is a type-safe builder operating on basic document elements, while additional functionality plugs in as user code or external dependencies. The dependencies can deliver any kind of functionality – from specific source or output formats to natural language processing features.
With the Kotlin DSL, technical writers can define semantic elements, such as chapters, procedures, tables, lists, and more. Although it initially focuses on our own markup, the DSL’s flexibility allows for custom extensions, so in theory, we can turn any input format into any output format.
On the element level, users can encapsulate complex logic in custom elements, which will then be as simple to use as a paragraph or a list.
One of the significant advantages of the Kotlin DSL is that Integrated Development Environments (IDEs), like IntelliJ IDEA, provide built-in support, including error checking, code completion, and refactoring. This goes a long way in improving the quality of the written content.
An example of how duplicate detection works
As the sources are regular Kotlin code, all code intelligence and language support features are available out of the box. Need to navigate through the code? Want to detect dead and duplicate code? Or inject another language into a string literal? All these IDE features work for the Kotlin DSL. Speaking of the language itself, it offers significant benefits, such as full static typing and an entire ecosystem of useful tools.
While this blog post shows how the DSL generates our custom XML markup, it’s important to note that it can generate various output formats, such as HTML or .docx, based on your specific requirements.
Additionally, the DSL can be used not only in IntelliJ IDEA but also in other editors or even through the command line. It provides an experience that is still similar to writing content while also harnessing the endless possibilities offered by the Kotlin programming language.
Below are a few examples of what our markup may look like.
In the first example, we create a paragraph and a list with two list items and append some content inside these elements.
val content = StardustDslContentProvider {
p { +"Hello, DSL"}
list {
li { +"List item 1" }
li { +"List item 2" }
}
this
}
After running a script, it turns into the following result:
In the second example, we create a table with two columns.
And in the third example, we demonstrate how to inject any other language, for example, XML or Markdown. In the case below, we are injecting a procedure with three steps:
But of course, just writing in markup is hardly a groundbreaking achievement. So, let’s proceed to something a little more innovative and exciting.
Demonstration
Firstly, please note that we want to show you an approach, not a particular implementation. The demonstration below is performed using our custom XML markup, but we can bridge any other format, like AsciiDoc, Markdown, reStructuredText, LaTeX to HTML, or even .docx.
Three key strengths of our approach
Separation of Concerns
We talk a lot about separating content from its presentation. This approach has existed in the web development world since the early days of CSS, and it was then reinterpreted and reinforced in lightweight markup languages. This technique involves decoupling the visual and design aspects of a document from its content and structure. This way, writers can focus on the content while easily adapting its presentation.
But we can go even further and separate data from its presentation. Instead of describing the world in markup, which has no direct relation to the things being described, the documentation may be generated based on the data itself. We can take data from the application runtime and then define its representation.
Moreover, we can make the representation conditional, dependent on the data design. For example, if a method description indicates that it is deprecated, turn it into a warning element. In other cases, turn it into a paragraph.
We often speak about treating documentation as code, but we usually mean a limited amount of tools and practices, like writing in lightweight markup, putting docs under version control, and using code review and linters. But, there is so much more that we can take from the development world.
With the Kotlin DSL, documentation becomes synonymous with code, allowing writers to leverage practices commonly used by developers. Some of these practices include:
Making certain parts of content a module and then importing it as a dependency in many documentation sets, for example, some frontend components or legal information like copyright or license agreement.
Using function composition in programming, we can break down complex markup structures and patterns into simpler ones, making our sources more granular and easy to maintain and reuse.
Treating semantic and frontend components as types unlocks the advantages of object-oriented programming where we need them.
Extensibility
The extensibility of the DSL is a game-changer. Not only does it allow you to add custom elements, but it also offers the ability to modify the DSL itself, opening up endless possibilities.
You are only limited by your own imagination. Whatever is possible on a computer is possible with docs!
Thanks to seamless integration with existing JVM libraries, you can incorporate data sources, parse and enrich content, and even integrate with external tools and frameworks like Selenium and Cucumber.
A few examples of the extensibility options with the Kotlin DSL are:
Parsing and integrating any data format, including XML, JSON, YAML, custom serialization formats, and even objects from an application runtime.
Adding mappings and enriching docs with additional content.
Applying tests and assertions for autogenerated parts.
Why Kotlin?
Attempts to generate HTML from code have existed before, so you may be wondering why we‘ve selected Kotlin for documentation purposes?
First and foremost, Kotlin has advanced features that facilitate creating a powerful DSL based on it.
Second, Kotlin is renowned for its pragmatism and beginner-friendly nature. It embraces the principle of simplifying everyday tasks, ensuring that even newcomers can grasp the language quickly and easily.
For instance, writing a basic “Hello, World!” program in Kotlin doesn’t force beginners to operate with concepts and keywords they don’t understand.
Here’s an example that compares the “Hello, World!” program in Java with the same program in Kotlin:
Java:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Kotlin:
fun main() = println("Hello, World!")
In Kotlin, you don’t need to define a class or use the public static void signature. The main() function serves as the entry point, and you can directly use println() to output the desired message. This simplicity is one of the key advantages of Kotlin, making it easier and more enjoyable to write basic programs.
As mentioned before, Kotlin seamlessly integrates with the JVM ecosystem. With Java nearing its 30th anniversary, an abundance of immensely useful tools and libraries have been created. You can incorporate these tools into your workflow by simply adding a line to the build script.
By choosing Kotlin, we prioritize a language that strikes a balance between simplicity and powerful capabilities, ensuring an enjoyable and efficient developer experience.
Do I need to be a coder to use the Kotlin DSL?
We often hear writers say, “I am just an average technical writer, not a developer or super techie! How can I use this? What level of programming do I need in order to benefit from it?”
To start using the DSL elements as markup, you need zero coding skills, and you don’t need to know how DSL works under the hood.
Only when you have tasks related to some automations will you need to have a basic understanding of Kotlin. The Kotlin Core course at JetBrains Academy will be more than enough to teach you what you need to know.
However, we believe that an initial investment in learning the Kotlin DSL pays off in the long run. With its intuitive syntax and IDE support, writers can quickly become proficient and reap the benefits of a powerful documentation tool.
When you incorporate this approach into your documentation workflow, you may need to learn a bit of programming. By integrating the Kotlin DSL into your work, you can learn programming practically and engagingly, specifically tailored to your documentation responsibilities. After all, technical writers may find tasks related to documentation more enjoyable than synthetic exercises like calculating scores in a hypothetical class or building a basic calculator. Moreover, learning Kotlin helps with understanding other languages and ecosystems as well.
This approach may not resonate with all technical writers, but for those who write about developer tools, it can be a valuable way to enhance their skills.
Conclusion
The Kotlin DSL for documentation introduces a paradigm shift, enabling technical writers to create compelling content with the ease and power of a programming language. By leveraging Kotlin’s strengths, IDE support, and the inherent extensibility of the DSL, documentation becomes more than just words on a page. It becomes a dynamic, integrated part of the development process, enhancing collaboration and delivering exceptional results.
So, why not explore the possibilities of the Kotlin DSL for your own documentation needs?
🚀If you want to start using Kotlin DSL, we’ve created a sample project you may download and try to play with. If you have any questions regarding it, join our Slack, we have a dedicated channel called #kotlin-dsl-for-docs.
Embrace the power of code and take your documentation to new heights.
KotlinConf is bringing the Kotlin community together for the fifth time, from May 22 to 24, 2024, at the Bella Center in Copenhagen, Denmark!
KotlinConf’24 will feature one day of workshops followed by two consecutive days of content and networking, including sessions, expo booths, and other fun activities. Secure your tickets, organize your travel, and get ready to come together for the biggest Kotlin event around.
On May 22, 2024, you’ll have the opportunity to immerse yourself in one of six expert-led workshops covering some of the most popular Kotlin topics. Seats for each are limited, so register soon if you’d like to attend.
Choose your workshop:
Asynchronous Programming With Kotlin Coroutines by Sebastian Aigner and Roman Elizarov.
Kotlin Multiplatform Beyond the Basics by Garth Gilmour and Pamela Hill.
Functional Programming in Kotlin by Simon Vergauwen and Francisco Diaz Rodriguez.
Hands-On Kotlin Web Development with Ktor by Anton Arhipov, Pasha Finkelshtein and Leonid Stashevsky.
Mastering Kotlin Refactoring – Tools and Techniques by Duncan McGregor and Nat Pryce.
Reactive Spring Boot With Coroutines and Virtual Threads by Urs Peter.
KotlinConf tickets always go fast. The last conference was completely sold out around 4 months in advance, so we recommend getting your tickets now.
Stay up to date with our regular digest, featuring the most important news about the Kotlin ecosystem! Subscribe here.
Roadmap updated
The Kotlin roadmap has been updated with our plans for the upcoming releases. The key priorities are making Kotlin Multiplatform and the K2 compiler Stable. The plans also include making Kotlin/Wasm suitable for standalone Wasm VMs, improving Android debugging, and extending the kotlinx-io library towards a more unified and Kotlin-first API.
Compose Multiplatform – a declarative framework designed for building cross-platform user interfaces with Kotlin – has recently gained the capability to support iOS. This means developers can now use Compose Multiplatform to create a UI entirely in Kotlin and use it on Android, iOS, and other platforms.
Compose Multiplatform for iOS is now in its Alpha stage, which makes it perfect to use in your experiments. We invite you to give it a try and help us shape the future of the technology!
The first experimental version of the Kotlin Notebook plugin for IntelliJ IDEA is out. A notebook is an interactive tool that allows you to combine code, visualizations, and text in a single document. With Kotlin Notebook, you can explore, prototype, visualize, and document your code – all in the same environment. Delve deeper into the plugin’s functionality and use cases in our blog post and try it out in your project!
To recognize and appreciate the efforts of our community members who produce Kotlin Multiplatform content, we regularly run the Content Creators Recognition Campaign, which showcases articles and videos related to the technology. Explore our latest selection of stories and get inspired.
The Kotlin Foundation establishes the new Ecosystem Committee
The Kotlin Foundation has recently announced the formation of the new Ecosystem Committee, which promises to be an important contributor to the growth of the Kotlin ecosystem. The new committee is responsible for identifying strategic funding avenues for the Kotlin ecosystem, recommending direct investment into open-source Kotlin projects, and increasing awareness of the members’ individual contributions to the development and improvement of key libraries.
Contributors to Kotlin projects for Google Summer of Code announced
In May, 5 Kotlin project contributors were selected for Google Summer of Code 2023. As part of the initiative, they’ll work on several 12-week programming projects with the Kotlin Foundation guided by mentors from JetBrains, Google, and Gradle. We believe that each of the projects will have a significant impact on the Kotlin community. Learn more about the projects the selected contributors will be working on and keep up to date on their progress.
We’ve just released our latest educational resource – a freely available, semester-long Programming in Kotlin curriculum. The course is currently being taught at two universities, and we’ve also made the course materials available to all Kotlin educators. The educational materials include slides for 11 lectures covering core Kotlin concepts, along with speaker notes. You will also get access to assessment resources, such as quizzes, three tests, and four homework assignments involving hands-on coding exercises. We invite you to use the curriculum as is or adjust it to fit your needs!
And if you missed our “Launch Your Kotlin Course with New Materials for Educators” live stream, feel free to watch the recording. A special guest, Anastasia Birillo, is a JetBrains researcher, Kotlin developer and instructor, an active member of the Kotlin community, and one of the authors of the Programming in Kotlin curriculums. Learn from Anastasia’s expertise and profound experience and use free downloadable course materials for launching your own Kotlin course.