Live data from Hacker News

Does C++ still deserve a bad rap?

nibblestew.blogspot.com

31–40 of 310 posts

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

#32
post #5

I don't think C++ ever really had a bad rap except among ideologues and evangelists of other languages. In my experience, people like this are very rare in the real world outside of maybe Rust conferences.

Your experience is highly incongruent with mine. I work with a lot of Rustaceans, and while they're often able to articulate why they prefer Rust over C++ for many applications, many of them would probably be reaching for C++ if not for Rust, and certainly don't spend time hating on the language. Speaking personally as a Rust fanatic, C++ is still my 3rd favorite language. (Out of a large N.)

I guess my point is, this is a weird (and IMO, flat-out wrong) dig at the Rust community.

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

#33
If this is the best that can be said for it, then yes.

60 lines of "portable code" turns out not to be portable.

Practically every line requires some piece of C++ ceremony.

The nightmares around the potential for "undefined behavior" and miscompilations of code by C++ are ignored.

It has always been the case that there are several subsets of C++ which make reasonable languages. The problem is that when you combine them in the wrong way, you get into a world of hurt. And in the real world, C++ programmers do not agree on which subset to use.

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

#35

Earlier quoted context omitted.

Is there any language where string handling doesn't suck? (No script languages please, because they cheat by implementing the hard things on C or C++) From memory the less horrible experience i had was with Go, but there's help for the slices on the runtime which let the difficult parts hidden and also the batteries-included std library, which is one of the most well designed standard libraries out there. Buffer mana…

I think it's pretty nice in Scala. I don't know if "no virtual machines" was implied as part of the "no script languages" request, though. scala> "Mary had a little lamb. The lamb was in federal witness protection.".split("lamb") res0: Array[String] = Array("Mary had a little ", ". The ", " was in federal witness protection.")

No, its ok and not part of that category.

I meant for languages where the hard parts are delegated to another like Python and Javascript (C and C++ respectively).

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

#37

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…

> 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 it hard to leave Python.

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

#38
post #2

I say this with a lot of love for C++, and I think it has gotten much better, but just try splitting a string via another string as the delimiter...

Why would that be more difficult in C++?

It is not difficult to do it, but it is difficult to do right and in a C++ way. That means with least overhead, i.e. not copying stuff if not necessary and not doing any memory allocations. This is why C++ still has no string split is its standard libary: People cannot agree how it should look like.

There is, however, boost::split from the famous boost library.

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

#39
post #7

Depends: does it still have header files?

for people that dont like headers, how do you browse the api of a class? Scrolling through the implementation?

i look at a nice HTML documentation page generated from the code. happily, no one has to maintain that by hand :)

i like how haskell does it: https://hackage.haskell.org/package/base-4.14.0.0/docs/Data-...

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

#40

C++ is a very poorly designed language. A lot of the work being done by the committees is fixing Stroustrup's mistakes. Consider horrors such as this. In the following statement what are foo and bar? int x = foo(2) + bar(3); Most people will say foo and bar are functions and that's a reasonable guess. Unless you are talking about C++. In C++ foo and bar could be functions but could also lots of other things. For exam…

If you mark the constructor as explicit, the automatic cast you mention does not take place and you'll get a compile time error.

The casting style can be enforced via linting. There are also C++ cast operators, that in my opinion should be preferred to the C style casts: static_cast, dynamic_cast, reinterpret_cast, const_cast, static_pointer, dynamic_pointer_cast, const_pointer_cast... and you can enforce that those are preferred rather than C style casts.

Post reply on HN