4 ms·
Sorry, but boilerplate in C++ ? Did he ever try using templates ? C++ is one language where you can get rid of boilerplate with a truckload of strategies. I su
by lenkite 4y ago
Sorry, but boilerplate in C++ ? Did he ever try using templates ? C++ is one language where you can get rid of boilerplate with a truckload of strategies.
I suspect [Ancient C/C++] weighed down with tech debt and utilising a plethora of old-code frameworks to Swift is what let him save 30%. If he did the port to Modern C++ and modern libs, he would have likely saved 50%.
- mkl 4y agoHe "typically" saved 70%, and overall >80% (152000 lines down to 29000).
- suby 4y agoI'm surprised by this take. C++ requires you to duplicate signatures in header files, which that alone requires a good degree of boilerplate. Modern C++ offers some tools to be more terse such as keywords like auto, but often times the "proper" way of doing things is the more verbose way. This is a bit of a strawman, but [[nodiscard]] constexpr int Add(const int& a, const int& b) const noexcept { return a + b; }
- bpye 4y agoI guess modules help this a little right? I haven’t used them for anything non-trivial so perhaps I’m overly optimistic.
- mpyne 4y agoThat example has nothing to do with modules. It doesn't even use templates (where concepts would help at least) or the "noexcept(noexcept(...))" thing. Modern C++ does help with most type specification, looping over containers, writing constructors and making value classes. It's definitely not all bad, but there's still a lot of boilerplate to C++.
- bpye 4y agoSorry, I was thinking of modules in response to > C++ requires you to duplicate signatures in header files, which that alone requires a good degree of boilerplate.
- suby 4y agoModules will definitely help but even modules unfortunately aren't perfect. You aren't allowed to have circular dependencies with modules, you need to forward declare. It's less boilerplate but still unfortunate imo.
- noobermin 4y agoauto is part of the language for reason.
- socialdemocrat 4y agoModern C++ is in some ways more boilerplate and more messy. I am so done with C++. Swift solves such a large list of C++ problems. Modern C++ solves very few of the problems I have experienced with C++ over the years. I get that people stick to C++ because it is too costly to port. But it doesn’t make a lot of sense to stick to C++ if you got the option to use Swift, Rust or Go. Swift avoids null pointers, undefined static initializations and de-initialization order, virtual call disasters when calling a virtual from a constructor. Protocol oriented programming solves a lot of problems you tend to run into in C++ when doing object-oriented programming.