Auto Added by WPeMatico

Ktor 2024 Roadmap DI Update

Since the Ktor Roadmap for 2024 was published there have been a lot of questions regarding Dependency Injection (DI). Specifically how Ktor will be changed to support DI, and to integrate existing DI frameworks. This work is still in its early stages, but we would like to clarify our intentions and invite feedback.

First and foremost, we would stress that:

  1. There will never be any requirement to use a DI framework with Ktor.
  2. Ktor itself will never include a DI framework as part of its design.

The proposed feature is solely for users who wish to combine DI with their Ktor services. We want to help existing DI frameworks integrate with Ktor as seamlessly as possible.

How the proposed Dependency Injection feature will work

Let’s consider how we could use Koin within a Ktor route. Imagine the unfortunate scenario where we require seven separate services in order to purchase the contents of the customer’s shopping cart:

fun Application.root() {
   install(Koin) {
      modules(module {
         single { PricingRules() }
         single { DiscountRules() }
         single { StockCheckRepository() }
         single { DeliveryRoutePlanner() }
         single { PaymentGateway() }
         single { CreditRatingChecker() }
         single { PastPurchasesRecord() }
      })
   }
   ...
}

The DI framework will create and inject the dependencies for us. But because Ktor has no knowledge of Koin we have to specify the dependencies manually. Also the injection process is complex, requiring Delegated Properties and Type Parameters.

Our proposal is to replace the above with something like this:

fun Application.root() {
   install(Koin)
   ...
}

This will be achieved as follows:

  1. You will be able to select which DI framework (if any) you wish to use in the Ktor Project Generator. We hope to support all popular DI frameworks.
  2. The presence of a DI framework will be noted by the Ktor Gradle plugin. It will automatically find all the components managed by that framework. 
  3. The plugin will add new methods to these types, which will enable you to inject them in the simplest possible way.

Our goal is to radically simplify how DI is used within Ktor, without adding any extra complexity. The code generated by the Ktor Gradle plugin will be fully debuggable, and the pipeline architecture will not be modified at all. You will be able to use this new approach in both services and tests.

Hopefully, fans of DI will find this a great improvement, but like DI itself, this will be a completely optional feature. You will still be able to use the DI framework’s native syntax if it suits you better. 

As always we remain committed to Ktor’s founding principles. Every feature we add is aligned with the vision of a no-magic, lightweight solution that is minimalist, simple, flexible, and fast. To help shape the future of Ktor, please join the discussion on the Ktor channel of Kotlinlang Slack (request an invite to Slack).

Continue ReadingKtor 2024 Roadmap DI Update

The Ktor Roadmap for 2024

As in 2023 and 2022, we have been working on a roadmap for our development of Ktor for the year ahead. In the interests of transparency and accountability, we would like to share our plans with you here.

Our ongoing plan

Our ongoing plans and goals for Ktor remain consistent with previous years. We aim to keep the framework lightweight, flexible, and transparent, so our users can easily create powerful and maintainable services and clients.

With each new release, we try to improve the quality and performance of the features we provide, while simultaneously expanding our ecosystem of Ktor plugins. This involves introducing new plugins to simplify existing use cases (like transaction handling) and adding support for new ones (such as Observability and gRPC).

Along with improving the core product, we want to make the development experience easier for our users. We aim to make the plugin ecosystem easier to work with and to remove impediments to community contributions. We are also working to improve the range, quality, and variety of the documentation we provide.

Lastly, we want to take advantage of the stabilization of Kotlin Multiplatform (KMP) and the growing ecosystem of multiplatform libraries. Our goal is to make the benefits of KMP available to Ktor developers and empower them to create multiplatform applications.

New features

We intend to deliver the following new functionality in 2024:

OpenTelemetry plugins

We plan to introduce OpenTelemetry plugins for Ktor Client and Server, which will enable you to generate telemetry data (metrics, logs, and traces) and advertise it for collection.

gRPC based services

We have already been working to add gPRC support. In 2024, we will integrate gRPC into both Ktor Client and Server via an idiomatic Kotlin implementation. This will make creating and consuming gRPC-based services as natural and familiar as HTTP and REST.

Migration to Kotlinx-io in Ktor 3.0.0

Kotlinx-io is a multiplatform library that provides abstractions for data sources and destinations. Before Ktor 3.0.0 becomes final, we intend to replace the existing bespoke networking types with those provided by Kotlinx-io. This will make it much easier for creators of multiplatform libraries to support Ktor Client and Server. With this update, the existing IO functionality is now deprecated and will eventually be removed.

Add support for managed transactions

At present, Ktor services require manual management of database transactions, which is appropriate in complex scenarios. However, in many cases, it is preferable to start a transaction at the beginning of the request and commit it at the end, provided there are no errors.

In 2024, we will introduce an official plugin that implements this behavior. This will simplify database access while providing support for recovering from SQL and application-specific exceptions.

Simplified dependency injection

Until now, we have been agnostic on dependency injection (DI) libraries, preferring to allow users to integrate their preferred products as they see fit. However, many users have asked for explicit recommendations on how to integrate frameworks like Koin into Ktor-based services.

In response to this, we will officially add support for DI into Ktor Server in 2024, and publish guidelines on how best to integrate existing DI libraries.

Making Ktor development better

Along with adding new features to Ktor, we will be making changes that simplify the development process and expand your potential options:

Improved documentation

Based on the feedback we received over the past year, our focus for 2024 is on enhancing current content quality and expanding support with new materials. Our primary goal is to make the learning journey more flexible and straightforward – a goal we aim to achieve over several iterations:

  • Extending, improving, and streamlining the tutorials in the Getting Started sections of the Ktor Server and Ktor Client documentation.
  • Addressing cloud deployment and configuration topics.
  • Introducing a comprehensive guide on full-stack development with Kotlin Multiplatform.
  • Increasing the scope of API coverage in our documentation.

We are also planning structural changes. Tutorials will seamlessly complement each other, interlinking topics more efficiently, and Server and Client content will be reorganized to ensure clearer distinctions.

All of these additions will take advantage of a modernized look and feel, plus integration with the documentation for other JetBrains frameworks and libraries.

A plugin registry

Currently, the online project generator only offers plugins created by the Ktor team. While users can create and integrate their own plugins into services, there is no way to register them for other teams to use. This impedes the growth of the Ktor community.

To fix this, we will introduce a mechanism for accepting third-party Ktor plugins. 

This will consist of:

  • A new, simplified format for creating Ktor plugins. This format will enable you to include all of the information needed to register and display the plugin within the project generator.
  • A new version of the project generator, with support for registering external plugins.
  • A procedure for submitting a pull request to the Ktor team in order to begin the process of evaluating and registering a third-party plugin. 

A command line tool

At present, we recommend creating new Ktor-based projects using either the online project generator or the wizard in IntelliJ IDEA Ultimate. While these two methods cover most scenarios, there is demand for a command line-based alternative. This would allow users to create and modify projects within the terminal or shell.

In response to this demand, we will publish a CLI Tool for Ktor in 2024.

Conclusions

We hope these plans sound exciting and address any outstanding issues you may have with the framework. Thanks to everyone who helps keep the Ktor community flourishing and expanding, whether through contributions, feedback, patronage, or advocacy. If you would like to comment on these plans or suggest additional features, we encourage you to join the discussion on the Ktor channel of Kotlinlang Slack (request an invite to Slack).

Continue ReadingThe Ktor Roadmap for 2024

Nine Highlights from the Kotlin Roadmap

Many of you want to know about Kotlin’s future and what lies ahead. We often talk about the upcoming new compiler, focus on tooling quality and performance, and server-side and KMM experience, but the talks usually don’t give the full picture. 

If you want to stay up to date and follow all of the team’s plans, review the Kotlin public roadmap. We’ve just updated it to reflect our plans for 2021 and beyond! This update covers how the language, tooling, and ecosystem will evolve in the upcoming year. You can choose whether to explore the updated roadmap yourself or check out nine notable highlights in this blog post.

1️⃣ The new compiler takes a big step forward

2️⃣ Sealed whens

3️⃣ Placing a bet on the WebAssembly

4️⃣ New Kotlin/Native garbage collector on the road to experimental

5️⃣ Improving iOS-related tooling in KMM

6️⃣ Support for the Apple Silicon target in the Kotlin Multiplatform tooling

7️⃣ New ways to improve IDE performance and stability

8️⃣ New core libraries features

9️⃣ Community assets with the new style

1️⃣ The new compiler takes a big step forward

The new Kotlin compiler is a huge project that consists of rewriting the JVM and JS backends together with the frontend to the new architecture. When fully completed, the project should bring significant performance benefits, enable compiler plugin API support, and give us the opportunity to create new language features. We’ve just released the new JVM backend part of the compiler, and now we’re focusing on other pieces.

