News for hackers. Stuff that matters.
Re:Show HN: Strife, a 2D game library for Go by weberc2 on Saturday September 29, 2018 @11:27AM (#18100889)
Go’s GC is extremely low latency and you can pretty easily avoid allocating using the same techniques as you would in C++.
Re:Show HN: Strife, a 2D game library for Go by pcwalton on Saturday September 29, 2018 @12:34PM (#18101249)
You can't avoid allocating using the same techniques as in C++. In Go you have to know the intricacies of escape analysis to avoid allocation: objects are heap allocated "by default" and sometimes optimized to be stack allocated. In C++ there is no implicit heap allocation and usually no need for escape analysis.

As a practical example, capturing variables in a closure will usually cause them to be heap allocated in Go, but in C++ capturing has no effect on variable storage.

Re:Show HN: Strife, a 2D game library for Go by nullstyle on Saturday September 29, 2018 @01:22PM (#18101574)
It seems to me that you're not really taking a charitable interpretation of GP's comment. For example, in my game development experience (granted, I'm 6 years removed from that industry) we often relied on object pools to avoid allocation. You don't need to know anything about Go's escape analysis to use a pool to avoid allocation, as far as I can tell. Could you explain your position further?
Re:Show HN: Strife, a 2D game library for Go by pcwalton on Saturday September 29, 2018 @02:34PM (#18101986)
Go language constructs allocate in ways that are not immediately obvious. So using object pools is not sufficient to avoid allocation in Go as compared to, say, C++.

In my view (which is the dominant view among compiler engineers for GC'd languages), spending a lot of effort to avoid allocation is a poor use of programmer time in a GC'd language. It is better to just improve the GC to make allocation fast. In a properly designed generational GC like that of Java HotSpot, allocation is about 5 instructions. That is a game changer: allocation is as cheap as a function call plus the prologue.

Unfortunately, Go's designers have so far not deployed generational GC, which is why we keep having these threads about avoiding allocation. (I've seen indications in the last couple of weeks that Go may finally be moving to a generational GC, though, and I hope they do.)

Re:Show HN: Strife, a 2D game library for Go by pjmlp on Saturday September 29, 2018 @02:28PM (#18101949)
Anyone doing HTML 5/Flash like games in Go doesn't need to worry like if they are writting the next Fortnight in Vulkan.
Re:Show HN: Strife, a 2D game library for Go by pcwalton on Saturday September 29, 2018 @02:42PM (#18102020)
This is why I've been careful to say "CPU-intensive workloads" and not "games", because not all games are CPU-intensive workloads.
Re:Show HN: Strife, a 2D game library for Go by nullstyle on Saturday September 29, 2018 @04:11PM (#18102533)
You weren't careful to say it in this subthread though. I had a whole response written up to talk about how you're being completely unreasonable with regards to most gaming projects before I saw this clarification. Now all that effort is wasted! ;)
Re:Show HN: Strife, a 2D game library for Go by pjmlp on Saturday September 29, 2018 @03:16PM (#18102240)
Ah, sorry I missed it.

Then I fully agree with you.

Re:Show HN: Strife, a 2D game library for Go by weberc2 on Saturday September 29, 2018 @08:23PM (#18103811)
You’re splitting hairs. Yes, you need to reason about escape analysis. This is pretty easy, especially since the compiler will tell you when things escape. It’s certainly easier than... well, pretty much anything in C++. :)
Re:Show HN: Strife, a 2D game library for Go by crowhack on Saturday September 29, 2018 @11:28AM (#18100899)
How low latency are we talkin? 1ms , 10ms ?
Re:Show HN: Strife, a 2D game library for Go by tptacek on Saturday September 29, 2018 @11:33AM (#18100925)
Re:Show HN: Strife, a 2D game library for Go by crowhack on Saturday September 29, 2018 @11:35AM (#18100943)
Thanks for this link.
Re:Show HN: Strife, a 2D game library for Go by NikolaeVarius on Saturday September 29, 2018 @11:34AM (#18100933)
https://blog.golang.org/ismmkeynote

Seems like it can go sub 1ms

Re:Show HN: Strife, a 2D game library for Go by acln on Saturday September 29, 2018 @11:34AM (#18100931)
Sub-1ms STW pauses, even for very large heaps.