1. I Regret

    I regret. Before I learned to think and to act functional, I proclaimed X=X+1 for years. Have mercy!

  2. Why Functional: One Reason

    Why functional is better? So many reasons, one comes here: Programming languages are not made for computers, they are for humans to formulate generic solutions computers can solve faster in the details. The imperative style formulates the steps the computer has to follow, the functional style formulates the generic solution as such. Imperative style wants you to act like a machine, functional style allows you to think like a human.

  3. Scala - Functional Productivity

    Currently, in my job, I’m working on my first real life Scala application, a certain clustered database system. The storage engine, Neo4j, is written in Java and the server has to be build around that storage engine to accomplish a number of complex requirements.

    After switching from Java to Scala I was really excited of both the ease of integrating Java libraries and - the high productivity when writing Scala code. The first features I learned to love are type inference and closures. With type inference finally you are free to think about algorithms and not types without ever loosing type safety, your programms are still correct. I’m not sure if it isn’t my former fault, but with Scala the number of casts in my code reduces nearly to zero. On the other hand, I save so much time using closures! No function objects anymore, just a line of code enclosed in curly braces passed around. Sweet!

    Since I know Erlang very well and have a good experience both in functional and object oriented programming, switching to Scala was very easy to me. It’s just like having some of the candy of Erlang right inside of Java. Since I do not use the build in actor library but Akka, the runtime does not loose too much performance. Programming parallel code is much easier with the actor model compared to threads (it’s a common joke by Joe Armstrong to ask “What exactly does ‘thread safe’ mean?”). Another helpful feature here is immutability, of course. In Scala, the pure way has been soften by the “var”s but this again supports productivity - if used sparsely.

    There are a lot more features in Scala making life easier such as partial functions, pattern matching (not as rich as in Erlang or Haskell, but ok), case classes, traits or mixins, generics, laziness and last but not least strict object orientation - opposite to Java… And all this simply compiles down into pure JVM byte code!

    In summary, today we have to ask why we use Java at all to program the JVM. Well, if you have to fight for each single CPU cycle to produce the ultimate high performance code you may still benefit from Java. All the other times in your industrial life when you just plug this library into that and add some business rules there is no need for Java anymore. Scala is not the future, it is the present of today.

Powered by Tumblr; designed by Adam Lloyd and Ingo Schramm.