Hacker News new | ask | show | jobs
by delta_p_delta_x 382 days ago
> but it failed as a library language

This is very inaccurate. Essentially every high-performance library, user-mode driver, desktop application, and more is written in nothing but C++. Give me any library you can think of, and I assure you it is written in C++ (or maybe C, but this is masochism on the part of the developers). Even libraries for other languages like numpy, pandas, pytorch, etc are written in C++.

1 comments

> or maybe C, but this is masochism on the part of the developers

C is the better choice when interoperability with other languages is needed (technically: a C API, the implementation language doesn't matter - but if a C++ implementation is wrapped in C API as an afterthought the result is usually a shitty C API). Personally I switched to C from C++ for writing libraries ca 2017 and don't regret that decision one bit.

Also, many C++ coders only have a foggy idea how convenient working in modern C can be, because their idea of C is usually the 'common C/C++ subset' that exists in C++, and this is stuck deep in the early 90s (for instance the designated-init feature in C++20 is a mere shadow of what C99 designated-init can do - to a point that the C++20 version is pretty much useless for real world usage).

> only have a foggy idea how convenient working in modern C can be

Here is a list of C++ features that C doesn't have, that are an immediate deal-breaker for me:

  - reference and move semantics
  - templates, and type constraints with concepts
  - namespaces
  - `constexpr`, `consteval`, and other compile-time magic
  - `auto` type deduction
  - trailing return types 
  - RAII (can't believe I put this this late, but eh)
  - a passable (although still not perfectly complete) standard library that blows the C standard library out of the water
  - improved semantics that allow programmers to reason about the logic in code better, than obsess over pointer arithmetic
  - built-in virtual functions, function pointer tables, etc
I can list more, but this is going to end up as a list of 'essentially every feature in C++ that isn't in C', which is the very reason for the former language to exist.
...now who's the "masochist" here ;)