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

The term "zero-cost abstraction" is a bit annoying. By definition an abstraction has an obfuscation and compilation cost even if it doesn't add to the runtime cost. Too much of these and the program is not understandable anymore and takes hours to compile.


Zero cost abstraction has never meant anything other than 0 cost at runtime, so I don't see why you would get annoyed at it being used accuratcly.


I wish the term wouldn't exist.

I've measured "zero-cost abstraction" that weren't quite so when profiled.

What it really means is "if the inlining goes like the programmer expects, then it should have no cost". The term expresses hope.

But inlining is best left to the compiler, and hope is of little value until measurement is done with a profiler.


Inrust you can tell the compiler to always inline a given function.[1]

But you don't necessarily want to do that since you may not make the most efficient use of the CPU cache.

[1] https://doc.rust-lang.org/reference.html#inline-attributes




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

Search: