News for hackers. Stuff that matters.
Re:Functional programming in C++ by goatlover on Monday September 26, 2016 @10:47AM (#12582252)
I don't understand. What's the point? If you really want to do function programming, use a language made for it, like Haskell or OCaml. Why the need to make one language do everything. Whatever happened to using the right tool?
Re:Functional programming in C++ by HelloNurse on Monday September 26, 2016 @11:38AM (#12582715)
This is a direct demonstration that C++ is the right tool. Most good modern programming languages have sufficiently convenient syntax (in C++, function types, templates and lambdas/closures) and sufficiently advanced libraries (like the set implementation the article relies on) to allow a functional programming style, which mostly means, like in the linked article, read-only data structures and higher order functions.

For an established C++ or Python programmer, being able to "make one language do everything" is great and functional programming style is "the right tool" for some specific needs. Preferring certain "pure" languages for the purpose of doing functional programming, regardless of the domain, can be an interesting experiment but is completely backwards from a practical engineering point of view.

Re:Functional programming in C++ by AnimalMuppet on Monday September 26, 2016 @12:02PM (#12582954)
> This is a direct demonstration that C++ is the right tool.

Well, it's a demonstration that C++ can be made into an adequate tool. The right tool? That might be a bit of an overstatement...

Re:Functional programming in C++ by blub on Monday September 26, 2016 @11:22AM (#12582566)
Multi-paradigm languages like C++ (or C#, Swift, etc) are the right tool because they allow you to use different solutions depending on the project you're working on.

As you can probably tell, languages that support one paradigm aren't particularly successful. This is painfully clear in the case of F#.

Re:Functional programming in C++ by enricosada on Monday September 26, 2016 @11:37AM (#12582708)
Just curious, what are the pain points of F#?
Re:Functional programming in C++ by gumby on Monday September 26, 2016 @11:59AM (#12582919)
Consider why you might want a functional approach in the first place: perhaps you have a large dataset to manage and want to use an approach that minimizes the amount of garbage you generate. Or maybe you have a major algorithm that is simply easier to express and maintain in a functional style.

But it's part of a larger project. That project could have other constraints that make C++ a better choice (or it could be an existing codebase).

Re:Functional programming in C++ by AnimalMuppet on Monday September 26, 2016 @08:26PM (#12586743)
The amount of garbage you generate isn't a big reason to use functional in C++...