4 ms·
Do you imagine Go ever being able to create Android applications?
by hswolff 16y ago
Do you imagine Go ever being able to create Android applications?
- enneff 16y agoIt's possible. Go can produce ARM binaries, and the Android NDK permits one to write Android apps in C. It's conceivable that one could either wrap the NDK with something like [cgo](http://golang.org/cmd/cgo/ http://golang.org/cmd/cgo/), or write their own NDK-like thing to communicate with the rest of the Android system. It's a big job, though.
- ale6 16y agoThe problem with the NDK is not calling the NDK, it's more a problem with exporting native symbols in the binary's symbol table the JNI can call. Even if you build a binding using cgo with a home-made C library which calls the Android APIs by JNI, will be a time in the code where the Java code or you library must say "hi, run your code, bitch!" to your go code, and I don't think that cgo enable that.
- deleted 16y ago[deleted]
- kjksf 16y ago"Ever" is a difficult time frame to bet against. There are good reasons it won't happen anytime soon. First, there are 2 kinds of Android programming: * majority of programs are written to Dalvik VM using either official Java SDK or with clever cross-compilers (I believe C# can be used with mono-based compiler) * for performance sensitive programs (i.e. games) code can be compiled to native ARM assembly. There's official NDK from Google based on gcc. However, those programs have very limited access to the system, pretty much enough to write games but you can't access majority of the OS libraries, since those are written in Java and compiled to Dalivk VM. Go already has an ARM compiler so it wouldn't be hard to make it generate native ARM code compatible with Android, like NDK's gcc does. Go, however, has a feature (concurrency based on goroutines/channels) that is fundamental to the language and just doesn't mesh well with traditional runtimes, which are provide good support for threads. Making goroutines/channels work on Java/.NET runtimes is either impossible or would have terrible performance. Again, it's not inconceivable to e.g. modify Dalvik VM to also support goroutines but that's not easy and no-one is even talking about that being a possibility. Go is still a very young implementation, it'll take a year or two before the basics are worked out and then esoteric use cases like supporting Android will invade implementor's minds.