News for hackers. Stuff that matters.
Re:Talking to C Programmers about C++ [video] by blub on Sunday September 25, 2016 @07:21AM (#12574850)
What are the components of C++ that add up to 100%?

I can count:

* language basics (variables, structural statements, functions, error handling, preprocessor, how compilation works)

* OOP

* functional programming (which is not that complicated at all in C++)

* generic programming

* advanced generic programming and metaprogramming

* the C standard library

* the C++ standard library basics (containers, algorithms, smart pointers, cout << "foo")

* more advanced c++ standard library (maths stuff, threading(?), chrono, advanced streams (not needed))

I think most C++ programmers have a reasonable command of all of these except the metaprogramming and advanced standard library.

Re:Talking to C Programmers about C++ [video] by hellofunk on Sunday September 25, 2016 @09:23AM (#12575201)
> functional programming (which is not that complicated at all in C++)

> I think most C++ programmers have a reasonable command of all of these

These gave me a bit of a chuckle. It's true only if you've never done proper functional programming using a genuinely functional language.

It's true that you can now pass lambdas around as first-class values easily, store and manipulate them as you might in a functional language, and that's a fantastic convenience.

But that's not what functional programming is. None of the idioms you'd use in Clojure or Haskell are wise to use (yet) in C++ (although Niebler's Range library will make a big step in the right direction... in C++20, where it's currently slated for specification).

If you try to do real functional programming in C++, you'll end up with a very inefficient program that pales to writing an algorithm with a more procedural or OO idiom.

And, in my experience interacting with lots of C++ developers, most do not know what actual functional programming is all about.

Re:Talking to C Programmers about C++ [video] by blub on Sunday September 25, 2016 @10:07AM (#12575365)
A discussion about "proper functional programming" is not particularly relevant, because the topic is functional programming in the context of C++.

The constructs that C++ offers for FP are not complicated.

Re:Talking to C Programmers about C++ [video] by hellofunk on Sunday September 25, 2016 @10:15AM (#12575402)
Sorry, but this is just simply not true. If you've never done functional programming before, then I could see why you think doing it in C++ is not complicated. Here is an example of just how large the can of worms gets when attempting to bring functional programming to C++:

https://bartoszmilewski.com/2013/11/13/functional-data-struc...

and:

https://bartoszmilewski.com/2013/11/25/functional-data-struc...

And, I disagree that you can change the definition of a particular programming paradigm when discussing a particular language. Functional programming means something that is not really possible in C++. For starters, the fundamental underlying data structures for functional programming do not exist in C++ and there is no third-party implementation of them worth mentioning; the above experiment is admitted by the author to fall flat when doing anything idiomatic.

As I mentioned before, C++20 might turn the tide on this front a little bit, thanks to the Range library.

Re:Talking to C Programmers about C++ [video] by blub on Monday September 26, 2016 @05:14AM (#12580376)
Fine, what shall we call this programming style in C++ (lambdas, immutability, function composition, etc) so that everyone is happy then?

Functional style C++?

I haven't felt the need to go deeper than that, it's very possible that I've missed many interesting things, but it's not clear that I can use those things and see tangible benefits in my projects today.

Re:Talking to C Programmers about C++ [video] by AlexandrB on Sunday September 25, 2016 @09:39AM (#12575258)
> * OOP

C++ OOP is an endless tire fire. I now have 7 years experience writing C++ "OOP" on the job and I still run into surprises when I try to do things that are easy in other languages but unnecessarily hard in C++. Plenty of examples in the C++ FQA[1].

[1] http://yosefk.com/c++fqa/inheritance-mother.html#fqa-23.5

Re:Talking to C Programmers about C++ [video] by blub on Monday September 26, 2016 @06:20AM (#12580621)
I'm not an expert at this, but it seems to me that it would be a good idea to take the time to learn it properly in one go instead of independently discovering all the mistakes that can be made in 7 long years and then being upset about it.
Re:Talking to C Programmers about C++ [video] by satysin on Sunday September 25, 2016 @07:27AM (#12574866)
You just proved my point ;)
Re:Talking to C Programmers about C++ [video] by blub on Sunday September 25, 2016 @09:15AM (#12575165)
Doubtful. What would 25% of the above list be, basics + OOP? No standard library at all? No templated code?

I am saying one can barely write programs by knowing just 25% of C++, let alone for almost two decades.

On the contrary, I think 80%+ of the language is accessible to every programmer.

Re:Talking to C Programmers about C++ [video] by AlexandrB on Sunday September 25, 2016 @10:04AM (#12575350)
> On the contrary, I think 80%+ of the language is accessible to every programmer.

80% of the language looks accessible to every programmer. Until you hit some corner of C++ behaviour and you realize your mental model of what C++ is doing is woefully incomplete. C++ is stuffed full of syntax, and obscure interactions between that syntax will continually trip you up. Each of the things in your list is somewhat contained on its own but interacts in surprising ways with every other thing on that list.

For example[1], want to create a template friend function for a template class? Prepare for function definitions like:

    Foo<T> f<>();
Edit: that's not to mention various C++ idioms like CRTP [2] which don't fit neatly with the stuff you listed but are non-obvious and occur in a lot of complex C++ code.

[1] http://yosefk.com/c++fqa/templates.html#fqa-35.16

[2] https://en.wikipedia.org/wiki/Curiously_recurring_template_p...