r/programminghorror • • May 27 '26

Javascript Destructuring strings

Post image
887 Upvotes

64 comments sorted by

View all comments

Show parent comment

11

u/Sacaldur May 27 '26

Same goes for many other languages and their shortcomings:

  • C++:

    • const correctness is desireable nowadays, but requires const everywhere (instead of it being the default
    • manual pointer handling is typically not necessary anymore, but unlike e.g. Rust they are easily accessible and part of the "fundamentals"
    • ownership modeling (with smart pointers) is important, but also just a "convention" (i.e. the compiler doesn't support you)
    • having to deal with headers. It's understandable why they are there, and why they are still there, but I feel like this is something that could be more automated
    • Macros
  • Java:

    • type erasure (forgetting the generic type arguments at runtime), made more difficult if you have generic and non-generic versions of the same class
    • primitive types not being part of the remaining type hierarchy and thus not an option for generics (you have to use their wrappers)
    • Optional<T> has some nice things about it, but there might have been better approaches (see C#, Kotlin, Dart, ...)
    • the Stream API is fine, as long as the predefined metgods are enough. Without extension functions/extension methods, you can't extend it yourself
  • C#:

    • even though nullabillity handling is better than in Java, Nullable<T> (like int?) doesn't behave the same as nullable reference types (e.g. string?): even after a null check you have to use .Value

Just some examples for some languages.

2

u/conundorum May 28 '26

C++ does have modules, now.

...You're probably still better off with headers, unless you start a new project and design it to use modules from the ground up, since they require actual design thought and can't just be slotted in like header copypasta.