3 ms·
I love how C++ has had simple features like default arguments / function overloading for decades, while modern languages like Go and Rust require awkward workar
by TillE 10y ago
I love how C++ has had simple features like default arguments / function overloading for decades, while modern languages like Go and Rust require awkward workarounds.
Swift 3 looks good, though. They've learned the right lessons.
- catnaroek 10y agoDefault arguments, at least as done in C++, complicate the language's semantics (e.g., template specialization selection) far more than they raise the level abstraction. Definitely not a well-designed feature. And Rust's traits are a far more principled (and thus better!) approach to overloading than anything C++ has (Boost's concept checks?). Traits turn concepts into language entities that are directly expressible in Rust syntax, rather than in awkward English documentation.
- dominotw 10y agoC++'s problem was never 'not enough features' it was precisely the opposite.
- pcwalton 10y agoThere are also features that Rust has that C++ doesn't. So what?
- tomjakubowski 10y agoI certainly wouldn't say these are "simple features" in C++. Overload resolution in particular is one of the most complicated parts of the language. Default arguments can get weird since the right hand side of the default, more or less, just gets inlined at the call site; I do recall there were a couple bugs in the last year at work because of C++ default arguments, though I don't remember their details. It's also fun when you don't realize a particular function has a default argument until you make a function pointer to it and assign/pass it to something that you mistakenly think is compatible. Depending on how nasty your codebase's use of templates and overloaded functions is, this can be a nightmare to debug.