Live data from Hacker News

Does C++ still deserve a bad rap?

nibblestew.blogspot.com

21–30 of 310 posts

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

#21
I think you could argue every single programming language has a bad reputation under any context. Name a single programming language and someone will have something bad to say about it. I think C# is fantastic, and I bet someone, somewhere will thrash on it despite it being quite a powerful and rich language. Heck, I can pick on things about C# I don't like, but fortunately they seem to be aiming towards partially addressing those.

I think C++ is not inherently completely bad, the usual thing is "do it the right way" which is usually some spec the community has drafted up with arguments why certain styles or code decisions are bad and what their better alternatives are and why. In the face of Python we have PEP-8 for example.

C++ makes it easy to shoot yourself in the foot with a shotgun, and that means you need to think a little more about your approach and ensure you know what you're doing to begin with.

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

#24
post #4

Earlier quoted context omitted.

Why would that be more difficult in C++?

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.

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

#25

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…

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

Same as in Lisp, one of the most beloved of languages on HN.

Were Lisp's macros a mistake? Some will say yes, but overall the language is more praised for them than damned.

So highly regarded are Lisp macros that many languages will eagerly proclaim that they have macros too -- even if they're not homoiconic and so harder to work with than in Lisp. Few if any are the languages that proudly proclaim that they don't have macros because they thought Lisp macros were a big mistake.

C++ fans themselves often point out that C++ templates can be as powerful as Lisp macros.

So which is it? Is giving users the power to radically transform their language a bug or a feature?

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

#26
I'm not a fan of the syntax. I've never used C++ but it just looks arcane to me. Its hard to imagine enjoying programming with such a syntax heavy language.

Anyway, here is my bash version of the problem. Now that WSL is distributed with windows, does it also hit the "runs on all major platforms with no dependencies" mark? For the record, this hits the enjoyment mark 100%.

cat $(find . -name "*.txt" | xargs) | tr ' ' '\n' | sort | uniq -c | sort -k1 -n -r | grep -E '^\d+ [[:alpha:]]+$' | head -n 10

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

#27

Right at the beginning, > This calls for regular expressions Why? A regular expression is a whole new program, written in a whole new programming language (one used to program finite state machines, instead of Turing ones, but still). Why not just write a simple function to compare string suffix? Is you programming language (C++, in this case) so anaemic that you need a whole different language to do such basic opera…

That immediately jumped out at me. They don't need a regular expression here, it's probably an inappropriate fit, or else it's revealing an undisclosed design assumption.

It certainly ensures that I don't take their conclusion to be worth much.

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

#28
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...

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…

C# and Python...

  "a, b".Split(", ")  // C#
  "a, b".split(", ")  # Python

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

#29
So first, C++ in a small codebase with a small team, is a very powerful language that really does produce the best code. That's what you want in a professional, top tier code base and that's what you get.

Unfortunately, once a project grows to many developers, many of whom have varying levels of experience, it's just too easy to write bad C++ that becomes impossible to debug. I've been using it for a decade and I swear I barely scratch the surface of its features.

Lastly, and this one is the most annoying, C++ also has cryptic error messages that almost always never mean what they suggest. You'll learn to understand them over time and decode their meanings, but at first glance you'll spend long days hunting for the wrong issue.

Post reply on HN