A recent conversation at OSSCAMP with the backdrop of a presentation on Scala by a very interesting chap really made me think about the functional programming aspects of python . It is obvious python has a huge stack of tools for scientific programming but this has just increased appetite for more .
Little background about Scala. It is “Scala (pronounced /ˈskɑːlə, ˈskeɪlə/) is a multi-paradigm programming language designed to integrate features of object-oriented programming and functional programming. The name Scala stands for “scalable language“, signifying that it is designed to grow with the demands of its users.” –wikipedia
Even if you are not excited by the idea of functional programming which you might be after a few lines. Scala is a dynamically typed language written on top of JVM. This means you can use some very reliable well written Java libraries in its web framework — lift . Also you can potentially write applications for android. Although their is a project to get scripting languages to android, this could be an interesting option. Also since Scala is compiled, it should run faster than other scripting languages. (Either I am starting to like scala or I have had too much cheese.)
But more importantly talking about the functional programming . It is a paradigm which is closer to mathematical expression. Take for example How would you define second order derivative in an object oriented language .Well till the idea of f(x) , functions in programming languages correlate well to their mathematical cousins. You send variables and get results. But what if you wish to do f square (x) . You call the function recursively and have a control structure to see how it is called . The control structure is an additional aspect we have added to the program not really related to the actual expression. Now see this little program and see how elegantly can solve some problems .
def sigma(term, a, next, b)
return term(a) + sigma(term, next(a), next, b)def term(x): return 1.0/(x * (x+2))
def term(x): return 1.0/(x * (x+2))
def next(x): return x + 4
sigma(term, 1, next, 1000)
This little code solves the following problem :
1/1*3 +1/5*7 …..
Read More »
