• 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

Why Scala?

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 2 questions about the book.

1. From the sample chapter, it's a book about FP. Scala is just a vehicle. Why do you choose Scala, a multi-paradigm language? Isn't it better to use some pure FP languages like Closure, Haskell?

2. Which paradigm do you usually use in your daily work? OO, FP or combined? and the reason?

Thanks.
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

qunfeng wang wrote:I have 2 questions about the book.

1. From the sample chapter, it's a book about FP. Scala is just a vehicle. Why do you choose Scala, a multi-paradigm language? Isn't it better to use some pure FP languages like Closure, Haskell?

2. Which paradigm do you usually use in your daily work? OO, FP or combined? and the reason?

Thanks.



Scala is not just pure FP, but rather a mix of OOP and FP and that makes sense as it plays very nicely with the plethora of existing Java libraries, given the fact that it compiles to the JVM. All the benefits of Java is available to you at hand which is not the case with Clojure or Haskell. If you are writing Scala code, try writing it in a functional style.
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Harry wrote:All the benefits of Java is available to you at hand which is not the case with Clojure or Haskell.


Actually Clojure is a JVM language as well so I think there is pretty thorough interoperabiity in both directions with Java, although it looks a bit strange because you really are shifting paradigms between OOP and FP with Clojure, unlike Scala which is also an OO language and still looks a lot like Java.
 
author
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even though Scala is a multiparadigm language, it works well for purely functional programming, and writing the book with Scala would lets us reach a different, wider audience than if we wrote the book using a language like Haskell. Scala has a nice adoption story precisely because it is multiparadigm, interoperates with Java, and does not impose any particular programming style - people can start out using Scala as if it were Java with different syntax, and gradually incorporate more FP into their work. Runar and I also really felt like there was an unfilled niche, in that there were various books about Scala, but not really any books that deeply explored using Scala as a purely functional language, which was how we were using it.

Personally, I use Scala as a purely functional language in my day to day work. We usually refer to functional programming in contrast to imperative programming, not in contrast to OOP. People mean lots of different things by OO, but to the extent that it is well-defined, I think it relates more to how one organizes code, rather than whether side effects are used.
 
Ranch Hand
Posts: 56
Scala Mac OS X Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Chiusano wrote:
We usually refer to functional programming in contrast to imperative programming, not in contrast to OOP. People mean lots of different things by OO, but to the extent that it is well-defined, I think it relates more to how one organizes code, rather than whether side effects are used.



I would say that abstraction (primarily through encapsulation) is one of the main features of OOP, which couples very well with abstractions available in FP (higher order functions and function composition). It can become an effective pair.

Scala gives you lot of freedom in how you organize your code. This is a nice feature because you can experiment. But it also blurs the ways to better combine both natures of the language.
I believe it will get even better when time and experience will provide us the insights necessary to pick out the most profitable combinations.

Ivano
 
reply
    Bookmark Topic Watch Topic
  • New Topic