Live data from Hacker News

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

blog.kareldonk.com

11–20 of 87 posts

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

#11
post #3

People aren't rational actors for a reason: Sometimes things are easy to argue for but aren't that great in practice. And so by following your heart instead of your head, you sometimes make seemingly illogical but objectively better decisions. And I think that there is a case to be made about how C++ is efficient in theory, while C is effective in practice.

> And so by following your heart instead of your head, you sometimes make seemingly illogical but objectively better decisions.

And sometimes you make seemingly illogical decisions that end up being objectively worse decisions. The problem is that we don't really have a way to quantify our emotions usefully, which means we can use them accurately and are forced to allow for enormous amounts of error in our calculations when we provide any level of significance to them. That's why they are often seen as detrimental to rational decisions, not because they don't matter (obviously emotions do), but because including them sometimes leaves us no better off than flipping a coin (are the downsides really that bad, or is your fear of change in this instance vastly overwhelming the other considerations, and in an unwarranted way that you aren't entirely aware of?).

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

#12

In C++, "return (x);" isn't equivalent to "return x;" [0]. But according to OP, it's not C++ that's irrational, it's the programmers who don't want to use C++. [0] https://twitter.com/sigfpe/status/857748171778252800 [EDIT: corrected broken link]

Or one could say it's irrational to write return (x); :] More typing, less readable, more confusing.

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

#13

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

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

#16

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…

[deleted]

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

#17

If we were discussing two languages Strawberry and Kiwi, and I had a large, established codebase in Strawberry and a bunch of programmers who are experts in Strawberry, it would be a hard sell to get me to switch to Kiwi even if Kiwi were better than Strawberry in every conceivable way and backwards compatible with it to boot: - Learning to use a new system effectively takes time and energy. Are you 100% sure that th…

One of the major problems I have with C++ is that for any non-primitive data type, there are way too many choices of mutually incompatible classes that people have developed. Even strings. There are things out there that use char[], std::string, CString, APString (#*&!), ...

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

#18
> The C++ language is an improved version of the older C language (it’s a superset of C),

The first statement is arguable and the parenthetical statement is false. C99/C11 have language features that C++ hasn't adopted, which makes it somewhat obnoxious to support C++ from C codebases that use them. One example is the "static" keyword used in array parameters.

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

#19
“If you’re arguing, you’re losing.”. That is a quick way to stop any discussion. The reason I am not using C++ is because C already does everything I need:

- Easier to write code generators for: I use libclang to read in annotations that will generate new code according to where the annotations are being used. If I have to take care of every edge case and new features added to the latest C++ standard it would make the code generator more complex.

- Using plain old data structures: My code generator generates new code to be able to work with the plain old data structures which data can be interleaved or non-interleaved using data-oriented design. Classes will not add that much value.

- C compilers are easier to write: I integrated the tiny C compiler inside my program to be able to compile C code on demand. The C code can then use the code I've already written.

- No name mangling by default: I dynamically load a lot of plugins and do not want to bother with binary incompatibilities all the time (if compiled by different compilers like the tiny C compiler for ex.).

- I mostly use libraries written in C

- Low-level access

If I need concepts or meta-programming etc. I can already use Nim or write my own code generator, else I would rather choose something different than C++.

To be more on-topic. Confirmation bias. On The Internet you can find confirmation of something being true about almost every topic. Whatever people believe is the truth, it will not change the reality. Which programming languages are better is a very difficult thing to measure because there are many factors to consider. Being used to a certain programming language can be a good reason not to change.

https://en.wikipedia.org/wiki/Confirmation_bias

Update: added some explanations, and more on-topic

Post reply on HN