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

The mental effort you have to make to determine the overhead of an expression by looking at the call site is greater in C++ than it is in C.

Isn't this just a specific example of saying "the mental effort you have to make to determine the overhead of an expression by looking at the call site is greater in higher-level languages than in lower-level ones"?

It's true, precisely because you are using higher-level abstractions. I'd be more interested in seeing an example where this wasn't true.



This is besides the point.

The only good reason to use C++ is because you (1) need a level of abstraction that C doesn't give you, (2) need level of performance that no garbage collected language can give you (even compiled ones), and (3) can't even use C + Lua (or some other scripting language), probably because you need the abstraction and the performance in the same place.

(This is an awfully narrow application domain, compared to what C++ is actually used for)

At that point, the performance characteristics of your programs have become part of the specs. You do not want to hide them under the carpet like you would do with a garbage collected language. Yet C++ does. It wouldn't hurt if it syntactically distinguished initializations, casts, calls by reference and so on.


There's some truth in that, but I don't think "higher level" and "lower level" is sufficiently well defined to make that as automatically true as you present it. For instance, languages that allow you to redefine the assignment operator are not necessarily higher level than languages that don't.

Or take reference parameters. In C++, if you pass an object to a function you cannot know by looking at the call site if the object is going to be copied or not. The parameter could be defined as a reference, but you have to look at the function definition to find out. In C#, in Java, in Python and in C you know it by looking at the call site. These other languages are all over the place in terms of any high/low level categorization.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: