• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Scala in Depth: functional programming vs OO

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
Aaaaaand ... we're on the march. Stylin. Get with it tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic