The Power of The Functional or: I’ll bet you can’t do this in Java
arantaday.com
arantaday.com
I think it's a good thing: it reminds us that even in our corner of the woods, where reason is supposed to reign, we succumb to the most banal fashions. Hackers typically like to point out that "normal" people speak much nonsense and hold irrational views. In fact, the same is true for us. Well, except me, that is ;)
Well, I beg to differ. Right tool for the job is the way I think of these things. Java is the right tool for many jobs. Not for everything, but for many things. For our application (equity stat arb trading), java is certainly a good choice. Ease of network programming, serialization for free, lots of libraries available, good performance, excellent IDEs, good support for multithreaded programming; these are some of the attributes which make java attractive for us.
One example where it's not the right tool was where we wanted to be able to evaluate moments of well-defined statistical processes. There was a lot of symbolic processing, so we used Scala for that part.
Another example is scripting type stuff, we want to amalgamate lots of Java code and run stuff in an interactive environment. For this purpose, we chose jython.
Use the right tool for the job.
FWIW, Real World Haskell's a great, readable book. The first FP-language book[1] where I can really just lie down with it and read a chapter before going to sleep.
[1] with all due respect to PG's Ansi Common Lisp, RWH takes a more verbose and guiding style.
I mean, the first real programming I did was with logo. Why was it fun? Because the it resulted in pretty pictures and animations. When I started programming pascal, C, and assembler, it was 320x200x256 graphics that made it fun (that and TSRs).
Programs need to do something to be exciting. Sorting lists and building trees is certainly interesting, but doesn't inspire that "I need to figure out how they did that" feeling that every programmer my age will have felt when he/she first saw Doom or Wolfenstein, or in my case, Strike Commander.
As much as I like merb, I would like it _much_ better if it was in erlang or scala. lift, erlyweb, mochiweb, etc are still not at the ease of use level of the ruby frameworks. There will be a tipping point, I hope ;).
Agreed, strongly. Look at extlib ( http://code.google.com/p/ocaml-extlib/ ) and such, though. While OCaml's official standard library has some infuriating gaps, the unofficial standard library makes up for many of them (and the core language is quite good).
quicksort:
qsort [] = []
qsort (x:xs) = qsort (filter (<= x) xs) ++ [x] ++ qsort (filter (> x) xs)
fib sequence:
fiblist = 0 : 1 : (zipWith (+) fiblist (tail fiblist))
but don't worry, with the rate at which the java kitchen sink swallows more paradigms, this will likely compile in java8 or something
So the paradigm is easily replicated, but yes, the syntax is totally ugly though ;) I think the real difficulty is in explaining how say lots of Comparators and Function classes are better or worse than a first-class function. Java at least affords type-safety on the wrapped functions whereas Ruby and Python don't (though, they don't really have any Java-style type safety to begin with).
I'm not proficient enough in Haskell to write a public blog post on it though; and I figure Lisp was esoteric enough ;-)