Generate HTTP REST requests behind the scenes

There’s a few different ideas here.

It sounds like you really want some RPC or RMI library. Or maybe your use case would be solved with plain old serialization? You could check out gRPC (which recently got Google support for Kotlin). There are many other libraries and tools that solve similar cases like this (e.x. Protobuf).

Another point I should make is that you shouldn’t hide remote work as if it’s a normal method call. Suspending functions can solve this in Kotlin.

Lastly, you ask

This should not be part of the language. What you’re describing could be done with a library–in fact, I’d bet there are several libraries that do what you want. I’m on mobile so I won’t copy any examples right now.

4 Likes