• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

blogged about how i started thinking in functional programming

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
378
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote up how I started thinking in functional programming rather than just writing Java code in Groovy.

How did you grasp the switch?
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice post. Next stop, monads!
 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes my head hurt. I don't know if I'll ever get functional programming. I've tried and failed several times.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kevin, SICP -which I recommended here- is an excellent introduction to FP, IMO, if you want to give it another try.
 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 1366
29
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34973
378
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic