News for hackers. Stuff that matters.
Re:Four common mistakes in audio development by jerf on Wednesday June 15, 2016 @08:48AM (#11908960)
You'd have to write in a bit of a dialect of Go to make sure you don't get bad GC behavior. It's possible in Go, unlike many scripting languages, to write in an allocate-up-front style that doesn't generate garbage, in pretty much exactly the same way you'd do it in C. If you write in the C style, you get a lot of C-like behavior, only with memory-safety. But you don't get much support from the runtime for this style; for instance, if you accidentally append to a slice beyond its capacity, the runtime will simply reallocate the array, there's no way to ask it to not do that and throw an error instead or something, beyond not using "append" (hence my comment about the "dialect"). ('Course, there isn't really one in C either; arguably reallocation is better than a segfault here, as one merely risks an audio pop at some point whereas another guarantees it.) There is also no way to prioritize a goroutine.

I think people end up overselling the difficulty here, because people often strike me as speaking as if the 10ms maximum GC delay is actually the minimum or something and as if the GC is running uncontrollably keyed by a random number generator or something, rather than the amount of garbage generated. It's not that hard to imagine an audio application that runs a 50us GC every several minutes or even less often if you preallocate everything. In practice it's not entirely dissimilar to writing in C and avoiding malloc.

But the real level of difficulty is still something that should make you think, especially as you move from "a single filter" to "a full synthesizer suite".

Rust would generally be a better language, as long as you can step up to the somewhat-harder language, and can find the libraries you need. The payoff for the somewhat-harder language is that you'll have much better assurances about many of the relevant issues. It's what I would generally choose for this task, again, given libraries. But if someone did want to use Go because it's a bit simpler of a language, I wouldn't immediately breath flames on them, unless they were being obviously too ambitious.

Re:Four common mistakes in audio development by pconner on Wednesday June 15, 2016 @02:40PM (#11911123)
> It's possible in Go, unlike many scripting languages, to write in an allocate-up-front style that doesn't generate garbage, in pretty much exactly the same way you'd do it in C

I am very interested in this. Do you have any links with more info?

Re:Four common mistakes in audio development by jerf on Thursday June 16, 2016 @11:00AM (#11916573)
Basically, the link would be the language spec. Go's structs are "value types". Until you deliberately take a pointer or access them through an interface, they're just structs, like C. It also has real arrays.

In many ways, Go is like a scripting language, but it does let you do some systems-like things in a way that Python or Perl or the other similar languages completely don't.

Re:Four common mistakes in audio development by greenleafjacob on Wednesday June 15, 2016 @10:54PM (#11913614)