News for hackers. Stuff that matters.
Re:Convincing C programmers to switch to C++: A look at huma... by bumbledraven on Friday June 02, 2017 @11:18AM (#14470505)
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]

Re:Convincing C programmers to switch to C++: A look at huma... by simias on Friday June 02, 2017 @11:36AM (#14470659)
I'm not a big fan of the huge complexity of C++ (and much prefer C in general, although for some things C++ is more convenient) but I don't really think it's fair to dismiss a language based on a small snippet. You can basically mock any language that way:

- In C "getchar" returns... an int.

- Pointers and array are kinda the same thing, but not exactly. The rules for when an array decays into a pointer are sometimes unintuitive and surprising.

- Same thing for the implicit integer types promotions.

- `char *s = "foo"` is not at all the same thing as `char s[] = "foo"`. Arguably the former should be considered erroneous, but compiles just fine in C. G++ gives a warning for the same code however.

- There's also the ridiculous "gets" function that's so poorly designed it could be part of PHP. This one finally got officially deprecated though.

Of course many of these issues are also part of C++ since it's mostly a superset of C but in general it's stricter and more strongly typed.

Re:Convincing C programmers to switch to C++: A look at huma... by vostok on Friday June 02, 2017 @11:39AM (#14470685)
Intuitively, you can think of this as providing the name of a variable as compared to an lvalue that doesn't name a variable.
Re:Convincing C programmers to switch to C++: A look at huma... by stinos on Friday June 02, 2017 @11:27AM (#14470581)
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 huma... by sqeaky on Friday June 02, 2017 @12:30PM (#14471169)
Your link doesn't work for me. Can you perhaps just explain the difference? A twitter link is hardly a canonical source.
Re:Convincing C programmers to switch to C++: A look at huma... by Sean1708 on Friday June 02, 2017 @01:00PM (#14471453)
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 huma... by machuidel on Friday June 02, 2017 @12:30PM (#14471157)
Oh oh. Young me will get into trouble again: https://bytes.com/topic/c/answers/214712-using-return-parant...
Re:Convincing C programmers to switch to C++: A look at huma... by _pmf_ on Friday June 02, 2017 @11:20AM (#14470523)
There's shooting yourself in the foot, and there's C++.