• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Usage of Functional Programming

 
Ranch Hand
Posts: 171
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Venkat,

When to use Functional Programming? What are the advantages/benefits of the same over other languages in such scenarios ?
 
Author
Posts: 135
10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Divya,

There are some key reasons.

1. Declarative instead of imperative. We focus on what to do and let libraries figure out the details. This makes the code more expressive.

2. Favoring immutability. The more mutability (especially shared mutability) we have, the more bugs tend to creep in. We can reduce bugs by favoring immutability.

3. State transformation instead of state mutation. This leads to more of a function composition and state transformation. The code becomes more expressive and it tends to resemble more
closely to the problem statement.

4. Efficiency through lazy evaluation. Because we are passing higher order functions, we can postpone evaluation of certain parts to just in time of need. This can leads to greater efficiency in code.

The collective benefit is more expressive, more concise, less error prone, easier to understand (once we get a hang of the style), and easier to maintain code.

Also, when we combine composition, immutability, and laziness with things like parallel streams, we can create highly efficient code with much less effort and chances of error.

Hope this gives you a very high level view of the reasons.

Thanks

Venkat
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many of these features make FP especially useful for large-scale and concurrent distributed processing, which is one of the reasons why some of the key tools for Big Data are based on these principles e.g. Hadoop MapReduce engine, Apache Spark (written in Scala), etc. Back in 2013, Dean Wampler (now with Scala company Typesafe) gave a persuasive talk on why Copious Data Is The Killer App For Functional Programming, and so far he seems to have been on the right track with that claim.
 
Divya Shiv
Ranch Hand
Posts: 171
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Venkat.
 
Divya Shiv
Ranch Hand
Posts: 171
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Chris.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic