Live data from Hacker News

Convincing C programmers to switch to C++: A look at human behavior (2016)

blog.kareldonk.com

31–40 of 87 posts

Re: Convincing C programmers to switch to C++: A look at human behavior (2016)

#33
At a cultural level, when you have to convince somebody of something, isnt that generally a bad approach if you want somebody to change their view?

Though, Keeping thIngs Simply Stupid, is really the only lesson one has to know/learn. When C++ has a specific function go with C++, when C is sufficient use C. If a bash script is sufficient use that.

If people could just show why something is cool in what situation, instead of why something should be used over something else. And this includes guides 'how to switch desktop OS' too.

Re: Convincing C programmers to switch to C++: A look at human behavior (2016)

#34
How to convince them:

- Show them how classes makes things easier (automatic object management, some operator overloading, etc)

- Show how the STL makes most things easier (arrays, maps, etc)

How not to convince them:

- Show uses of excessive/pathological inheritance

- Use of templating beyond the basics

- Insist they use C++ functions for every single thing

- Insist they OOify every interface in their code

- Creating giant classes (structs) with a getter and setter for every field with no control or validation

- Going crazy with operator overloading

Re: Convincing C programmers to switch to C++: A look at human behavior (2016)

#35

I like to think of C# as what C++ should have been.

No, a garbage collector is a non-starter for a lot of what C and C++ get used for.

C# is more what Java should have been (which lines up pretty well with the history of C#).

Re: Convincing C programmers to switch to C++: A look at human behavior (2016)

#36

In a lengthy piece about rational arguments, you would expect somewhere in there someone would actually present a rational argument for switching beyond "it's modern." I mean, maybe the actual details of the case for switching are slightly beyond the scope the author intended to write about, but simply starting with an assertion that "modern = better, therefore people should have already switched if they were rationa…

It's kind of amazing to me that OP's 4000-word article doesn't mention -- even once -- the relative complexity of C vs C++.

Be careful comparing complexity. C might look simple, and C++ might look complex but I have never seen a char* in C++ to mean 2d of jpg images in memory.

C++ is more complex, because it covers more concepts. But when you get simple safe and to reusable things from that complex the difficulty is reduced.

What is the right way to store and unknown amount of things in C?

There are about a million ways to do and every project will implement their and about half will work. Of that half maybe 1 in 10 will have an API that is intuitive to the reader, and depending on the reader that 1 in 10 will be different. Now what if what you an associative container instead?

With C++ just using std::vector, because this is a solved. (or map/unordered map for the associative container).

This continues on with libraries. Every API needs to have a large series of questions answered every time you pass a pointer. Because C has no concept of ownership who is supposed to delete it? Without const references extra caution to distinguish const pointers and pointers to const things, why is this important? Without templates writing an API that works on multiple types involves dealing with void* at run time, presuming you don't want to actually use anything in the data.

C looks simpler because it is smaller. C++ is easier and simpler because it has already dealt with many of the hard problems.

Re: Convincing C programmers to switch to C++: A look at human behavior (2016)

#39
post #7

A good example of human behavior in TFA as well as the talk it cites is how deeply convinced they are that C++ is objectively always better than C; they don't even try to suggest that there could be a tradeoff and sometimes C would be better. Of course the guy in the talk makes a living from C++ consulting; another part of human behavior is it's hard to convince someone of a truth which threatens their paycheck. And…

> And I'm not here to argue how terrible C++ is (I've done enough of that elsewhere)

Haha that's one way to put it :p

For those new to this debate: Yosef Kreinin is the author of the (in)famous C++ Frequently Questioned Answers.[0] it's quite a body of work. Speaking of which: thanks for writing it, Yosef. I greatly enjoyed reading it back in the day, and it had a big impact on young me.

[0] http://yosefk.com/c++fqa/

Re: Convincing C programmers to switch to C++: A look at human behavior (2016)

#40
post #7

A good example of human behavior in TFA as well as the talk it cites is how deeply convinced they are that C++ is objectively always better than C; they don't even try to suggest that there could be a tradeoff and sometimes C would be better. Of course the guy in the talk makes a living from C++ consulting; another part of human behavior is it's hard to convince someone of a truth which threatens their paycheck. And…

Yeah, I see this trend in "behavioral science" arguments in other areas of debate.

It's especially funny to watch people on both sides of whatever issue argue that the side they're opposed to is in a self-reinforcing bubble that only closes them to the beliefs of their team, which are obviously correct. But, the thought process that produces the belief that their team is correct is incubated in exactly the same sort of bubble that they're complaining about.

Post reply on HN