# Kotlin/Native as Go alternative?

**URL:** <https://discuss.kotlinlang.org/t/kotlin-native-as-go-alternative/11572>\
**Category:** Native\
**Created:** [February 13, 2019, 7:15am UTC](https://discuss.kotlinlang.org/t/kotlin-native-as-go-alternative/11572 "2019-02-13T07:15:05Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![scellow](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@scellow](https://discuss.kotlinlang.org/u/scellow)\
**Post date:** [February 14, 2019, 2:46pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-as-go-alternative/11572/21 "2019-02-14T14:46:19Z")

</div>

this is why jvm is dead, this community DOESN’T CARE about performance AT ALL, this is sad, really sad, on same level as javascript developpers

---

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [February 14, 2019, 3:26pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-as-go-alternative/11572/22 "2019-02-14T15:26:15Z")

</div>

I guess, then it should be quite easy to write your own compiler. There are a low of pretty fast parsers out there.

---

<div class="post-metadata">

**Author:** ![ahmadalsharif.dev](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@ahmadalsharif.dev](https://discuss.kotlinlang.org/u/ahmadalsharif.dev)\
**Post date:** [February 14, 2019, 4:38pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-as-go-alternative/11572/23 "2019-02-14T16:38:58Z")

</div>

Dude, plz don’t start bashing around. I love Kotlin for it’s simplicity and when it comes to performance, it does a pretty impressive job. Go isn’t directly comparable to Kotlin, they’re two different things serving two different purposes.

Btw, I’m OP, just different account cuz I couln’t log out for some reason.

---

<div class="post-metadata">

**Author:** ![SOF3](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sof3/32/5646_2.png) [@SOF3](https://discuss.kotlinlang.org/u/SOF3)\
**Post date:** [February 15, 2019, 4:53am UTC](https://discuss.kotlinlang.org/t/kotlin-native-as-go-alternative/11572/24 "2019-02-15T04:53:28Z")

</div>

> [@scellow](#):
>
> for some applications, you want to be able to deploy and run as QUICK as possible, so JVM is not a solution

Almost every language requires some framework dependencies. You either ship an enormous binary or requires some dependencies. If you really hate dependencies, have you tried docker?

> [@scellow](#):
>
> again, often you’d prefer your server to cost as low as possible

C++ is almost (one of) the only language(s) with no garbage collection built-in. You could always remove unset all (circular) references to objects to facilitate faster garbage collection; then the only difference in performance is heap allocation, but it is small (and at least not more impractical than C memory management). You should be writing Assembly if you are so concerned about small costs.  
Meanwhile we are talking about Go, and Go isn’t that perfect either…

> [@scellow](#):
>
> on JVM kotlin compiles slower than java, it’s sensible, kotlin native on other hand compile time is a nightmare, TDD becomes really annoying, it hurts productivity
> 
> i believe in kotlin native, but as of today no it’s not an alternative to GO

Indeed, most parts of Kotlin/Native are still pretty experimental or new. But I don’t see a theoretical cause that makes Kotlin/Native inevitably slow to compile; more like JetBrains hasn’t optimized it well enough yet.

> [@scellow](#):
>
> this is why jvm is dead, this community DOESN’T CARE about performance AT ALL, this is sad, really sad, on same level as javascript developpers

This is overexaggeration. When we talk about a language, we are talking about what the language has potential to do (or if there is some theoretical constraint impossible to optimize, e.g. you can’t optimize a type-unstrict language too well), not about how the current compiler software performs. If nobody cared about performance, there wouldn’t have been Hotspot and JIT compilation. The point is that Java and/or Kotlin are not designed to be “you don’t pay for what you don’t use” languages with all sorts of tiny optimizations, but this does not render them impossible for most cases. You aren’t writing a Kotlin program to mine crypto currency; if you do, you should be writing in Verilog instead.

---

<div class="post-metadata">

**Author:** ![cretz](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@cretz](https://discuss.kotlinlang.org/u/cretz)\
**Post date:** [February 15, 2019, 9:52pm UTC](https://discuss.kotlinlang.org/t/kotlin-native-as-go-alternative/11572/25 "2019-02-15T21:52:23Z")

</div>

I just found this thread. I didn’t read the rest of it, but a few months back I started thinking “You know, Kotlin seems to have a superset of features w/ unsigned wrappers now and channels and what not, what if I made a Go-to-Kotlin transpiler? I’d sure like to use all those Go libs out there.”

And, so, I started on [GitHub - cretz/go2k](https://github.com/cretz/go2k). It compiles Go to Kotlin, but it’s not done (I’ve moved on for a bit). It relies on some of my other projects such as [go-dump](https://github.com/cretz/go-dump) to dump AST and types from Go to protobuf, [pb-and-k](https://github.com/cretz/pb-and-k) to read the protobuf, [kastree](https://github.com/cretz/kastree) to build a Kotlin AST and write the result, etc.

It can compile and run all of the Go you see in the folder at [go2k/compiler/src/test/go at master · cretz/go2k · GitHub](https://github.com/cretz/go2k/tree/master/compiler/src/test/go). The compiler got a little ugly so I’m taking a step back and when I revisit I will have a lot to clean up. There are some novel solutions to some problems in there worth reading the code for. While I am using the JVM as the initial runtime, I knew I’d want it for Kotlin Native so I make sure to abstract that out (e.g. [go2k/runtime/runtime-jvm/src/main/kotlin/go2k/runtime at master · cretz/go2k · GitHub](https://github.com/cretz/go2k/tree/master/runtime/runtime-jvm/src/main/kotlin/go2k/runtime) is all that’s needed so far). There is a ton of work to do for this to even be viable, but figured I’d toss it out there.

[Previous page](https://discuss.kotlinlang.org/t/kotlin-native-as-go-alternative/11572.md?page=1)
