4 ms·
In Python the standard library is fairly easily traversed and understood and if there's a better way of doing something it's usually linked I think. In C++ we h
by tinco 4y ago
In Python the standard library is fairly easily traversed and understood and if there's a better way of doing something it's usually linked I think. In C++ we have.. this..
https://en.cppreference.com/w/cpp/algorithm/transform_reduce https://en.cppreference.com/w/cpp/algorithm/transform_reduce
- Silhouette 4y agoPython's standard library includes many modules for specialised applications and yet it's surprisingly lacking in fundamental data structures and algorithms. Personally I think that's the wrong way round. Simple things like building dicts from different data structures or working with optional values that can be something or None just aren't there and you always seem to end up with some kind of utils.py full of hand-written functions to do these things that everyone writes again every time when they would have been either built into the syntax or a one-liner using the standard library in some other languages. I agree that the C++ example is (one reason) why modern C++ has jumped the shark.
- moloch-hai 4y agoThat example is not how C++ is used. It would not pass code review.
- xigoi 4y agoWhy is code that wouldn't pass code review part of the language documentation?
- moloch-hai 4y agoWhy are there falsehoods in Wikipedia?
- xigoi 4y agoBecause it's written by random people who may or may not know the topic well. How does that apply?
- bmitc 4y agoI know supposedly "harder to learn" languages (i.e., functional languages), but my god does that example and C++ look impenetrable.
- moloch-hai 4y agoThat is not idiomatic C++. The author is showing off esoterica.
- bmitc 4y agoThanks for the heads up. From the outside looking in, my perception of the difficulty of learning C++ is knowing what is idiomatic or not, with the understanding that that differs depending on who you work for and with.
- moloch-hai 4y agoIt is the same as in other languages: you do the simplest thing that gets the job done. Loops, particularly C-style "for" loops, often do not count as simple, despite their familiarity: std:: algorithms leave less scope for error.
- tinco 4y agoIt's not? This is literally the function that I found I should use when I wanted to fold over a list I had. What would you recommend I use?
- moloch-hai 4y agoThe library function is fine, although the long name is unfortunate. The apparatus around applying it, in the example, is aggressively weird.
- tinco 4y agoI agree that the example is crazy. But the function is not fine, it's a testament to how unhinged the C++ standards committee is. Its existence is proof that the problems of C++ are not just with its history, but that it is an ongoing snowball of incompetence and bad decisions.