Thursday, September 13, 2007

The imperative vs functional decision in Scala

When programming in Scala, one needs to think about whether to use an imperative or functional approach (or some hybrid thereof) when writing most methods. Thinking about which approach to use so frequently could result in a significant waste of time.

One thing that makes OO development easier is the use of automated refactorings for evolving a class hierarchy. So getting things right at the start is not so important because you can easily change things later.

To address the imperative vs functional decision that one encounters in most Scala methods, one can similarly have automated refactorings for transforming code fragments from one paradigm to the other. In this way, you don't need to worry much about getting this decision right because it is easy to change it later.

Moreover, for those not so familiar with functional programming, such refactorings can provide guidance by helping them transform imperative code to functional code.

No comments: