Live data from Hacker News

Does C++ still deserve a bad rap?

nibblestew.blogspot.com

151–160 of 310 posts

Re: Does C++ still deserve a bad rap?

#151

I've never actually had a problem with c++ grammar or syntax or logic What I do have a problem with is trying to interface with more complex apis and functions. For example a while back I had to implement a https get and post request and it was a total nightmare. Something that takes only a few lines in python took a few days to figure out. Maybe it's lack fo experience but I tried wrestling with libraries like pocco…

Modern C++ with libcurl API’s still isn’t great. I’ve found the Python and Go http API’s much more intuitive.

This is just a bad library. The library I use in C++ (which I wrote) is pretty much the same as Python requests2 library (or whichever the good one is now... I forget the names as I honestly also rewrite the Python HTTP API layer myself over httplib as the ones that used to come with Python sucked also).

Re: Does C++ still deserve a bad rap?

#152

Earlier quoted context omitted.

It is possible with a regex iterator #include #include #include int main() { std::string s = "Python*C++*Java"; std::regex regex("\\*"); std::vector out(std::sregex_token_iterator(s.begin(), s.end(), regex, -1), std::sregex_token_iterator()); for (auto &s: out) { std::cout

Hey just curious i have only coded c++ in school I’m curious to know why don’t we use `using namespace std;` in real world when writing c++

In addition to the other comments (which are the primary reasons), beware that you can actually get different behavior due to something called "argument-dependent lookup". The most well-known example being std::swap(a, b). In general it is not equivalent to using namespace std; swap(a, b), though in this case, you actually want to say something else (using std::swap; swap(a, b)) to avoid importing the entire std namespace while also ensuring you call the ADL version of swap that may have been provided.

Re: Does C++ still deserve a bad rap?

#153
post #4

Earlier quoted context omitted.

Because it doesn't even exist as provided functionality; you have to code basic stuff like this yourself. See for example https://stackoverflow.com/a/14267455

This is my annoyance with C++, it feels like the effort put into the language is disproportionate. As in, the committee is off solving problems that a handful of library implementors will use, but basic things like splitting strings or trimming whitespace is ignored. Yes these are fairly trivial but you either roll them over and over or start carrying around a little utility library.

After having used both Python and C++ for a while I concluded that most of the problems of C++ could be solved by a proper standard library.

Re: Does C++ still deserve a bad rap?

#154

Any software where you will need to develop serious things for will suck. Almost nobody feels miserable in languages like python because they rarely have to deal with the ugly stuff or having people depending their lives on it. Thats the 50% of the fun writing in it, because you will deal mostly with the cool things, and who would not like the language that gives you that kind of pleasure? And the languages that are…

> Any software where you will need to develop serious things for will suck.

Well, "serious things", that is, larger, robust programs need a lot of experience and discipline. This is true in any language and if people do not watch for it their library landscape turns into a hot mess quickly. Take Python.

But the thing is, I believe that in many applications, C++ does not make it easier to build serious things. It adds complexity and when working on large-scale stuff, you need extra complexity as much as a hole in the head.

Re: Does C++ still deserve a bad rap?

#155

Like every programming language out there, C++ is a tool. And like every tool out there it has its uses. There isn't any point of using C++ to count words in a text file. Any high-level language like Python will beat you to it. However, there's one thing you can do in C++ and not in Python or JavaScript or PHP: fully control the memory layout of your data. While you don't need it in most of the cases, it becomes a ki…

Just because there's a tool in a niche doesn't mean it's the best one. I could do all those things you listed in Rust with much less headache.

Re: Does C++ still deserve a bad rap?

#157
post #155

Like every programming language out there, C++ is a tool. And like every tool out there it has its uses. There isn't any point of using C++ to count words in a text file. Any high-level language like Python will beat you to it. However, there's one thing you can do in C++ and not in Python or JavaScript or PHP: fully control the memory layout of your data. While you don't need it in most of the cases, it becomes a ki…

Just because there's a tool in a niche doesn't mean it's the best one. I could do all those things you listed in Rust with much less headache.

plus rust type system etc are just wow. And mostly if it compiles it works :)

Re: Does C++ still deserve a bad rap?

#158

Earlier quoted context omitted.

> There isn't any point of using C++ to count words in a text file. Any high-level language like Python will beat you to it. However, there's one thing you can do in C++ and not in Python or JavaScript or PHP: fully control the memory layout of your data. Any books or resources for digging deeper in these kinds of topics? I’m a Python developer and would like to learn C++ but the just the reasons you mentioned make i…

Python developer here just switched jobs to one that does C++. Let me warn you right now. It's not worth it. At all. Don't go down this path. Memory management is easy, but that's not the only crap you have to deal with. Templating and the whole C++ ecosystem with Cmake compiling to make is a giant headache. It takes about a week to integrate a new C++ library in source code and people are worried about installing or…

lol thats not a c++ problem. Cpp is different lang than python. If u don't have experience with c++ stop complaining about it. And regarding developer experience it doesn't matter if end consumer are going to get slow bloated app which need python runtime to be installed lol.

Re: Does C++ still deserve a bad rap?

#159
post #88

Earlier quoted context omitted.

it depends on what you're doing of course. It can even go the other way[1] Generally languages like C++ are obviously much faster, but a lot of primitive stuff in languages like python is also just C calls and may be optimised to the point of being faster, because doing things in low level compiled languages often comes with its own tricks and problems. [1] https://stackoverflow.com/questions/9371238/why-is-reading-l…

> but a lot of primitive stuff in languages like python is also just C calls and may be optimised to the point of being faster That assertion makes zero sense if we take into account that parallelization is one of the most basic performance techniques there is, and Python's GIL simply eliminates that option except for multi-process applications which then require serializing stuff back and forth. Python is pretty muc…

> That assertion makes zero sense if we take into account that parallelization is one of the most basic performance techniques there is

I would not support that stance. There are areas where parallelization is helpful, like numerical weather models, graphics, and scientific number crunching, but for by far the most cases, parallelization is anything but trivial and requires a pretty deep knowledge about things like the C++ memory models, what read-write barriers, locks, and fences are, and so on. Less than 1% of C++ programmers can really handle that. And apart from that this is an area where other languages like Rust, Clojure, Scala have a strong point, because whether it is done correctly is completely implicit in a C++ program while in Rust, many errors will have the result that your program does not compile. Debugging the same mistakes in C++ will make you pull your hair.

In fact, I'd urge anyone who wants to learn principles of safe concurrent computation in C++, to learn Rust, Clojure and Scala first, they are wonderful languages with strong, highly coherent concepts, and it will make you a much better C++ programmer even if you never use them again.

Of course it is not only possible but common practice to implement parallel computation in games and such in C++, but this is not the standard application of C++.

Re: Does C++ still deserve a bad rap?

#160
post #101

C++ fills a niche and probably if you use it all on your own you don't even see the problems. But if you use it at scale with multiple developers you can see it's layers of leaky abstraction laid down since the 80s that can never really be cleaned because too much is built on this foundation. This slightly over 100 page book on move semantics https://leanpub.com/cppmove shows some of the iceberg like complexities dot…

> C++ will eventually peak and die off but the timeframe is probably measured in decades and I'm sure there'll places where it holds on even then, like Fortran today. I certainly would't recommend it to a programmer starting out today, instead C or Rust would be better places to get an idea of system level programming.

Unlikely. The only candidates for replacement are Rust and D, none of these are anywhere near the adoption of C++.

What C++ can do is get better at being a language and then maybe give tools for developers to phase out outdated constructs or relics from C. It is not going away cause it's the best replacement for C humanity will ever get, at least for the next century.

Post reply on HN