To get the performance boost, we need the new compiler frontend. We’ve been actively working on it for some time and are getting close to the Alpha release. At first, it’s going to support only the JVM target and work only on a specific subset of projects. When enabled explicitly, the new frontend will double the compilation speed!

The second focus is bringing the new Kotlin/JS backend to the Stable state. This requires implementing incremental compilation and sourcemap generation.

2️⃣ Sealed whens

Do you have a utility function in your codebase that makes Kotlin’s when statement exhaustive? Jake Wharton even created a Kotlin plugin introducing an annotation that makes an @Exhaustive when statement truly exhaustive. We hope that soon you won’t need it anymore!

We plan to introduce sealed when, a long awaited feature with 230 votes in YouTrack. The specific language syntax isn’t ready yet, but the general idea is to enable the compiler to warn you about your when statement not being exhaustive. This will make your code safer without the need to introduce your own functions.

Kotlin moves fast by both introducing new stuff and stabilizing experimental features.

Check out our public roadmap to get a full picture of the 48 features that we’re focusing on right now!

3️⃣ Placing a bet on the WebAssembly

We believe that WebAssembly will become the new standard for creating rich web applications in the future, and Kotlin should be a perfect fit there.

That’s why we’ve decided to go all-in for Kotlin/Wasm! We’ve already started creating a dedicated team that will work on it full time. We plan to iterate on performance, work closely with authors of the WebAssembly GC proposal, implement basic Kotlin language features, libraries, and basic Gradle support, and add experimental JavaScript interop. 

4️⃣ New Kotlin/Native garbage collector on the road to experimental

We’ve already prototyped most of the required components to create a simple garbage collector. The next step is to write a multithreading-capable garbage collector implementation. The first version will be slow, and thus not production-ready. But we still aim to release it to the public later this year to start gathering feedback. If you want to know more, Roman Elizarov just published the post that has much more detail about the current state of our garbage collector and future plans. 

Prepare to say goodbye to your old buddy InvalidMutabilityException, as you’ll stop seeing it every time you work with Kotlin/Native!

5️⃣ Improving iOS-related tooling in KMM

KMM is a cross-platform technology, so we want developers to enjoy using iOS-related tooling! Besides the Kotlin/Native memory model rework, there is a lot to be done. For now, we’re focusing on improving the Cocoapods integration UX and hiding the packForXcode Gradle build task from the default script to simplify project setup and the first time experience.

Pro tip: We have a special YouTrack board that provides a convenient way to see all the 48 features from the roadmap. Try it out yourself!

6️⃣ Support for the Apple Silicon target in the Kotlin Multiplatform tooling

Apple Silicon adoption continues to increase. The Kotlin/Native compiler already works on this platform and can produce binaries for it. To help you fully enjoy Apple Silicon support in your projects, we’re going to support it in the Kotlin Multiplatform Gradle plugin and in all of the Kotlinx libraries.

7️⃣ New ways to improve IDE performance and stability

Fast and smooth IDE support continues to be our priority. While our long-term solution to increase its responsiveness is the new compiler, we’re continuing to support our current tooling and find new ways of boosting your performance.

Kotlin plugin for IntelliJ IDEA and Android Studio uses more than 30 various indexes under the hood. We see many possible ways of improving code analysis speed and stability by refactoring the indexes system. Besides this, we also plan to significantly increase IDE Navigation and Find Usages speed.

Pro tip: The roadmap will have a large update every six months, with some possible changes after each feature release. If you want to follow a specific ticket, just vote for it, and you’ll get notifications when its status is updated.

Follow a YT ticket

8️⃣ New core libraries features

We’re continuing to improve standard and kotlinx libraries, such as coroutines and serialization. To name just a few improvements:

9️⃣ Community assets with the new style

Have you noticed the new Kotlin logo? This is just a part of our new visual style project, where we updated our colors, typography, and identity. Now we plan to use this new style to update assets provided for Kotlin User Groups:

If you’re a user group organizer, we’d be very grateful for your feedback in this ticket about which assets you’re missing or any other information on how we can make your life easier!


We want each of you to be a part of Kotlin’s future. Your feedback and ideas are what gives our vision of the future a specific shape. We will continue covering our plans in our blog and YouTube channel, so subscribe to both, stay tuned, and share your thoughts and experience with us.

Pro tip: Subscribe to our YouTube channel not to miss a video about the top roadmap highlights!

Learn more

Continue ReadingNine Highlights from the Kotlin Roadmap

End of content

No more pages to load