C++ Features Adapted as C Idioms

I didn't think it could actually be that bad.
> github.com/crawl/crawl/blob/master/crawl-ref/source/ability.cc#L1796

What's wrong with a big switch statement?
How would you be doing it?

I am working on a dataabase driven app write now, and goddamn, the number of mallocs required is stupid. String concatention in C is retarded.

Its as I'd that's already best practice.

and how do you do that? can you be more specific?
in any nontrivial program there will be some copying somewhere.

When not written by a Pajeet, code like this would compartmentalize rather than just glue fucking everything into a giant switch statement. A good way to realize what's wrong and also think about the right way to do it would be to ask yourself, "how would I add support for mods here?". You'd have some sort of struct representing things like this that would have its callback registered with the ability code. The result would be an ability.cc that is very small, ability code that could be grouped into its own file, and ability.cc could use datastructures to do the lookups rather than potentially roll through hundreds of comparisons looking for a match.

Maybe it's just your inexperience? C isn't Java, we avoid allocations. Software that has to be fast doesn't even use malloc.

I'm not sure how I can describe it, but it's really rare that good C and C++ copy anything. For an example, I just grepped 100k LoC of my C++ code for them and there were only 3.
There's probably a difference here depending on what language you came from. If you went from C to C++, you're unlikely to do something like add a copy constructor so you can let stl containers value copy your data because you know how fucking stupid what's going on under the hood is and know to avoid it.

Dennis Ritchie and Ken Thompson were the first Pajeets.

I don't think you understand how their implementation of abilities works. Your solution is more code, more files, and undoubtedly less efficient.


You keep using this joke as if it were the core design principle of UNIX. Tons of error recovery code is a waste of time, and bloat, unless you're writing a fault-tolerant financial system.