File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Scala and the fly likes Scala in Depth: functional programming vs OO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Scala
Bookmark "Scala in Depth: functional programming vs OO" Watch "Scala in Depth: functional programming vs OO" New topic
Author

Scala in Depth: functional programming vs OO

Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 433
Hi Author,

I took the coursera course Functional Programming Principles in Scala by professor Martin Odersky. It's a great learning experience. In the course, professor Martin Odersky mainly focused on functional programming. I'm wondering which paradigm to choose in the real world programming with Scala.

Thanks,
Qunfeng


To be or not to be. It's a question.
Josh Suereth
Author
Greenhorn

Joined: Jan 24, 2013
Posts: 15
qunfeng wang wrote:Hi Author,

I took the coursera course Functional Programming Principles in Scala by professor Martin Odersky. It's a great learning experience. In the course, professor Martin Odersky mainly focused on functional programming. I'm wondering which paradigm to choose in the real world programming with Scala.

Thanks,
Qunfeng



You should choose the paradigm that works for the problem you're solving. A lot of teaching/training we do in Scala is *forced* to be functional style, because we assume students are unfamiliar/uncomfortable with functional-style and the only way to really learn is to force them to immerse themselves.

You will notice that Scala has more powerful OO features than Java (traits, self types, early initializers, etc.) and also pulls in much of the functional concepts. It is a blend, and therefore in *practice* most of my code is blended as well. In my current project, I find myself using 3 paradigms:

Akka/Actors for the backend server, OO for exposing interfaces and Services, Functional Programming style inside Play for munging data around and sending it to the client.

When it comes down to it, each paradigm has different strengths, and is suited to different tasks. If you use the right paradigm in the right spot, it will serve you well.

For example, one frustration I have with a lot of FP languages is the lack of namespacing and "module systems". Scala actually provides a pretty nifty way to namespace functional code -> Objects. You can even extend full-on packages if you use nested objects/classes in traits. Some of the most advanced FP users in Scala are doing wonders with its OO system for packaging their software: Bake Me A Cake - Precog.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scala in Depth: functional programming vs OO