Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Functional Languages  RSS feed

 
Pankaj Shet
Ranch Hand
Posts: 320
Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kishori,

As the Programming world is moving on the functional paradigm,
There are many functional languages like Haskell, Scala, Groovy, Clojure, etc ... which are completely functional.
With the invention of Lambda expressions, Java 8 is slowly moving to the functional paradigm... I guess ..
Is Java 8 going to be completely functional?
So how is Functional paradigm advantageous over Object Oriented world?
Also I am the great fan of Apress books too... Apress Books are the plain simple language books and are easy to understand.. I am using JPA2 book from Apress for JPA2 Certification study and its very easy to understand..

So I need this set of books to understand the above..

Regards,
-Pankaj.







 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Java will probably never be a functional language. It has however become obvious that it was falling behind the times and functional features were one of the enhancements needed to bring it up to date.
 
Junilu Lacar
Sheriff
Posts: 11146
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I'll bite...

Pankaj Shet wrote:As the Programming world is moving on the functional paradigm

While functional programming (FP) is certainly gaining popularity, I haven't seen programmers abandoning the imperative style in droves. Even the ones I've seen who have written Scala programs still seem to be stuck in the procedural programming world, the one that they should have left behind when they moved to object-oriented programming. FP is not for everyone and it takes a major mind shift (and mind bend) to transition to it successfully.

There are many functional languages like Haskell, Scala, Groovy, Clojure, etc ... which are completely functional.

A word of caution: don't ever use "completely functional", "Haskell", and "Scala" and/or "Groovy" in the same sentence if you're around FP purists if you like your head enough to keep it -- you could very well get your head bitten off for such heresy.

Scala and Groovy are far from being "completely functional" since they support OO programming constructs. You can use classes from the standard Java libraries as well as third-party Java libraries, so OO is still very much a part of these languages. I'm not familiar with Clojure so I will leave it up to someone who is to comment about it's being "completely functional".

With the invention of Lambda expressions, Java 8 is slowly moving to the functional paradigm... I guess .. ... Is Java 8 going to be completely functional?

I don't know if "invention" is the right word. Lambda calculus has been around for a while. With the introduction of lambda expressions in Java 8, we are now able to take advantage of their elegance and conciseness. Of course, as with any tool, you have to learn how to use them properly so that you don't end up harming yourself or others instead.

While the introduction of features that allow for functional style programming is certainly an important shift in the language, I see it more as an evolutionary step that's necessary to keep the Java language relevant in the growing field of competitors such as Scala, Ruby, and even JavaScript. There are also certain kinds of problems for which FP is more suited (see next part of reply) but I don't see OO being supplanted by FP in the near or far future. These two paradigms can coexist very happily and in languages like Scala and Groovy (and now, Java 8), they do.

So how is Functional paradigm advantageous over Object Oriented world?

That's like asking "How is a hammer advantageous over a saw?"

It's not so much a matter of being advantageous than it is of suitability to a problem. You wouldn't use a hammer to cut a piece of wood nor would you use a saw to pound a nail into a piece of wood, would you? OO is suitable for solving certain problems in a certain way, FP is suitable for solving other kinds of problems in a certain way. And of course there are all sorts of problems that can be solved one way or another and that doesn't even limit it to just OO and FP - you could solve the same problems with something like C or COBOL or FORTRAN or RPG or whatever other language you can think of. For me, it's really a matter of the thought process involved in approaching a problem and organizing a solution. For some people, shifting to a functional mindset and approach can be very difficult. I found Scala and the propensity to use tail recursive functions to solve problems somewhat mind-boggling at first but after a while, you start to see the elegance of the solutions you can produce.
 
Pankaj Shet
Ranch Hand
Posts: 320
Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Junilu,


A word of caution: don't ever use "completely functional", "Haskell", and "Scala" and/or "Groovy" in the same sentence if you're around FP purists if you like your head enough to keep it -- you could very well get your head bitten off for such heresy.


So Can we say Object Functional?



It's not so much a matter of being advantageous than it is of suitability to a problem


In what situations Java8 is suitable compared to other languages?

Hi Kishori,

Since I am already experienced into Java, I would like to stay in JAVA and Know about Java 8. So I am very much interested in moving onto Java 8 as a beginner of it.

Hence I would surely like to be a winner of these books.

"A friend in need is a friend indeed" :P

Regards,
-Pankaj.
 
Paul Clapham
Sheriff
Posts: 22498
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pankaj Shet wrote:

A word of caution: don't ever use "completely functional", "Haskell", and "Scala" and/or "Groovy" in the same sentence if you're around FP purists if you like your head enough to keep it -- you could very well get your head bitten off for such heresy.


So Can we say Object Functional?


You can say what you like; but why do you feel the need to have a short and precise characterization of languages?
 
Pankaj Shet
Ranch Hand
Posts: 320
Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

You can say what you like; but why do you feel the need to have a short and precise characterization of languages?


C is a procedural language, C++, Smalltalk, Java is Object Oriented language, So each language has its own categorization into different programming paradigms according to their styles..

So, other languages which are mentioned above has different style of programming, So I feel they should have a seperate category or paradigm according to their style.

Regards,
-Pankaj



 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The basic idea behind functional programming languages is to treat functions as though they are some incarnation of a mathematical function. All the principles that apply to a mathematical function applies to functional programming as well. A mathematical function such as sin(x) would produce the same result for the same set of arguments every time you invoke it. If you apply that idea to programming, you have a function that purely depends only on its input parameters and does not depend on any state surrounding the function. The result of the function does not produce any side effects.

Speaking with respect to Scala, it is a mix of both OO and Functional paradigm. One of the best practices in OO programming argues that avoiding mutable state results in better performance effectively achieved through parallelization. OO world mimics the real entities while the Functional world goes one step further and adds immutability.
 
Pankaj Shet
Ranch Hand
Posts: 320
Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So What's your say about Java 8 Joe? how would you compare Java 8 and Scala ?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pankaj Shet wrote:So What's your say about Java 8 Joe? how would you compare Java 8 and Scala ?


The lambdas in Java 8 are just a language feature. You could write an entire project in Java 8 in a functional style using lambdas everywhere, but with difficulties. It does not feel natural. May be Java 9 or 10 would change that. Scala on the other hand is already ready for that. You could oscillate between both the extreme (fully imperative OO style or fully functional style) and the language supports you with its rich flexibility. Writing functional code in Scala feels pretty natural to the language. On the other hand, having so much flexibility also at times leads to a tough to comprehend code when you are working in a team of developers with varied Scala experience.

For me the take away is, whatever language that I use, I will not mutate and I will write easy to comprehend code.
 
Pankaj Shet
Ranch Hand
Posts: 320
Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joe for your Informative Reply ...
 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pankaj Shet wrote: . . .
C is a procedural language, C++, Smalltalk, Java is Object Oriented language, So each language has its own categorization into different programming paradigms according to their styles..
. . .
But those categorisations are not strict and immutable. It is possible to write functional programs in C, for example. Maybe not easy, however.
 
Rico Felix
Ranch Hand
Posts: 411
5
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:But those categorisations are not strict and immutable. It is possible to write functional programs in C, for example. Maybe not easy, however.

I second this view... One should take note that a programming language should not be categorized as being procedural, functional or whatever simply because programming languages are just abstractions to the underlying instruction set of the machine... Instead you must come to a realization that what the programming language is really doing is providing direct support for the concept...

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!