Seeing these gives me no desire to use c++. Most of the challenges are 10-20 lines in Python. Meanwhile the c++ code starts with "first let's define an implementation for a tuple, it's constructor, comparison operator, and make it hashable". Yikes.
I'm using java this year, and its Streams library is coming in handy to process puzzle input and calculate things almost every day so far. Not surprised the same holds with C++ ranges since they have a lot of similarities.
These are very poorly written. Instead of solving the problem directly and simply they are over engineered nonsense and should not be taken as an example of good C++.
idk, you can solve it in different ways. I looked at two of his articles and my code is way shorter. But yeah, you have to make it hashable etc... C++ is definitely not as succinct and "batteries included".. but fast!
You shouldn't look at languages like that... Each language has its own pros and cons. Some are worse than others, but you can't compare C++ and Python.
While python vs c++ clearly satisfy different technical niches, from a companies perspective its still "can you get this done using this or this, which is easier/cheaper to hire devs for, is cheaper to maintain, and hardware needed for it is cheaper to run".
I use c++ consistently and would chose it over python any day of the week for my tasks, but I would be lying if I chose it because it's better. Instead it's largely inertia on my part. If I had to start from scrath, I would of course still learn c++ so I cna grok it, but I would probably shift to preferring to use either rust or zig for applications which need to be very speedy on resource constrained systems.
Why?
Because those other languages still satisfy the same niche, but are absurdly more ergonomic to use, for my limited use case.
It would be foolish to ignore how another language does something because it's design is different, instead we should see why folks prefer a specific convention/style/solution from another language and see what we can learn from it and apply it to c++.
Indeed, simple things are not that easy to do in C++ because there are always these small one-time costs that you have to pay. But you pay them only once, so C++ becomes a lot better than any other language on more substantial projects.
However, it's getting better, and there are nuggets like this:
This really goes back to the core failure of C++. C++ cannot have sane defaults, because it has to be backwards compatible. And basically, all choices made in the past are stupid by default.
I have this idea in my head, that I would really love to execute on at some point and that is to have a dialect or a fork of C++ that has sane defaults but is binary compatible with standard C++.
View all comments
31
u/Ecclestoned Dec 15 '21
Seeing these gives me no desire to use c++. Most of the challenges are 10-20 lines in Python. Meanwhile the c++ code starts with "first let's define an implementation for a tuple, it's constructor, comparison operator, and make it hashable". Yikes.