“Thinking in Scala" if I have a Java/C++ background?

I'm familiar with developing server-side applications in Java, but now I'd like to start using Scala. Can you describe the paradigm shift that is necessary? Here are a few questions that might help you frame an answer:

  • How do I architect and design web applications differently? What is the biggest difference?
  • What should I stop doing/using; What should I start doing/using instead?
  • Are there any client-side considerations/restrictions?
  • I'm not looking for a detailed comparison between Java and Scala.


    The key difference between Scala and Java is Scala's use of functional programming.

  • For web applications, you will use different frameworks. Play is currently the most popular flavour. It feels similar to MVC work in other frameworks but leans more towards functional purity (though most Play apps are far from being pure)
  • You should stop thinking in terms of mutating fields in memory and think about data flows of immutable values. Do not use a var , when you can do it with a val . Loops will mostly be replaced with higher order constructs like map and fold . Avoid nulls, and use Option s instead.
  • Assuming a web client side, no. Unless you want to compile Scala to JS. Then the same stuff applies.
  • Learning wise, I would start with Twitter Scala school, then once you grok that, I recommend the book Functional Programming in Scala. I think these two resources will guide you in the FP direction, as opposed to writing Java-style programs with new syntax. Then, find the right spot in the OOP/FP scale that suits the problem at hand.

    链接地址: http://www.djcxy.com/p/538.html

    上一篇: 我如何在git中找到origin / master的位置,以及如何更改它?

    下一篇: “如何在Scala中思考”如果我有Java / C ++背景?