News for hackers. Stuff that matters.
Re:Proposed New Go GC: Transaction-Oriented Collector by dboreham on Friday June 24, 2016 @11:29AM (#11970503)
Finally a reason for me to consider using Go vs Java.
Re:Proposed New Go GC: Transaction-Oriented Collector by eternalban on Friday June 24, 2016 @12:37PM (#11971196)
The decision tree remains the same as before.

Both systems have active runtime sub-systems, GC, scheduler, and a compiler front-end.

Java, of course, has a virtual machine and intermediate representation (byte codes), and a JIT to make it performant. The runtime class loading mechanism is a key +input here. The JIT aspect is a mix, with the -input being the upfront startup cost.

Go has far better C linkage, access to underlying memory object image, and provides the (glaringly missing from JVM) unsigned integer types.

Java has a more modern type system and first class metadata facilities, with -input being "more rope". Go has a 'interesting' type system, with -input being source level fragility, but +input here is "less rope".

Having extensively worked with concurrent systems in both languages, the distinction ultimately boils down to a question of whether langauge level continuation (fiber/green) as provided by Go vs. library/ByteCodeEngineering (various Java libs) is a critical requirement.

I honestly think it should be clear at this point that Go is really displacing Python and the notion of Go vs. Java is a false dichotomy.

Re:Proposed New Go GC: Transaction-Oriented Collector by the8472 on Friday June 24, 2016 @12:59PM (#11971460)
> Go has far better C linkage

This is changing. There already are 3rd-party FFI libraries for java[0][1] which are far less cumbersome to use than JNI and in the future there will be Project Panama[2] which will provide that out of the box.

[0] https://github.com/jnr/jnr-ffi [1] https://github.com/java-native-access/jna/blob/master/www/Ge... [1] http://openjdk.java.net/projects/panama/

Re:Proposed New Go GC: Transaction-Oriented Collector by weberc2 on Friday June 24, 2016 @04:45PM (#11973321)
> the distinction ultimately boils down to a question of whether langauge level continuation (fiber/green) as provided by Go vs. library/ByteCodeEngineering (various Java libs) is a critical requirement.

Excellent point. This doesn't seem to be brought up very often (or at least it's rarely emphasized) in Java/Go comparisons.

Re:Proposed New Go GC: Transaction-Oriented Collector by pjmlp on Friday June 24, 2016 @02:47PM (#11972359)
Also the Go advantage regarding AOT compilation to native code only exists, if one ignores that the majority of commercial third party JVMs do have it as a feature.
Re:Proposed New Go GC: Transaction-Oriented Collector by wheaties on Friday June 24, 2016 @01:00PM (#11971467)
Go isn't displacing Python any more than Elixir is displacing Ruby.
Re:Proposed New Go GC: Transaction-Oriented Collector by the8472 on Friday June 24, 2016 @12:24PM (#11971051)
Except that Java already has G1GC[0], a region-based collector. And if you're willing to shell out money there even is a pauseless, fully concurrent collector[1] scaling to hundreds of gigabytes.

[0] https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gc... [1] https://www.azul.com/products/zing/pgc/

Re:Proposed New Go GC: Transaction-Oriented Collector by merb on Friday June 24, 2016 @02:46PM (#11972352)
With Java 9 or 10 (doesn't remember) it gets a new Pausless GC, too. Not like the Azul one that works even with low Memory. But for high memory stuff.
Re:Proposed New Go GC: Transaction-Oriented Collector by the8472 on Friday June 24, 2016 @03:10PM (#11972548)
Shenandoah[0]. From what I've read it's contributed to openjdk by redhat. Their claims about pause times aren't quite as strong as those of Azul, but <100ms pauses for 100GB+ heaps will still be leagues ahead of most GCs.

It's probably also be less CPU-efficient than azul's, since it uses forwarding pointers instead of page table trickery. But if you have such a large heap you'll also have many cores. Here's a performance comparison to G1[1].

[0] http://openjdk.java.net/jeps/189 [1] https://rkennke.wordpress.com/

Re:Proposed New Go GC: Transaction-Oriented Collector by voidlogic on Friday June 24, 2016 @01:20PM (#11971655)
The Go 1.7 GC is already on par with most Java GCs and arguably better. Our Go projects with large heaps now have better pause times than the similar Java programs, all having tried many of the Java GCs...
Re:Proposed New Go GC: Transaction-Oriented Collector by icholy on Friday June 24, 2016 @02:02PM (#11972000)
Not sure if it's better, it just has less work to do. Java creates a lot more garbage.
Re:Proposed New Go GC: Transaction-Oriented Collector by stcredzero on Friday June 24, 2016 @02:13PM (#11972090)
Whatever works. It's the result that counts.
Re:Proposed New Go GC: Transaction-Oriented Collector by icholy on Friday June 24, 2016 @08:06PM (#11974452)
ofc, I was strictly speaking about the GC algorithm.
Re:Proposed New Go GC: Transaction-Oriented Collector by voidlogic on Friday June 24, 2016 @05:08PM (#11973492)
Fair enough, I was comparing the application + runtime interaction, basically I, app behavior.

>Java creates a lot more garbage.

Very true, Go is great about keeping things on the stack.

Also sync.Pool helps a lot when used as needed.

Re:Proposed New Go GC: Transaction-Oriented Collector by twic on Friday June 24, 2016 @06:41PM (#11974062)
Part of the reason for this is that Java GC development has focused more on throughput, whereas Go GC development has focused more on pause time. It's rather hard to compare throughput between two such different languages, though.
Re:Proposed New Go GC: Transaction-Oriented Collector by pjmlp on Friday June 24, 2016 @12:19PM (#11971003)
Java has plenty of GC algorithms to choose from.
Re:Proposed New Go GC: Transaction-Oriented Collector by weberc2 on Friday June 24, 2016 @04:48PM (#11973348)
Sounds like a 'more rope with which to hang yourself' proposition.
Re:Proposed New Go GC: Transaction-Oriented Collector by andrewfromx on Friday June 24, 2016 @11:31AM (#11970524)
oh there were plenty other reasons before this!
Re:Proposed New Go GC: Transaction-Oriented Collector by pjmlp on Friday June 24, 2016 @12:20PM (#11971016)
I used to think like that until they decided to freeze the language.
Re:Proposed New Go GC: Transaction-Oriented Collector by remus on Friday June 24, 2016 @03:15PM (#11972586)
It isn't a language freeze but a comparability promise.

"It is intended that programs written to the Go 1 specification will continue to compile and run correctly, unchanged, over the lifetime of that specification. At some indefinite point, a Go 2 specification may arise, but until that time, Go programs that work today should continue to work even as future "point" releases of Go 1 arise (Go 1.1, Go 1.2, etc.)."

Granted that means it is effectively a freeze on backwards incompatible changes, but it does leave the door open for additions to the language.

Having said that, the go authors are definitely very conservative with language changes.

Re:Proposed New Go GC: Transaction-Oriented Collector by pjmlp on Friday June 24, 2016 @03:28PM (#11972709)
No, frozen are the words used by the Go team.

"Not everything was fixed, though. We're still learning (but the language is frozen for now). "

https://talks.golang.org/2012/splash.article

Re:Proposed New Go GC: Transaction-Oriented Collector by federicoponzi on Friday June 24, 2016 @12:28PM (#11971095)
What do you mean?
Re:Proposed New Go GC: Transaction-Oriented Collector by TheDong on Friday June 24, 2016 @12:56PM (#11971418)
The Go1 promise (https://golang.org/doc/go1compat) means that they cannot refine the language any further. It's frozen.

For example, there's a mess of different error handling techniques (e.g. err == io.EOF vs os.IsNotExist(err) vs perr, ok := err.(*os.PathError); ok).

This also prevents the language from evolving, as can be seen in the case of the context package (see 'Frozen' in this post https://github.com/golang/go/issues/14660#issue-138695431 )

While the above poster didn't explain his problem clearly, it is a valid complaint.

Re:Proposed New Go GC: Transaction-Oriented Collector by andrewfromx on Friday June 24, 2016 @02:18PM (#11972124)
wow, i've been golanging for a year now checking tons of if err != nil and I never once thought there was a problem.
Re:Proposed New Go GC: Transaction-Oriented Collector by TheDong on Friday June 24, 2016 @02:44PM (#11972332)
The whole `if err != nil` thing is a different problem as well!

Example of one of them: https://play.golang.org/p/pku8VJteH1

That stupid issue means that packages like os return 'error' even if it will always be of type '*PathError' so you have to be careful to note if the package you're using screwed up in returning err structs or not when doing `if err != nil` or else you'll check a nil interface vs a nil struct... not what you want. This hinders the ability to make richer error types somewhat. In addition, it means you have to always read the docs because the type system cannot represent the possible errors you can get there safely.

Second, this is bad because of places in the language (like io.Reader.Read) where it returns two values (numRead, err) where both are useful.

Due to the lack of sum types, you can't actually tell in multiple-returns of errors whether the results are mutually exclusive or not. What's more, without sum types, there's no way to express to the type system correctly that you indeed are in a non-nil branch of a value or so on.

Finally, there's no macros or other ways in the language to have more expressive error checking than the brain-dead "if err != nil". Sure, what go has is better than java's terrible implementation of exceptions, but it's so much worse than what you get in rust or ocaml or so on.

Re:Proposed New Go GC: Transaction-Oriented Collector by placeybordeaux on Friday June 24, 2016 @12:26PM (#11971077)
This is only one of many differences between Go and Java. The style of coding is extremely different.