Live data from Hacker News

Show HN: GoJava – Server/desktop Java bindings to Go packages

github.com

11–15 of 15 posts

Re: Show HN: GoJava – Server/desktop Java bindings to Go packages

#11
post #3

Earlier quoted context omitted.

This exists for Python [0]. The reverse is also interesting (Go -> Java/Python/Ruby) and once I get some spare time, I'll play around with using libjvm to load and call jar files from Go. [0] https://github.com/go-python/gopy

Its awesome. The problem is that only specific types are supported by a bunch of these types of libraries. In the case of gopy you cannot do anything with a nested slices in structs which limits things a bit.

Yes this is definitely a little limiting. I'm also experimenting with a slightly different binding method, where passing pointers to structs is disallowed (gobind currently allows pointers to structs). All structs are only passed by value, which solves a lot of the underlying problems and allows for slices and nested structs. I'll have something tangible in a few weeks and might switch out the dependency on gobind.

EDIT: edited for clarity

Re: Show HN: GoJava – Server/desktop Java bindings to Go packages

#12
post #9

Since GoJava generates jar binding, does it mean other JVM languages can use the jar to call Go too? Edit: Java has generic Go doesn't, how do the bindings work for generic?

Yes. The only constraint is that the jar will only work on the architecture it was built on.

Re: Show HN: GoJava – Server/desktop Java bindings to Go packages

#13
post #9

Since GoJava generates jar binding, does it mean other JVM languages can use the jar to call Go too? Edit: Java has generic Go doesn't, how do the bindings work for generic?

Regarding generics: the tool generates Java bindings from Go code. Since Go doesn't have generics we just generate non-generic bindings.

Re: Show HN: GoJava – Server/desktop Java bindings to Go packages

#14

Earlier quoted context omitted.

Its awesome. The problem is that only specific types are supported by a bunch of these types of libraries. In the case of gopy you cannot do anything with a nested slices in structs which limits things a bit.

Yes this is definitely a little limiting. I'm also experimenting with a slightly different binding method, where passing pointers to structs is disallowed (gobind currently allows pointers to structs). All structs are only passed by value, which solves a lot of the underlying problems and allows for slices and nested structs. I'll have something tangible in a few weeks and might switch out the dependency on gobind. E…

Thats awesome news, Thanks for the explanation!

Re: Show HN: GoJava – Server/desktop Java bindings to Go packages

#15
post #9

Since GoJava generates jar binding, does it mean other JVM languages can use the jar to call Go too? Edit: Java has generic Go doesn't, how do the bindings work for generic?

Yes. The only constraint is that the jar will only work on the architecture it was built on.

Still pretty awesome and that's not really a big deal. I'm going to guess most Java these days is running on x86_64 or ARM.
Post reply on HN