Hacker News new | ask | show | jobs
by pjmlp 3669 days ago
I dabble occasionally in FP languages and I am a bit fan of the ML family.

However I came to the conclusion that the latest improvemetns in C#, Java and C++ are already quite good for doing FP style programming.

Yes, I feel a bit dirty not being able to use more pure FP languages, but I have to work within the context that customers allow us to do.

Although it feels like blasphemy, C++14/7 can be seen almost as an impure Haskell with curly brackets.

1 comments

Yes I agree. It's MUCH easier to do FP in modern OO languages than OOP in functional languages. So with the OO languages, you're simply in a better position to solve real problems.

Learning OCaml really improved my appreciation of C++. C++ code is just all over the place, but you can write it in a pretty clean style (admittedly with considerable effort.)

Related: https://akabe.github.io/evilml/

Have you ever learned Smalltalk?

Thanks to support for blocks (lambda), Smalltalk collections already had LINQ style programming, aka algorithm.h support, for example.

Nice link.

I actually haven't ever used SmallTalk, although I understand Ruby is considerably influenced by it (blocks, as far as I understand). Any pointers are appreciated though.

I'm more of a Python person, and Python doesn't really use blocks. I like the duality mentioned this post: http://journal.stuffwithstuff.com/2013/01/13/iteration-insid... (In summary it's for item in L: f(item) vs L.each(|item| ...)

I don't really think of C++ algorithm.h as LINQ ? I guess I don't use it that much. To me that is more "functional in the small", e.g. map or filter with lambdas, vs. "functional in the large". But I'd be interested to hear more details on this analogy.

There are lots of Smalltalk books here, including the original ones from Xerox PARC.

http://stephane.ducasse.free.fr/FreeBooks.html

The best free implementations to play around are Squeak and Pharo.

http://squeak.org/

http://squeak.org/

Or if you want to avoid installing anything, Amber gives some taste of it.

http://amber-lang.net/

Now, regarding the LINQ like stuff, in Smalltalk doing this type of stuff was already possible back in those days.

    |a|
    vec := #(1 2 3 4 5 6). 
    sumPairs := (vec select: [:x | (x \\ 2) = 0]) inject: 0 into: [:l :r | l + r].
Yes, that is what I was thinking of. The other part, immutable data and such, isn't that possible to practice in large teams. But I do make use of it in personal projects.