Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin Native Support #571

Open
DanTsk opened this issue Sep 8, 2018 · 35 comments
Open

Kotlin Native Support #571

DanTsk opened this issue Sep 8, 2018 · 35 comments
Milestone

Comments

@DanTsk
Copy link

DanTsk commented Sep 8, 2018

Hello !
Does Ktor support Kotlin Native for now (using Netty)? I saw few comments in JetBrains Blog, but can't find any detailed information about it.
Thank you !

@soywiz
Copy link
Contributor

soywiz commented Sep 10, 2018

Right now, only the HTTP Client supports Kotlin/Native

@luca992
Copy link
Contributor

luca992 commented Sep 21, 2018

Right now, the HTTP client supports osx, and macos. I read Linux is being considered. But windows isn't mentioned anywhere... Is there any plans to support windows? I am building a cross-platform desktop program that targets macos and windows, and just want to know if I can expect windows to be supported in the future. I would rather not waste my time using ktor's http client if windows support is not in the plans.

@Dominaezzz
Copy link

Can the 'ktor-client-core' be published for other native targets? So at least, custom client engines can be made.

@e5l e5l self-assigned this Jan 22, 2019
@DanTsk
Copy link
Author

DanTsk commented Mar 2, 2019

Any updates on it? Can we now create ktor server-side app for native ?
I found Kotlin Native server - source

@e5l e5l modified the milestone: 1.1.5 May 6, 2019
@DanTsk
Copy link
Author

DanTsk commented May 15, 2019

@e5l Hey, just saw that this issue was added to 1.1.5 milestone that is closed. Does it mean that Ktor support Kotlin Native? (as the current version is 1.2.0)

@e5l e5l modified the milestones: 1.1.5, 1.3.0 May 17, 2019
@cflorion
Copy link

Hi there :) I'm in love with Kotlin Multiplatform! But Ktor server support is blocking for us to use it in our company's product. Is it something that is still planned or this is something that appears impossible in the end ?

I can (try to) give an hand on this, is this possible to have an overview of what is missing or what are the problematics ?
Thanks! :)

@cy6erGn0m
Copy link
Contributor

ktor server MPP is planned for 1.4.0

@cy6erGn0m cy6erGn0m modified the milestones: 1.3.0, 1.4.0 Dec 5, 2019
@cy6erGn0m cy6erGn0m assigned cy6erGn0m and unassigned e5l Dec 5, 2019
@serebit
Copy link

serebit commented Dec 10, 2019

Still waiting on MPP websockets 🤞

@jershell
Copy link

and http3 =)

@napperley
Copy link

napperley commented Jan 25, 2020

Ktor Client is available for linuxX64 but not for the other Linux targets (linuxArm32Hfp, linuxArm64 etc) :( .

@krishofmans
Copy link

This would make for a very interesting serverless implementation in combination with things like openfaas or rio.io

@julKali
Copy link

julKali commented Feb 26, 2020

I think this issue doesn't receive the attention it is worth. If it was really possible to decouple ktor-server and its modules from Java, it would be groundbreaking. The biggest problem with Java web frameworks is their slow startup time, because the JVM often takes seconds to start up. If K/N ktor-server would be a thing, I am pretty sure that many developers would consider porting existing Kotlin projects that depend on http4k, Spring, Vert.x or similar to ktor which would give them a dramatic performance boost.
I don't believe that this issue will be easily resolved (and I am genuinely curious how you guys will tackle it!), so I was a bit surprised to see so little discussion in this thread. I couldn't find a public roadmap, so one can only hope that 1.4 will be around, soon, but until then, the next generation of Kotlin microservices will be waiting 🚀

@napperley
Copy link

napperley commented Feb 27, 2020

If Ktor Server was ported to Kotlin Native (supporting the linux targets) would Ktor be suitable for Serverless via OpenFaaS? What would the performance footprint for Ktor Server look like on Kotlin Native compared to Go lang?

Currently there isn't a single cloud provider (eg AWS) that provides Kotlin Native support. Having Ktor Server ported to Kotlin Native would help change that. Many cloud providers except for GCP (Google Cloud Platform) are paying lip service to Kotlin support (aka examples/demos are presented but no official Kotlin support is provided). GCP Kotlin support is restricted to Kotlin JVM only, and doesn't extend to Kotlin Native unless Google have some future plans to extend Kotlin support.

@julKali
Copy link

julKali commented Feb 28, 2020

@napperley at the moment, K/N has poor performance as the dev team primarily focused on compatibility. It will take a few iterations until it is comparable to the more mature Go let alone C. In the meantime, though, it would be great to start with the porting of ktor so that when K/N is performant, ktor is ready to be used.

@krishofmans
Copy link

I also think there's a lot of opportunity for kotlin native/ktor in the serverless space and to compete with things like graalvm.

I get that graalvm has different promises than kotlin native as it will transpile more jvm related stuff to native. But still it seems very painful, slow and complex, and also requires changes in the jvm related frameworks.

Offering the combination of native performance/memory usage, ktor and a familiar language might be able to pull over a lot of developers out of the jvm/graalvm space.

@julKali
Copy link

julKali commented Feb 28, 2020

@krishofmans exactly! I am currently working with Micronaut because it's specifically made to be compiled as Graal native-image and it's extremely tedious!
Documentation is terrible, I have to look up source code in order to find out how to implement simple features, IDEA needs additional configuration (which in part is nowhere documented, I had to figure it out by trial and error) and although they have some support for Kotlin it feels very clunky and requires some hacks. Compiling the Micronaut code then takes forever (especially annoying when testing) and creating Graal's native-image takes even longer (literally minutes). On top of that, it fails every second time with some unidentifiable error (I don't want to bash native-image too much though, as it's currently Early Adopter so errors are to be expected).
And another reason why K/N is so valuable: Because Graal's native-image is currently Early Adopter. I suspect Oracle to make it an enterprise feature when it's released.
Sorry for the rant, but I really want to stress that for serverless developers, it would be so mind-boggling to have the beauty of Kotlin and the performance of native code - all without the need of weird hacks.

@julKali
Copy link

julKali commented Feb 28, 2020

I just realized that because ktor seems to rely on reflection a lot, porting it will require significant changes of the whole application pipeline. K/N currently supports reflection only to a very limited extent.

@krishofmans
Copy link

Perhaps that's just an opportunity for K/N to also further it's features. Since reflection is basically a metadatamodel of the code that can be modified at runtime.

It could be seen as an api around method/field lookup tables with some additional metadata and perhaps it will become more widely supported in K/N this way.

I know that it's a lot more complex and a lot of work will go into it to support it, but still looks like something that could be worth it if it would also enable porting over other jvm kotlin based frameworks over to the native space.

@PatrickZGW
Copy link

Is there another issue or PR for this? Still planned for 1.4?

@e5l
Copy link
Member

e5l commented Apr 21, 2020

WIP in e5l/cio-common. Yep, the implementation is in progress.

@napperley
Copy link

napperley commented Apr 22, 2020 via email

@michallaskowski
Copy link

I am not in a hurry, I want to use native servers for a testing framework for iOS and Android I am working on. I have a solution working with okhttp mocks and Objective-C server, under one interface in Kotlin MP. Just interested if there is a way, or some rough ETA, where I could switch that to Ktor Server on Kotlin MP.
I would be happy to help, if possible, if there are parts I could comprehend ;)

