| ▲ | marcosdumay 6 hours ago | |||||||
The thing you are annoyed about in C++ is not constructors. It's the overloading of syntactic operations. The C++ design bets heavily on that. Just like you can overload an operator, you can also overload the meaning of `=`, `new`, variable declarations, and etc. That necessarily leads to an awful complex language, but also a very powerful one that can potentially lead to very easy to read code in high abstraction levels. The problem both C++ and Swift have is that you can't really build high abstraction levels, because the languages are designed in a way that makes some fixed concerns creep over your entire code. | ||||||||
| ▲ | ninkendo 6 hours ago | parent [-] | |||||||
I get that for C++ to have all this overloading it needs constructors, but Swift doesn't take the same bet as C++ does when it comes to overloading, yet it still has first-class constructors anyway. So do lots of other languages (Java, C#, TypeScript, etc.) Swift is especially interesting because it's basically a successor language to Objective-C, and Objective-C did not have first class constructors (`-init`/`-initWithFoo:` is just a convention), they chose to add it anyway. | ||||||||
| ||||||||