4 ms·
The difference between C++ and Python is that the Python standard library is actually useful to get practical work done (the famous "batteries included" philoso
by flohofwoe 5y ago
The difference between C++ and Python is that the Python standard library is actually useful to get practical work done (the famous "batteries included" philosophy). The C++ standard library can't quite decide if it wants "academical purity", or solve real world problems, and the result is a remarkably useless mishmash of random ideas.
- CodeGlitch 5y agoI find if you combine the standard library with boost, it does become pretty useful... Although some of the libraries in boost are beyond my understanding eg CallableTraits. I agree that the python standard library is really useful.
- je42 5y agoboost has quite a few useful libs.. unfortunately, some of the libs put performance first over ease-of-use. which can be a drag. and then there is compiling boost which is usually a thing where i need to set aside a day or two to get it working on a new platform / project.
- lostinparadise 5y agoWhat parts of the C++ standard library do you find useless/random?
- tialaramex 5y agoMaintenance matters. The C++ standard library provides some data structures you shouldn't use. OK, not some, C++ stdlib provides almost exclusively data structures you shouldn't use. But hey, the C++ language itself has some data structures you shouldn't use too (arrays especially). However, Python's standard library is stuck with urllib, although these days they have the courtesy to tell any poor fool looking at the documentation that Requests exists, if you do use the standard library you get very primitive HTTPS handling, and so many wrong defaults. Because these standard libraries have so many users, Hyrum's law means that you have to work very hard to fix anything.
- bsder 5y agoExactly. Just look at the mess that is the C++ String. This, of course, causes everyone to roll their own String, which is probably almost as bad. So, now we have a zillion String libraries, all of which suck. All because the C++ standard library doesn't provide a decent String.
- blub 5y agostd::string is not a mess, it's a good general string implementation which should suffice for many applications. Its only sin is perhaps that it does not support Unicode. If you look for example at other implementations like fbstring, the main benefit is performance.
- uranusjr 5y agoI think in urllib.request’s case (urllib.parse is fine albeit arguably with a cluncky API) it’s not they need to work very hard to fix it, but the task is impossible. My understanding is that bundling SSL validation in the Python stdlib is a lost cause since Python is updated way too infrequently and the stdlib cannot be easily changed once a Python minor version goes EOL, so they just gave up. If there’s anything Hynum in here, it’s they have their hands tied from removing the module entirely.
- Abishek_Muthian 5y ago> although these days they have the courtesy to tell any poor fool looking at the documentation that Requests exists Added up with "And when your project scales, Replace asyncio with uvloop, Coroutine with gevent, http.server with gunicorn and everything else with a cython based alternative". Or personally I just say 'Use go instead' to someone who's just getting into programming for developing a project which could potentially scale.
- blub 5y ago"C++ stdlib provides almost exclusively data structures you shouldn't use" The containers according to [1] are array, vector, deque, forward_list, list, *set, *map, stack, queue and priority_queue. All of these are good general implementations that can and should be used for most C++ software. Some classes of software require better performance or certain special guarantees and then it makes sense to consider specialized implementations. [1] https://en.cppreference.com/w/cpp/container https://en.cppreference.com/w/cpp/container
- shams93 5y agoYeah with python you have pip, with rust there is cargo wih c++ there is a whole painful largely manual process unless you use a big tool like bazel to help reduce the build complexity.
- 0-_-0 5y agoDamn right! The C++ standard is now at a point where a good standard library would be possible, but it's just not happening.
- blub 5y agoThese kinds of replies are the bane of interesting discussions because they're aggressive and don't contain any information... What is someone that is unfamiliar with the C++ standard library left with after reading it? At most an uneasy feeling, which is not based on any facts. So here are some facts: * A good reference for the C++ standard library is https://en.cppreference.com https://en.cppreference.com * The standard library is not as large as .NET or Java, but it covers many essential concepts of which the containers and algorithms are the best known. Besides classics like doubly-linked lists, dynamic arrays (std::vector) or maps, there's also sets, a singly-linked list, stack, queue and priority queue. All data structures have complexity guarantees defined in the C++ standard, which is surprisingly very rare for programming languages. * The algorithms include sorting and searching but don't stop for example at a simple sort and instead also include a partial and stable sort. Besides binary search and linear search, there's also functions like https://en.cppreference.com/w/cpp/algorithm/lower_bound https://en.cppreference.com/w/cpp/algorithm/lower_bound or https://en.cppreference.com/w/cpp/algorithm/equal_range https://en.cppreference.com/w/cpp/algorithm/equal_range and several functions for working with heaps, such as make_heap, push_heap, etc. Other interesting algorithms include those for permutations, counting, working with ranges and modifier functions like rotate, sample or random_shuffle. C++ offers a world-class algorithms library. * The numeric library offers support for many pseudo-random number generation algorithms, and many distributions (https://en.cppreference.com/w/cpp/numeric/random https://en.cppreference.com/w/cpp/numeric/random). There are dozens of usual (https://en.cppreference.com/w/cpp/numeric/math https://en.cppreference.com/w/cpp/numeric/math) and less usual (https://en.cppreference.com/w/cpp/numeric/special_functions https://en.cppreference.com/w/cpp/numeric/special_functions) mathematical functions in there. * For systems programming there's the date and time utilities, file system, threads and atomics. * Although standard for most languages at this point, C++ does offer regular expression support in the standard library. * Many other smaller types and functions such as tuples, complex numbers, a modern union type (std::variant), streams, etc. When the above is not enough, there's boost, a series of high-quality libraries with a long history which are like an extension of the standard library. My personal favorites from boost include state machines, graphs, numeric conversions, logging, program options, signals (subject-observer implementation) and ASIO for all sorts of IO. But there's tons of stuff in there, from additional algorithms and containers to JSON parsers to HTTP and web sockets, from process and shared object management to userland threads, IPC, lockfree data structures and so on and so forth. And if that's still not enough, there's almost certainly another library for it. C++ is one of the most popular programming languages out there and it has decades of history behind it.