aspose file tools*
The moose likes Blog around the Campfire and the fly likes blogged about how i started thinking in functional programming Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Blog around the Campfire
Bookmark "blogged about how i started thinking in functional programming" Watch "blogged about how i started thinking in functional programming" New topic
Author

blogged about how i started thinking in functional programming

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30938
    
158

I wrote up how I started thinking in functional programming rather than just writing Java code in Groovy.

How did you grasp the switch?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1848
    
  16

Nice post. Next stop, monads!


No more Blub for me, thank you, Vicar.
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 1043
    
  13

That makes my head hurt. I don't know if I'll ever get functional programming. I've tried and failed several times.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
Kevin, SICP -which I recommended here- is an excellent introduction to FP, IMO, if you want to give it another try.


Ping & DNS - my free Android networking tools app
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 1043
    
  13

Thanks for the recommendation. I already have the instructors version of that book on my Wish List.

I've already tried "The Little MLer" and the "The Little Schemer" (not much help), and the site "Learn you a Haskell for Great Good", and tried the Coursera course. All very frustrating. Interesting, but frustrating.
Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 688
    
  11
hi Jeanne,

thanks for the clear blog. It caused me some mixed feelings, though...

Having just received my Scala certification of the Scala course in May and June,
I was certainly impressed by the power of functional programming, and I found it
a pleasure to use.

However, what gives me this mixed feeling, is that the first method
in your blog was very, very comprehensible. I just needed one look to
know what you were doing.

Then, looking at the last method in your block, indeed, powerfull, but I can imagine
someone looking at it needs at least two readings to understand what's going on.
(I'm not talking about all those FP experts around, of course).

Still thinking about this aspect...

Greetz,
Piet
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

I feel the same as Piet. Furthermore, every other snippet of functional programming code/language I have seen, makes me "search for real content" between all those parenthesis, brackets and other such symbols and it straightaway turns my brain off. Maybe it's just a matter of indentation and perhaps getting used to it, but like Piet notes, I have usually found it hard to comprehend functional code. I do admit though that I haven't really put in efforts to learn the languages and get used to it, since I still haven't found a reason (other than everyone seems to want to use it these days) to use functional languages.


[My Blog] [JavaRanch Journal]
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1848
    
  16

Jaikiran Pai wrote:... since I still haven't found a reason (other than everyone seems to want to use it these days) to use functional languages.

I'm working on a "skunkworks" project investigating Big Data technology, and we're looking at Apache Spark, which seems to be getting a lot of traction as an alternative/complementary technology to Hadoop and MapReduce. Spark is written in Scala and has strong support for Python, as well as a slightly less comprehensive Java API. It's written by some very clever people who have taken advantage of lots of very clever functional programming magic to make Spark perform well on massive volumes of data. I'm only writing my first, very simple programs with Spark right now, but I'm using Scala and trying to think functionally in order to make most effective use of the platform. And it's good fun to have an opportunity to try this FP stuff out for real.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30938
    
158

Piet Souris wrote:However, what gives me this mixed feeling, is that the first method
in your blog was very, very comprehensible. I just needed one look to
know what you were doing.


I think that comprehensible feeling is from comfort with the language. This is essentially Java:


Piet Souris wrote:
Then, looking at the last method in your block, indeed, powerfull, but I can imagine
someone looking at it needs at least two readings to understand what's going on.
(I'm not talking about all those FP experts around, of course).


This is the after. It took me two readings at the beginning. But the Java version wouldn't have been immediately obvious to me 15 years ago either.


One reason I like the functional version is there is less to remember at once. grep is UNIX for search (Java 8 doesn't call it that though). So I know that I'm filtering the items for disabled. Then I can forget that and go on to the rest which is getting the names. In a longer chain of actions, this impact becomes more noticeable. I can replace three levels of nested loops with a functional programming chain.
 
Don't get me started about those stupid light bulbs.
 
subject: blogged about how i started thinking in functional programming