4 ms·
The basic spec, Stroustrup's c++ is simple. The insanity really began when attempt to further formalise, and narrowly specify the language revealed glaring gap
by baybal2 5y ago
The basic spec, Stroustrup's c++ is simple.
The insanity really began when attempt to further formalise, and narrowly specify the language revealed glaring gaps of the basic spec, and a decade+ period of haphazard fixes to the standard started.
- tsimionescu 5y agoBut even the basic, original spec was extremely complex compared to any other language I for one know. For example, there is no other language that has as many type qualifiers as even the original C++ - volatile, static, const, extern, inline (for function types), mutable (for members), pointer (*), fixed-size array ([NUM]), reference (&), throw (for function types), virtual, friend [we could add unsigned and long, but those at least only apply to a few built-in types]. C++98 had the same value categories (lvalue and rvalue) as C, but already more complex interactions between these and various other language features, because of references if nothing else. Then, C++ has not one but two kinds of pointers - C-style pointers and references, which each interact with other languages differently. C++ has the most complex function overloading rules of any language. Made all the more complex by the special interaction between single-parameter constructors and function overloading. Operator overloading adds yet another layer of complexity, being slightly different than function overloading rules. C++ has exceptions and destructors and special interactions between them. Exceptions also interact with the reference and type specifier system in complex ways. C++98 even had exception specifiers which also have interactions with the type system in general. C++ has templates, with the myriad complex rules for their syntax (e.g. the little known second meaning of the keyword "template"), for name resolution inside template definitions, for template interactions with the linker. SFINAE is also a famously hard to understand rule, that interacts so nicely with overload resolution that it turns the compilation process into a turing-complete language of its own. C++ has namespaces, which interact with name resolution and thus templates and overload resolution in several ways. In the same vein, it has private, public, protected, and friend, all interacting with name resolution. C++ supports multiple inheritance, with complex rules for how objects are constructed in the presence of multiple super classes. C++ has 3 different ways of initializing member variables, with defined interactions between them (in-place, constructor initiator list, constructor body). C++ inherits C's pre-processor, while adding new ways for it to interact with linkage rules (because of templates, default constructors/destructors).
- KptMarchewa 5y ago>C++ has 3 different ways of initializing member variables, with defined interactions between them (in-place, constructor initiator list, constructor body). If you generalize that to variables, you get 18: https://accu.org/journals/overload/25/139/brand_2379 https://accu.org/journals/overload/25/139/brand_2379
- throwuxiytayq 5y agoC# could probably rival C++ with its sheer keyword count thanks to LINQ's SQL-like syntax (that most people don't use anyway since you can just use regular methods instead), but in contrast to Stroustrup's monstrum, it's an incredibly well-designed language. Some of the core language features are built on top of foundations thoughtfully introduced many language versions earlier, all the way to C# 1.0. Still, the cruft accumulates, and I dread the day when the language will become recognizably C++ish. Feels like things are getting out of control already - most C# programmers I've met know/use barely any of the features introduced after C# 6.0. (They're pretty good, though. The features, I mean. But the programmers also)
- programmer_dude 5y agoJust wanted to let you know: you may be suffering from stockholm syndrome.