4 ms·
Oh interesting. I was expecting to see nonsense in that video (probably triggered by the first line -- C and C++ are basically the same thing, in that you can,
by dboreham 2y ago
Oh interesting. I was expecting to see nonsense in that video (probably triggered by the first line -- C and C++ are basically the same thing, in that you can, and folks did forever, implement all the C++ fancy stuff in C -- just because something isn't in the core language, doesn't mean it wasn't done).
But actually it's suggesting how I've been wanting memory to be managed for a couple decades (and have achieved long ago in C projects). Basically some sort of "domain-orientated arena allocator". A simple example is in a network server -- you receive a request from a client, do a bunch of stuff to service that request, and now you're done. Please blow away the memory used to service the request, thanks, all at once. Of course it's not quite that simple because there will be some "chaff" objects thrown off in processing the request that we need to keep around for a while later (e.g. for logging to drain).
I suppose the reference to Jonathan Blow should have been a clue that this would be something worthwhile.
- bsder 2y ago> C and C++ are basically the same thing I disagree here. For example, try writing something that does reference counting in C vs C++. In C++, it's practically trivial. In C, it's a nightmare of bugs. RAII support being directly in the language is huge in this case.
- saagarjha 2y agoCasey writes games. Of course to him everything ought to be an arena allocator. This is not actually the best way to write all software.
- bsder 2y agoThat's a bit glib. Games almost always have significant networking component nowadays. And Andrew Kelley writes compilers. And arenas still appear to be superior. Games and compilers seem to do better with custom allocators. Embedded almost always static allocates. GPU workloads generally don't have "heap-like" allocations either. We have an increasing amount of evidence that "malloc-like" or "heap-like" allocations on an individual level seem to be a net negative. My gut feel, as someone with a grey beard, is that we're looking at a breakpoint like we did with garbage collection. Garbage collection absolutely suuuuucks until you get big enough memory that you can overallocate by about a factor of 2 at which point garbage collection flies. I think we're at a similar point in "systems programming". It's now okay to overallocate, overcopy, and especially overcalculate things due to current CPU architectures. Chasing pointers is now mega-bad so vtables and the like are becoming a performance bottleneck.
- kazinator 2y agoEmbedded almost always static allocates is outdated, like integer is almost always faster than floating point. Some embedded nowadays has hundreds of megs of RAM, with its application using mmap, out of an overcommitted virtual memory.
- bsder 2y agoI would argue that if you have an MMU, you aren't really "embedded" anymore. An RPi isn't "embedded". However, you may still be doing systems programming.
- kazinator 2y agoEmbedded means that something that is not itself computer contains one, running some dedicated control application. If a Raspberry Pi is built into a toaster, where it controls the temperature and toasting duration according to the user-selected selected darkness level, it's embedded. If the toaster has a screen, and you can install and uninstall apps on the Pi, then it doesn't look so embedded any more.
- mustache_kimono 2y ago> And Andrew Kelley writes compilers. And arenas still appear to be superior. Is Andrew pro-arenas for compilers? I have seen him preach re: data oriented design, and Zig certainly does more re: allocators than Rust, but do you have more info re: this claim?