Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is just bloody stupid.

If you care about performance, you don't use OOP, you don't use if/else, you don't use switch{case}, what you do is you write the hot parts in assembler.

If you aren't writing it in assembler, you're writing slow code.

But that code is still not optimised until you've implemented it in an ASIC.



> If you aren't writing it in assembler, you're writing slow code.

Depends in part in how good you are at writing assembler.


True, with modern processors there is a hell of a lot of "it has to be this way round for the pipeline to flow" that the compiler does for you.

But you're still throwing away so much time on things like bounds-checking memory accesses that never need it.


> But you're still throwing away so much time on things like bounds-checking memory accesses that never need it.

Are you? C++ doesn't check bounds by default, and Rust only checks in certain situations and you could opt out if you wanted to instead of switching to asm


C++ is tremendously bloated though, and wastes hundreds of instructions with stuff you shouldn't need to care about.


> stuff you shouldn't need to care about

Such as? I don't believe any C++ compilers are producing extra machine code just for the fun of it.



> I literally have never found a place where `std::variant` has any positives that can't be written a different, clearer way with drastically better compile time and run time performance.

So, don't use std::variant? To produce performant output from a C++ compiler, you have to make the same sort of informed decisions that you would if you were writing assembler. Possibly not using the standard library at all.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: