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

The problem with C++ is that you either want to write low-level code, in which case you ultimately end up using C, or you don't care about low-level stuff, in which case higher-level languages (python, ruby, java) are much simpler, make it harder to shoot yourself in the leg etc.


Low level is different from high performance. C++ is much higher level than C yet still retains its performance.


It isn't much higher level, it is just more feature rich. You can still, with minimial tweaking, take any C program and compile it as C++. You just get more of the kitchen sink with C++, and what the article doesn't mention is how a subset of that sink makes code simpler, more maintainable, and more logical.

Just by having templates and classes doesn't make it higher level. It just means it has more feature parity. More higher level is when you can say "aspect X of the execution environment is barred from the language for the sake of abstraction, such as Java's garbage collection or Python's list comprehensions or dynamic types." You can't chose an alternative, so the level is raised on those issues since the language deals with them for you.


I think what you are both trying to say is that C++ was designed to ensure you "only pay for what you use"? Remarkably successful at that, really.

Kinda falls apart in some cases. For example the standard says with respect to inline functions that:

An inline function with external linkage shall have the same address in all translation units.

So I guess for the purpose of not having to worry about comparing the values of a function pointer to an inline function or worry about assignment semantics? Actually I have never really understood the point of this part of the spec.

Anyway, the cost of this is not negligible, since the linker has to maintain state for those cases where inline replacement is not an option[0]. As a result, even if you don't use this feature of the language, you pay for it with increased link time and object file sizes. But this is a pretty arcane corner case to pick on.

[0]: http://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html


There are dozens of them though, like name mangling bloating code size even if you forego namespaces. Not saying the compiler doesn't have some inherent inefficiencies, but it still is operating at the same level as C.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: