News for hackers. Stuff that matters.
Re:Comparison of C++17, Go, and Java for a next-generation s... by shigeo on Thursday April 23, 2020 @03:30PM (#22960104)
> I wouldn’t have bet that this is what would have happened.

Which part of the results are you referring to? It's well-known that reference counting has significantly lower throughput that tracing garbage collectors, so the fact that C++ is outperformed here isn't surprising at all.

Re:Comparison of C++17, Go, and Java for a next-generation s... by ken on Thursday April 23, 2020 @05:35PM (#22961770)
As a Lisp programmer, I confess that when I see a performance shootout between Go, Java, and C++, I don't expect to hear the result that Go won -- and that its performance is on par with their old Common Lisp program.
Re:Comparison of C++17, Go, and Java for a next-generation s... by pizlonator on Thursday April 23, 2020 @11:34PM (#22964369)
Great point. Here’s the issue: there are tons of ways of doing reference counting in C++. Some go all-in with implied borrowing. Some make great use of C++’s various references. Some use the reference counting only for a subset of objects and rely on unique_ptr for hot things.

So, there is no universal answer to how C++ reference counting compares to GC.

There is a well known answer, that you’re probably referring to, if you reference count every object and you do it soundly by conservatively having every pointer be a smart pointer. But it just isn’t how everyone who does reference counting in C++ does it, and I was surprised because I’m used to folks going in the other direction: being unsound as fuck but hella fast.

Re:Comparison of C++17, Go, and Java for a next-generation s... by kllrnohj on Friday April 24, 2020 @02:21PM (#22971342)
> there are tons of ways of doing reference counting in C++

There are but critically there are also a lot of ways to not do ref counting at all. C++ isn't a refcounted language, it's a language where you can use refcounting (shared_ptr), but you don't have to (unique_ptr, value types). It's not even recommended to be primarily refcounted.

They chose a really odd subset of C++ to use here (shared_ptr exclusively), very unorthodox and not something I've ever seen elsewhere or recommended.

Re:Comparison of C++17, Go, and Java for a next-generation s... by BubRoss on Thursday April 23, 2020 @03:36PM (#22960200)
If either of those affects performance there are WAY too many memory allocations happening.
Re:Comparison of C++17, Go, and Java for a next-generation s... by shigeo on Thursday April 23, 2020 @03:44PM (#22960285)
Sure, but I guess that's the point --- the GCs in Java and Go can handle any allocation pattern you throw at them reasonably well, but there's not, as far as I know, such a "one-size-fits-all" solution in C++ (not that it needs one.)
Re:Comparison of C++17, Go, and Java for a next-generation s... by MauranKilom on Thursday April 23, 2020 @07:08PM (#22962653)
If you don't want to plan out proper (as in performant) data structures and memory management, C++ is indeed the wrong language. And judging by the stuff discussed in comments above, this is exactly what happened here.
Re:Comparison of C++17, Go, and Java for a next-generation s... by BubRoss on Thursday April 23, 2020 @03:50PM (#22960369)
I'm not sure I would call 'using your entire CPU to do trivially small heap allocations' a pattern unless you mean that it's a pattern you see when people wonder why their software is so slow.