9,428 karma · joined Jul 10, 2015 (11y ago) · 3,276 submissions
2221.
Nissan creates self driving chairs for people who can't stand queuing(designboom.com ↗)
1 points · by hellofunk · 10y ago · discuss
comment 10y ago · link · parent
2223.
Unsafe Air-Pollution Levels Affect 9 in 10 People Globally(time.com ↗)
5 points · by hellofunk · 10y ago · discuss
comment 10y ago · link · parent
Are you sure about that? The standard does not guarantee which order transform will actually run and apply the function, but that is a different matter than the order of the final result. I'm pretty sure the standard guarantees that. If you have side effects and require application order guarantees, for_each is the one to use.
edit: this SO answer from a Google engineer suggests I am correct: http://stackoverflow.com/questions/34167638/stdtransform-ord...
comment 10y ago · link · parent
https://github.com/BartoszMilewski/Okasaki
https://github.com/fons/functional-cpp
There is a lot of interest in making this happen in C++, which is awesome.
comment 10y ago · link · parent
https://github.com/kennytm/utils/blob/master/traits.hpp#L47-...
Wow that scares the heck out of me to do that!
comment 10y ago · link · parent
1) C++ already provides a transform and accumulate (just for starters) which are much like map and fold. Isn't it better to learn to use the built-in tools rather than rely on a library? There is quite a lot of functional-style stuff in the standard already.
2) The cost of these abstractions is not clear. You can do a lot of functional idioms in C++, but often a tremendous amount of copying is happening compared to an imperative solution, because C++ lacks functional data structures under the hood.
3) Points 1) and 2) above are largely addressed by proposals for C++20 specification, such as the Range library.
comment 10y ago · link · parent
The downsides? Well, I find some of its syntax choices a bit odd and inconsistent; I think the pursuit of elegance could have gone much further. And, while I celebrate its pervasive use of closures/lambdas and functional idioms in my many contexts, it lacks true functional data structures that would be necessary to really write in a proper functional style with confidence that the runtime wouldn't suffer.
Also, the implementation of its high-level features is somewhat magical and hidden. You can't depend on performance when using them until you really study them. So much so, that WWDC had a big talk about how to choose language features depending on the type of performance you need, and none of it was intuitive.
Additionally, at least on the Apple platforms, its Objective-C heritage can be a bit annoying. In particular, you can't mix and match closures with "selectors", which is a real shame and missed opportunity for flexibility and elegance.
comment 10y ago · link · parent
That's what I do and it's great. I don't use move semantics or think about them, I avoid heavy templates, and I focus a lot of my work on the functional tools in C++ now and the more elegant ways of doing stuff at a high level. For when I need those extra optimizations, no need to change languages, I'm already there.
comment 10y ago · link · parent
C++ is a changing language and is doing a good job keeping up the with times, adding high-level features while increasing performance at the same time.
comment 10y ago · link · parent
Then there are genuine trolls who, despite massive reputation, seem to have the sole goal of proving everyone wrong. It's also weird.
This image has never rung more true to me then when interacting with so many "power" users: http://i.imgur.com/Oy6mA.jpg?fb
comment 10y ago · link · parent
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.
2246.
How Big Would Your Social Security Check Be If You Wait Until Age 70?(host.madison.com ↗)
1 points · by hellofunk · 10y ago · discuss
comment 10y ago · link · parent
> 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.