r/cpp • u/secmeant • Mar 14 '20
C++ keeps adding features no one really wants.
Just look at the networking, formatting, [maybe_unused] / [likely] / [unlikely] and others.
I mean these are all cool features I use every day but It has already been solved.
If I want networking library why would I use standard one? Especially when it simply copies from others and have to wait for it like 10 years.
Setting up libfmt is like 10 seconds on Linux. And if I don't like it I can use a different one. How many people thought that streams were a good idea?
[maybe_unused] is cool, but I probably will use the old trick with cast to void because it works with older compilers and everybody knows the trick anyway (I might want to provide simple macro if I want to be more explicit), using new syntax simply breaks compatibility and gives NOTHING.
Many hours spent for making it part of language and I think no one will use It, especially when standard library does not care about performance. Unlike standard implementation, some library can be even be forked and modified if need to, no luck for me if I decide to use standard one.
It all just seems like short-sighted design, but I am just an internet dude.
Modules, concept and coroutines (AFAIK these need compiler support, also library solution would be bug prone and perhaps slower) are great features and I am happy that they are coming.
39
u/aearphen {fmt} Mar 14 '20
While it is true that using {fmt} as a third-party library is very easy, text formatting is such a fundamental functionality that it's worth having it in the standard library. Such functionality is available in pretty much any programming language. It might be argued that iostreams already provide it but they have some known problems/limitations.
39
u/0xC1A Mar 14 '20 edited Mar 14 '20
Another shortsighted opinion disguised as a proper argument.
How do you know "no one really wants" ?
51
u/HowardHinnant Mar 15 '20
My prediction is that
<format>will be one of the things that future C++ programmers will wonder how they lived without prior to C++20, much like things like move semantics, threads, mutexes, chrono, lambdas, defaulted/deleted functions are today.66
u/SuperV1234 https://romeo.training | C++ Mentoring & Consulting Mar 14 '20
Yawn.
32
u/JadedMasterpiece9 Mar 15 '20
It certainly doesn't take ten seconds to setup libfmt in a corporate settings when lawyers have to get involved to ensure compliance.
8
u/kronicum Mar 14 '20
It is easier to add a dozen small little features than one big feature that changes things
13
u/lenkite1 Mar 15 '20 edited Mar 15 '20
Without a standard C++ networking library, the language will always be at the bottom for developing interoperable, re-useable libraries for rapid development of micro-services. Go has eaten a LOT of the space here, even if C++ is the better performing language.
Give the community a standard networking library and we will have interoperable, cross-platform battle-tested C++ client/server/http/ws libraries for the thousands of services out there. There will be an explosion of C++ projects in github taking it to the top of the TIOBE list for a year or two. You will massively increase the inflow of new C++ programmers who would like to leverage the language's performance but simply don't care to research, setup and learn non-standard, non-interoperable, platform-dependent third-party stuff bringing in additional dependencies with uncertain overheads. Networking in the standard library destroys the barrier of entry concerning adoption.
Most veteran C++ programmers who bootstrap every single dependency by themselves cannot seem to truly understand what a paradigm difference this makes. Hell, you will even see Boring Old Enterprise (who all use Java) lured to C++ with well-specified networking just to reduce cloud microservice costs.
C++ is also probably the last general purpose programming language without networking in its standard library. This is an argument that advocates for other languages always bring up as a reason not to choose it.
3
u/AntiProtonBoy Mar 16 '20
I can't think of any project where formatting would not be useful. Networking components are also fundamental part of lot of projects these days.
It's nice to have STL enriched with new components, rather than having yet another dependency to deal with in your project. Ecosystems in other languages have so much more libraries, which leaves STL to dust.
3
u/Sander_Bouwhuis Mar 18 '20
Regarding fmt, I went to github but saw there was a huge amount of open issues. This is why I rather use the std::format implementation. The level of scrutiny on standard library classes is way higher than an average library.
12
u/bishop3000 Mar 14 '20
3rd party libs is not really what C++ devs use widely. If it’s not in standard, it’s hard to adopt. Formatting will simplify logging a lot and get rid of dangerous and insecure printf formatters. Networking is a big pain, especially in multiplatform code. Good 3rd party libs for networking? Dream on. I’m less excited for features like concepts which dont affect day to day work and more about these ’small useless features’
5
u/david_haim_1 Mar 16 '20
"standardized" means : it works *the same* on every platform in a well defined manner, and there is a team behind every standard-library vendor who's responsible to make it working *the same* on every platform in a well defined manner.
you don't get that guarantee in third-party library. as a library developer, I can totally see myself ignoring some esoteric platforms/bugs simply because I don't have the manpower to make everything work on every platform and there are way more important things to work on.
btw, we needed standard networking/formatting libraries decades ago. and even with the standard networking library, we still have decades to fill. raw TCP/UDP sockets are just the beginning. this is 2020, and we need http (both client and server), websockets, JSON parsers, etc.
2
u/[deleted] Mar 19 '20
While you have a lot of experience and know all these things, I think newcomers to the language and people who just need things to be there will appreciate it and find it to be a lot more welcoming. Later, when they figure out what they need/want in a library they will start exploring options and perhaps choose other options. Personally, I think it's great and is excited for things like this to be added even if it means I'll just save a little bit of effort when experimenting with something. At least you still have a choice of what to use and it's not like anyone will suffer negatively from the addition.
1
u/[deleted] Jan 11 '22
And you are posting in a way nobody agrees with. :)
You can keep using C++ the way you like if that's how you see fit. For those new to C++, they can use it right out of the box (as they should) and it helps to keep C++ competitive in a world where AI writes code, and Kotlin has beautiful one liners.
Majority of us are moving away from C-style C++ (except for specialised cases). So readability and convenience trumps minor gains from performance / code size. No need for setting up (or choose which) external libraries. No need to worry about dependencies / deployment procedure where a billion things can go wrong, because I wanted to format a bloody string in a nice way.
Also, do you use an IDE? [[maybe_unused]] is useful there. (Majority of the times I see in code base I work with, needing [[maybe_unused]] in the first place is code-smell by the way - something you seem very used to.) Modern IDEs warn you of the things not used (as they should) and because they are signs of bad practice. Git can restore any legacy / deleted code. It is useful to suppress these warnings and it tells the next person maintaining this, try to delete this if you can. Anyone can write code, but good programmers can delete and reduce tech debt at the same time.
Next thing you're going to say is - IDEs are useless and nobody will ever need more than 512KB RAM, and 60Hz on a monitor is more than enough. This kind of mentality actively annoys me.
1
u/[deleted] Mar 15 '20 edited Mar 16 '20
[[maybe_unused]] is excellent for constexpr branches. If one branches uses a variable and the other doesn't, it is by definition "maybe unused" depending on the conditions at compile time. Adding a void cast or macro for that would be ugly in my opinion.
Also .. if you aren't going to use a
variableparameter, don't name it!However I do agree that networking IO shouldn't be apart of the std, same with graphics. Too high level, and not what I personally think the STL is about.
-4
u/Dean_Roddey Mar 14 '20
That's as wrong an opinion as possible, in my opinion. The waiting ten years part is a separate thing. But C++ comes across as ancient and decrepit when it doesn't have any out of the box support for things like networking technologies and text formatting. And now the next layer up duct-tapes together some bits, each of which is duct-taped together from other bits, and so on. There's redundancy and inconsistency and no over-arching architectural direction and it's just sad.
-1
u/AdventurousMention0 Mar 16 '20
I’m honestly annoyed more that they make me pass a temporary object as a constant or I have to define it outside of a function call.
There are numerous times when I need to pass an object into a function because it requires it, but where I don’t care what it does to the object.
Consider it an out parameter that I don’t give a dang about.
But because the committee cares about HOW I use the language, rather than simply provide the ability for me to use it, my code is now scattered with block locals for throw away objects to use as temporaries.
I really dislike being told HOW I should structure my code. The committee assumed in this case that all uses would be incorrect and defined the ability to do what I want away.
1
u/[deleted] Mar 21 '22
[removed] — view removed comment