6 ms·
if i could have function overloading, operator overloading (particularly (), ++, --, *) and i could auto-convert my existing codebase to C, i'd move right now t
by uwagar 5y ago
if i could have function overloading, operator overloading (particularly (), ++, --, *) and i could auto-convert my existing codebase to C, i'd move right now to C. i stay with C++03 and thats enough.
- google234123 5y agoNo unique ptr, auto, or for each loop? No thanks
- uwagar 5y agoi write/maintain solo this software for 15 years and just dont want to start doing autos in for loops. then i have to go and change all the loops otherwise it would bother me. i dont want to go back and start messing with code that is pretty solid all these years.
- ncmncm 5y agoThe answer is simple: just don't. Write new code the new way, and leave old code that works alone. There will never be a case where you wonder why old code looks like old code. Continuing to write new C++03 is just masochism. You might find reasons to switch some old stuff to use move semantics, eliminating reference counts, which is a small job. Leaving alone stuff that doesn't need to change needs only discipline, not time. Discipline builds with use. I recommend it.
- uwagar 5y ago> Continuing to write new C++03 is just masochism disagree. this keeps things simple, readable and maintainable. beyond STL i havent found need for any new data structures or algorithms. i roll my own for domain specific (audio/graphics). > Discipline builds with use. I recommend it sure daddy. perhaps if the c++ committee had discipline they wouldnt have added these crazy things to the language too and made it a mess that it is today. however we masochists are pleased with the concession offered by stroustrup's one-liner: 'if u dont use it, u dont pay for it'
- maccard 5y ago> disagree. this keeps things simple, readable and maintainable Unique pointers pre C++11 are fundamentally broken, and smart pointers are the poster child for modern C++. Other features like nullptr, enum class, range based loops, and constexpr provide huge gains in readability too. > i havent found need for any new data structures or algorithms That's great - however the unordered contains are for many people a drop in replacement with a performance boost that came in C++11 .
- simplestats 5y agoHow hard is it to read a "for" loop? Even when programming in python, half the time I find myself switching to a simple loop over an index because I realize I need the index. Often it's for debugging, because that index has a real meaning I can interpret when I see it. Along those lines, I think the real disconnect in the argument here is in terms of what kind of problem people are programming for. For many applications, advanced C++ is solving problems they don't have. The above poster mentioned audio. The data there is in single (or perhaps few) big buffers with a very simple and regular structure determined by international standards. They only need a few simple pointers. Or maybe just std::vector. Similarly just a few types also with real-world meanings. Debugging may require them to check the processing in ways that abstraction, type-checking, etc. will only get in the way of. And new features may not work within whatever abstractions had been put into place for previous features anyway, because the features relate to the underlying data.
- dragonwriter 5y ago> Even when programming in python, half the time I find myself switching to a simple loop over an index because I realize I need the index. If you need to iterate over an iterable xs and discover you need the index as well, in Python you shouldn't switch to a loop over the index, you should switch from: for x in xs: ... to: for idx, x in enumerate(xs): ...
- maccard 5y ago> How hard is it to read a "for" loop? for (std::unordered_map<std::string, int>::const_iterator it = some_map.cbegin();it != some_map.end(); ++it) is pretty damn unreadable (and for bonus points it doesn't compile) compared to for (const auto& keypair : some_map) Which doesn't have the possibility of the issue in the previous snippet (cbegin != end rather than cbegin != cend) > For many applications, advanced C++ is solving problems they don't have. No-one here is talking about advanced c++, we're talking modern c++. > The above poster mentioned audio. ... They only need a few simple pointers... And we all know that audio is immune from massive security vulnerabilities, right? [0] "New" features like nullptr (instead of NULL), unique_ptr, move semantics as examples can just flat out avoid classes of bugs that come up in low level programming, and features like constexpr and static assert can make runtime checks compile time checks instead. All these features can be escape hatched if you really really need to just cast to a void pointer to fill a buffer at the end, but the surface area for nasty bugs is significantly reduced if you do so. [0] https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-41331 https://msrc.microsoft.com/update-guide/vulnerability/CVE-20...
- david2ndaccount 5y agoIf you’re willing to stick to clang you can get function overloading in C. I don’t think you can get operator overloading though. https://clang.llvm.org/docs/AttributeReference.html#overloadable https://clang.llvm.org/docs/AttributeReference.html#overload...
- uwagar 5y agohah i like operator overloading, making function objects etc.
- DoctorDabadedoo 5y agoI'm starting to grudgingly think the same. Although I like some aspects of C++, the feature set and evolution over the years bothers me, C++20 seems almost like a different language from C++11, like C++11 was to C++03 but with none of the joy for me, with a lot of features that seem to over complicate things over time detrimental to the improvements they bring.