Live data from Hacker News

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

blog.kareldonk.com

61–70 of 87 posts

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

#61
post #43
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 a good example in the comments here is how few people are talking about what the article is actually about (human behaviour) but instead there's mostly anti-C++ reactions. The aversion to C++ is so strong that an article that only casually is about C++ must be attacked for the perceived C++ advocacy. The article isn't really about C++ advocacy at all. It really doesn't matter if C++ is better or not. The article…

To be honest the article's kind of bullshit regardless of what angle you view it from. Some of my favourite parts are:

> the fundamental energy that underlies and is responsible for the universe is consciousness. So consciousness is inherently logical.

> Since humans are a part of the universe ... humans are also logical or rational by nature.

> We’re born with the need for sexual satisfaction, yet society teaches us ... to suppress and even repress our sexuality. This is one of the most important seeds for irrational thinking that gets planted into our minds.

There's enough pseudo-scientific bullshit on the rest of this person's site that I'm very wary of drawing any conclusions from this article.

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

#62
Talk about the cat calling the kettle black. C++ arrogance and hypocrisy at its finest: Wondering why C programmers can't be reasoned while being impervious to any reasonable argument themselves towards the many modern alternatives to C++.

Why on earth should a C developer chose C++, when they could chose Go, Rust, Swift and Nim instead? And if you really insist on an old language I'd rather use Objective-C than C++.

Only reason to ever pick C++ is that you got a sizable existing legacy C++ codebase. That is why I am stuck on C++.

A C developer by definition doesn't have legacy C++ code to deal with so there is no reason to pick C++.

Saying C has no benefits over C++ is rather ignorant. Complexity has a real cost. For most of my C++ career that has been reflected in an utter lack of functional tools for manipulating C++ code, e.g. doing refactoring. Refactoring C code is a lot easier, as a regexp search and replace is far more dependable, since there is no function overloading.

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

#63
post #55

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]

Your link doesn't work for me. Can you perhaps just explain the difference? A twitter link is hardly a canonical source.

There are some trailing characters in the link. But the tweet is

> decltype(auto) f1(){int x = 0; return x;}

> decltype(auto) f2(){int x = 0; return (x);}

> Latter, not former, returns reference to int.

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

#64

Scott Meyers points out that one of the simplest possible refactorings is "rename method". To rename f(), you need to know what f() is, and in C++, f() can be any of 7+ different things! [0] It's extremely complicated to determine which thing it is. But according to TFA, people who prefer C are just being emotional and irrational. [0] Scott Meyers. Things that Matter - DConf2017 [@27:51] ( https://youtu.be/RT46MpK39r…

In some obscure technical sense you might be correct, that identifying some piece of code is hard, but that little of C++ obscurantism is rarely why code isn't easy to read.

With C++ it easier to express higher level concepts. I can have a map of strings to some class instance. Then I can use some string to lookup class instances. There are simple idiomatic ways to do this. They are short to writes (With C it is common to have an array of pointer to pointer to void pointers. To get associative lookup it might be even worse and have functions that need to pointer to pointers, with who knows what ownership model and what idioms in use.

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

#65
post #36

Earlier quoted context omitted.

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 p…

LOL, C++ developers complain about C developers being impervious to reason, yet can't admit one of the most blindly obvious problems with C++. Plenty of language manage to be more expressive than C++ while being far less complex. C++ is an uncritical grab bag of features. If you don't carefully design features to complement each other you can C++ style complexity.

C simplicity is real. It makes it easy to write compilers. Compare with the enormous complexity of writing a C++ compiler. This is actually quite important as any software development needs tools. Writing tools for simple languages is easier. Writing tools for C++ is next to impossible. Most of my C++ career I have never had proper refactoring tools. I haven't even been able to use a lot of C++ features because it has taken so many years for all compiler writers to implement all the features.

I can't think of a single other language where it has been so many years of lag between a language specification and it being widely adopted among major compilers.

The simplicity of C makes it easy to interface C with a huge number of other languages. C++ can't interface with almost anything. It is just way too complex.

A much saner superset of C, is Objective-C which can actually interface very easily with other languages.

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

#66

Why do programmers feel the need to convince other programmers to switch to a different language? How does it affect Programmer A, a C++ programmer, whether or not programmer B prefers to use C? I like both C and C++. I also like Objective-C, Ruby, and Python. Each one has its place--and if I'm starting a new project, I'll use the one that makes the most sense to use given the project's requirements--or a mix of them…

Because:

I don't want to maintain a giant heap of buggy C Code.

I don't want to deal with bugs in the JVM/JNI.

I want ownership semantics expressed in code. When a C functions accepts or return a pointer who deletes it?

I want code to be easily tested, automatically. Common C code has so much shared mutable state that unit tests are rare, and when used are trumpeted as masterworks of engineering like the sqllite test suite.

C makes all these things hard or impossible to work with. From my perspective, the only positive it brings in the standardized ABI.

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

#67

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 - Creatin…

Why would that convince them of C++ and not any other modern language like D, Rust, Swift, Go or Nim?

I really can't see what C++ has to offer anybody. It is a horribly complex language, which doesn't interface with anything except C.

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

#68
post #43
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 a good example in the comments here is how few people are talking about what the article is actually about (human behaviour) but instead there's mostly anti-C++ reactions. The aversion to C++ is so strong that an article that only casually is about C++ must be attacked for the perceived C++ advocacy. The article isn't really about C++ advocacy at all. It really doesn't matter if C++ is better or not. The article…

The article is a 4,000 word diatribe about how stubborn, irrational people refuse to see reason, without at any point admitting the possibility that these backward, incorrigible C holdouts could be right in any way.

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

#69
post #20
post #6

But in the table I see, pair-compared, C is faster than C++. Am I interpreting this wrong?

Yeah — it's a little confusing, but the multiples are how much slower they are than the fastest. Bigger is worse.

It becomes less confusing when realizing each line is a multiple of the fastest run time.

If the fastest one took 100s, then the one taking x1.57 took 157s.

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

#70
post #36

Earlier quoted context omitted.

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 p…

LOL, C++ developers complain about C developers being impervious to reason, yet can't admit one of the most blindly obvious problems with C++. Plenty of language manage to be more expressive than C++ while being far less complex. C++ is an uncritical grab bag of features. If you don't carefully design features to complement each other you can C++ style complexity. C simplicity is real. It makes it easy to write compi…

You are lumping me in with some strawman who insulted you, then you insult me calling me "impervious to reason". You are not interested in a real exchange of ideas.

I will respond to your points in the spirit of open exchange anyway, but if you continue to be rude it will just shine a poor light on C programmers as a whole. Since I feel you ideas are lacking factually this might seem like an attack, it is not an attack and I even ask for more information on points with merit.

I have pointed out that elsewhere in this thread that the standardized C ABI is perhaps the only thing I like about it. C++ can seamlessly use this, but not by default (which is a weakness of C++). So anything C inter-operates with C++ can too. So your point that C++ inter-operates with less is entirely without merit. Using this I have interoperated with Lua and Ruby from C++, it works well.

To push interop further there are several tools like SWIG that seek to allow exchange of rich objects between languages (rich objects that C doesn't even have), and these tools work. I have written code that throws exceptions from Java an catches them in C++ (and vice versa of course) and things of similar complexity in a few other languages.

It feels fantastic to have low or 0 cost abstraction around passing complex objects between systems and have all the code that does that strongly checked at compile time (And covered in Unit tests too that but that could be done in C too, I just don't see it often).

As for tooling, I again think your points are largely without merit. The are plenty of tools for both languages and there are plenty of simpler languages with less tools. It seems to me that the amount of tooling is not related to complexity but rather popularity of the language.

A language that is functionally driven by one vendor and supplanted by that vendor with a newer language (swift) is not a reasonable solution to most problems. I am curious about we makes it interop better than interop with C++, what does it do right that C++ does wrong?

Post reply on HN