Hacker News new | past | comments | ask | show | jobs | submit login

> 90% of C++'s useless standard library,

The Python library is even larger and doesn't seem to be a barrier. If you know `std::vector`, `<<`, and `std::sort` it seems you're set to contribute to most code bases.

> C++ would also not have been deprecated by Rust.

That's an overstatement, to say the least.




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


Python'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.


That example is not how C++ is used. It would not pass code review.


Why is code that wouldn't pass code review part of the language documentation?


Why are there falsehoods in Wikipedia?


Because it's written by random people who may or may not know the topic well. How does that apply?


I know supposedly "harder to learn" languages (i.e., functional languages), but my god does that example and C++ look impenetrable.


That is not idiomatic C++. The author is showing off esoterica.


It'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?


The library function is fine, although the long name is unfortunate. The apparatus around applying it, in the example, is aggressively weird.


I 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.


It is hard to know what you are talking about. It applies linear operators to an input sequence, defaulting to + and x, or whatever you specify. It is like inner_product, but sequence order is not specified.

There is a "range" version in C++20 that in use looks more like in other languages. (It is technically C++23, but appears in libraries shipped with C++20.)


It seems like a small thing, but everything about it is just slightly wrong. That it's called `transform_reduce` and not just `reduce`. The fact that it was in C++17 alongside a function called `reduce` that's basically useless. Why was it not in C++14? Why was it not in C++11? Why was it not in C++03?

That in 2017 the C++ standard committee was still introducing misdesigned cruft like std::reduce to the language says everything you need to be about C++, it's a clusterfuck.


Thanks 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.


It 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.


Python as a language is smaller even if the library is larger.

You can do many many things in Python without needing to know much other than working with dictionaries.

In C++, doing a sort or a string search is an ordeal. So much of common programming requires so much cognitive overload.

C++ is not an easy language. Not by a long shot.


I absolutely agree, but this comment referred to the library size as a major burden.


Ah fair. Though I do think the issue they meant is perhaps the C++‘s STL is not fleshed out enough to be as ergonomic and useful as Python.

Python’s standard library is not without its faults but I’m always so frustrated that the C++ STL stops just short of providing many things, and when it does, it requires writing out so much verbiage.


I don't think it is an overstatement to say that that imaginary world C++ would have been deprecated by Rust.

C++ complexity is also its strength. Highly backward compatible, even with C, and multiparadigm. It has classes, but you don't have to use them, it has exceptions, but you don't have to use them, it has templates, lambdas, smart pointers,... and again, you don't have to use them, but they are here if you need them. Even the "deprecated" features of C++ (like most things related to raw pointers) are heavily used today, even in new projects, because they are useful.

Strip 90% of "deprecated" C++ and what you get is essentially Rust, but worse because it still has its C baggage without the advantage of being mostly compatible with C.


I read the exact opposite. He's implying that real C++ has been depreciated by Rust, but that wouldn't be the case with imaginary-world C++.

(Rust has not replaced C++ in the real world. Not even close.)


How much of that can be attributed to it not having as much time to attract cruft? See Haskell, a very minimal and carefully designed language with a heap of complex and contrary extensions.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: