News for hackers. Stuff that matters.
Re:C++ Is the New Python by flohofwoe on Wednesday July 14, 2021 @02:06PM (#27836225)
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.
Re:C++ Is the New Python by tialaramex on Wednesday July 14, 2021 @02:47PM (#27836805)
Maintenance 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.

Re:C++ Is the New Python by blub on Thursday July 15, 2021 @03:17AM (#27842187)
"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

Re:C++ Is the New Python by uranusjr on Wednesday July 14, 2021 @07:54PM (#27839924)
I 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.
Re:C++ Is the New Python by Abishek_Muthian on Thursday July 15, 2021 @03:44AM (#27842329)
> 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.

Re:C++ Is the New Python by bsder on Wednesday July 14, 2021 @06:10PM (#27839067)
Exactly. 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.

Re:C++ Is the New Python by blub on Thursday July 15, 2021 @03:27AM (#27842231)
std::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.

Re:C++ Is the New Python by 0-_-0 on Wednesday July 14, 2021 @03:36PM (#27837432)
Damn right! The C++ standard is now at a point where a good standard library would be possible, but it's just not happening.
Re:C++ Is the New Python by CodeGlitch on Wednesday July 14, 2021 @02:28PM (#27836542)
I 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.

Re:C++ Is the New Python by je42 on Wednesday July 14, 2021 @03:57PM (#27837680)
boost 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.

Re:C++ Is the New Python by blub on Thursday July 15, 2021 @03:05AM (#27842135)
These 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

* 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 or 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). There are dozens of usual (https://en.cppreference.com/w/cpp/numeric/math) and less usual (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.

Re:C++ Is the New Python by shams93 on Wednesday July 14, 2021 @02:52PM (#27836853)
Yeah 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.
Re:C++ Is the New Python by lostinparadise on Wednesday July 14, 2021 @02:29PM (#27836564)
What parts of the C++ standard library do you find useless/random?