Re:Ask HN: What you up to? (Who doesn't want to be hired?)
by lukem567 on Monday November 01, 2021 @07:13PM
(#29074537)
Working on a way to write Oculus Quest apps in Golang. The entire thing is a tower of yak shaving. Current adventure: attempting to write a reactive UI system that doesn't need to dynamically allocate memory.
[ Parent
| on HN ]
Re:Ask HN: What you up to? (Who doesn't want to be hired?)
by messe on Monday November 01, 2021 @07:17PM
(#29074581)
> Current adventure: attempting to write a reactive UI system that doesn't need to dynamically allocate memory.
Avoiding dynamic memory allocation... in Go?
Re:Ask HN: What you up to? (Who doesn't want to be hired?)
by lukem567 on Monday November 01, 2021 @07:20PM
(#29074625)
One of the many yaks! In this case taking memory mapped Vulkan buffers and unsafeing them to various Go arrays and whatnot. I have a gapbuffer implementation on top of this, and then a truly evil "gaptree" implementation that uses gapbuffers to represent a tree data structure.
Re:Ask HN: What you up to? (Who doesn't want to be hired?)
by messe on Wednesday November 03, 2021 @12:07PM
(#29096580)
Do you need to work around Go's escape analysis much? I was under the impression that it's good but not perfect, leading to some heap allocation of variables that wouldn't necessarily need it if they were on C/C++.
Re:Ask HN: What you up to? (Who doesn't want to be hired?)
by lukem567 on Wednesday November 03, 2021 @10:48PM
(#29103176)
I think "good but not perfect" describes my experience here as well. I've certainly needed to rework some bits of code that were allocating when I didn't expect them to, but so far, this has not become too onerous (yet).
The "write a little bit of code, then test it to see if it allocates" approach has been very useful. That way I don't get too far out on a limb with a bunch of allocating code and no easy way to clean things up.
Re:Ask HN: What you up to? (Who doesn't want to be hired?)
by throwaway34241 on Monday November 01, 2021 @09:58PM
(#29075955)
It's actually easier than you might think: Go has most of the capabilities of C, including calling C APIs like malloc/free etc and casting them to Go data types. Of course (like C) writing code in that way won't be particularly convenient or memory safe.
Re:Ask HN: What you up to? (Who doesn't want to be hired?)
by messe on Wednesday November 03, 2021 @12:06PM
(#29096567)
Well, yes and no. My concern was the fact that Go's escape analysis isn't always correct (although it's quite good), leading to variables that would be stack allocated in C/C++, being heap allocated in Go.
Re:Ask HN: What you up to? (Who doesn't want to be hired?)
by throwaway34241 on Monday November 01, 2021 @09:48PM
(#29075860)
I'm also writing a Quest app in Go, maybe we should chat sometime! I added my email to my profile.