@gentunian
Copy link

I'm looking forward to this. I'm in a state of changing my tech stack and kotlin is one of them (I want to leave from JVM, golang is another selection). But for me, still kotlin with spring boot apps is the way until a native approach arises. Trying graalvm native support with spring was a failing step. If ktor manages to be native, for sure this will be the way to go for kotlin APIs into docker from scratch.

@mahdisml
Copy link

mahdisml commented Jun 28, 2020

Is there any updates ? (or news)

@oleg-larshin
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@emrul
Copy link

emrul commented Jan 10, 2021

I have ktor server with cio working as a native image - I posted this YT issue https://youtrack.jetbrains.com/issue/KTOR-965

@Xaseron
Copy link

Xaseron commented Jan 11, 2021

But this won't help if you want to use Ktor server on your iOS app.

@Nailik
Copy link

Nailik commented Mar 13, 2022

According to release notes it is in 2.0.0-beta-1.
I tried to test it on Android with CIO server and there is just no response from server when i try to call it.
Same issue with Netty on 2.0.0-beta-1 but Netty 1.6.7 works.

With CIO i get no visible errors in output.
On Netty there seem to be some issues:
No implementation found for int io.netty.channel.kqueue.Native.sizeofKEvent() (tried Java_io_netty_channel_kqueue_Native_sizeofKEvent and Java_io_netty_channel_kqueue_Native_sizeofKEvent__)
No implementation found for int io.netty.channel.epoll.Native.offsetofEpollData() (tried Java_io_netty_channel_epoll_Native_offsetofEpollData and Java_io_netty_channel_epoll_Native_offsetofEpollData__)
WARN io.netty.util.internal.MacAddressUtil - Failed to find a usable hardware address from the network interfaces; using random bytes:

@saket
Copy link

saket commented Mar 14, 2022

@Nailik I think this issue has been fixed https://youtrack.jetbrains.com/issue/KTOR-3653

@jpink
Copy link

jpink commented Sep 22, 2023

I think this isn't fixed until I can create native Windows server. The documentation doesn't give any hint why Windows target support is dropped. Can't we take the io.ktor:ktor-server-cio or io.ktor:ktor-server-core as a base. It sounds weird that it's impossible to create server on Windows nowadays. How they can achieve that on ISS or .Net Core?

@Adrian8115
Copy link

How does it look now?

Is there support for Windows(mingwX64) and/or LinuxArmX64?
It would be amazing to have these platforms supported!

Any Updates?

@Adrian8115
Copy link

btw this issue is freaking 5 years old

@Stexxe
Copy link
Contributor

Stexxe commented Dec 19, 2023

@Adrian8115, what modules do you want to know the support for?

@Adrian8115
Copy link

I want to develop a server software in kotlin which needs native multiplatform udp support...

The thing is, it looks like it's not supported on the most important platforms: Windows X64_86 and Linux Arm

And that is a huge deal-breaker sadly

@krishofmans
Copy link

This seems to be supported natively: https://ktor.io/docs/servers-raw-sockets.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests