Live data from Hacker News

Java is back? Programming language trends for 2345 teams

blog.helloworldopen.com

31–32 of 32 posts

Re: Java is back? Programming language trends for 2345 teams

#31
post #30

Earlier quoted context omitted.

Right, but how is that different than JNI? For instance one of the major complaints about the JNI is that adds a pretty high performance penalty to any native calls (and typically you want native calls when performance is important). Does Go's FFI not have this performance penalty? If not, why not? Like with the JNI, Go's garbage collector needs to understand life cycle semantics of objects coming in/out of the nativ…

The go runtime will manage memory of thins allocated in Go land but you must manage memory in C land. If you allocate memory using C.malloc you must use C.free otherwise you will leak memory.

So how can native code get access to objects on the Go heap?

Re: Java is back? Programming language trends for 2345 teams

#32
post #30

Earlier quoted context omitted.

Right, but how is that different than JNI? For instance one of the major complaints about the JNI is that adds a pretty high performance penalty to any native calls (and typically you want native calls when performance is important). Does Go's FFI not have this performance penalty? If not, why not? Like with the JNI, Go's garbage collector needs to understand life cycle semantics of objects coming in/out of the nativ…

The go runtime will manage memory of thins allocated in Go land but you must manage memory in C land. If you allocate memory using C.malloc you must use C.free otherwise you will leak memory.

Which again is very similar to JNI. I'm genuinely curious as to how Go's FFI differs from Java's to make that a distinguishing characteristic between the 2 languages.
Post reply on HN