4 ms·
Let me link to a (very longwinded, sorry) post I made a while back explaining how a particular type of memory pool allocator works: https://news.ycombinator.com
by ANTSANTS 13y ago
Let me link to a (very longwinded, sorry) post I made a while back explaining how a particular type of memory pool allocator works: https://news.ycombinator.com/item?id=6176091 https://news.ycombinator.com/item?id=6176091
tl;dr if you think "manual memory management" means "malloc thing, use thing, free thing" you're kind of missing the point.
Also, tricks like Duff's device and XOR swap have long since become pessimizations, not optimizations, on desktop and mobile-class hardware. Duff's device, for instance, wastes instruction cache when any decent CPU's branch predictor can eliminate most of a simple loop's overhead anyway. With the exception of manually vectorizing tight loops to take advantage of SIMD hardware (which is more of assembly's domain anyway), I think the "optimized C" of today looks pretty straightforward and unobfuscated, just with more attention paid to the details that higher level languages mostly gloss over for you.
> ...and possibly my generation has missed out on something wonderful...
I'm pretty certain I'm younger than you, I just grew up really wanting to make games and know how computers work. Maybe you don't need or even want to think about this kind of stuff, but it's not like the problems just magically disappeared one day. Or, more bluntly, "if C and C++ are so dumb then why isn't your browser written in Python?"
- pjmlp 13y ago> Or, more bluntly, "if C and C++ are so dumb then why isn't your browser written in Python?" Because Python's standard implementation, CPython is an interpreter?
- asveikau 13y agoI think the HN crowd honestly believes that the only reason the next browser hasn't been written in a GC language is momentum and time. That the next one will very obviously be written in Ruby or Python. I've seen discussions here to that effect. I find it hard to read HN discussions about C. One faction is totally amazed by the C equivalent of being able to tie their shoes. The other faction believes shoelaces are obsolete and everyone should wear velcro. This "my generation has missed out" thing is really odd... If you are honestly interested in it, go learn how it works! The commenter you're replying to should quit making excuses.
- recuter 13y agoSorry for the poor phrasing, maybe you've misunderstood: I've mentioned that I'm interested, am fond of it, and have learned how it works. Not sure what excuses you're talking about. OTOH, for when I'm not writing a browser, a HFTs, or the next-gen video game engine, the trade offs are increasingly not worth it. On top of that we don't have Amigas to have fun with anymore and stay close to the hardware on (I guess maybe Raspberry Pi qualifies as some sort of substitute) and so that particular brand of hacker, a small group to begin with, keeps on shrinking. That's what I meant by missing out.