31 comments

[ 4.9 ms ] story [ 75.4 ms ] thread
The first time I encountered FP was in an undergraduate PL class. I remember how easy it was to use, how beautiful the language was, and how many cool things could be done with it that were utterly foreign to Java at the time. I remember the thought: "Functional languages are so cool. It's too bad that you can't use them for anything serious." I guess this was a case of the cage door being swung open and the monkey staying inside.
I predict that in 2 to 3 years, there will be several accessible web frameworks in erlang, scala, and maybe even haskell. Yes, there are frameworks for them now, but they are not "accessible" to the masses yet. This will change and good programmers will have all the readability they need for quick web dev as well as the power and safety of more advanced language features.

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 ;).

F#, don't forget. It has the backing of a major industry player and access to all of the .NET libraries and tools already.
Plus it's based on ML, which, while possessing a few wrinkles and warts, is a very pragmatic language.
Don't forget OCaml, for that matter.
Agreed; in fact I've that's the only ML I've tried! What I don't like about it is the standard library; compared to Haskell's it feels so obtuse. Actually I think Haskell's standard library is pretty friggin' awesome. Everything is where it should be, functionality is well documented, the names are succinct but clear. It's a joy to use.
> [the standard library is] so obtuse

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).

I totally agree. We learned Miranda, which is similar to Haskell. Had we learned Haskell and the lecturer had pointed us to its FFI (which is a real joy to use, similar in ease-of-use to the lisp FFIs -- much easier than the java JNI [although JNA goes a long way towards alleviating JNI pain]), things probably would have been very different.

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.

haskell:

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

Well, Java has Comparator classes. You can simply have first class functions by making a generic-d class (generic types for input and output), and a single member like "public T apply(F arg)". Its not that out of the ordinary.

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).

Except that this isn't really quicksort, because it's not in-place. Let's see you write the real one; I bet you it will be uglier than the equivalent java code.
You're right - Haskell does lazy evaluation far better than Lisp/Scheme do. I've been making my way through real world haskell, and I'm constantly amazed.

I'm not proficient enough in Haskell to write a public blog post on it though; and I figure Lisp was esoteric enough ;-)

(comment deleted)
I don't get it, all of these things are simple to do in Java. Ugly, yes, but still simple.
In case you haven't noticed, for the last several years there has been a totally irrational and even juvenile trashing of java in favour of fine languages such as haskell, erlang, ruby, python, etc.

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 ;)

I've been a Java developer for years and I don't think its trashing is irrational. Once you have seen alternative ways of doing things, going back to Java is simply painful.
i think the same argument goes for other imperative/OO languages... its a pain going back to C++ once youve done python (or ruby or haskell or lisp)... even worse when you have no choice but to use it at work:(
Actually going back to C++ even seemed painful when I still was a Java developer.
[Nitpick: it's "its", not "it's", because you're not abbreviating "it 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.

I agree. As a longtime Java developer myself, it is horrible. But it's horrible on its own merits; there's no reason to make things up about what it can and can't do in order to trash it.
(comment deleted)
Even if you have to do look at scraps of it in your cupped hands while The Master yells at you for not working, functional programming is a wonderful little Eden of direct expression and general well-thought-outedness.

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.

It would be, if Amazon would ever ship it to me! Is it generally available in the US? I may just order from there and eat the cost of shipping.
I preordered. The blog talks about it being available in various stores already, but I'm out in the middle of nowhere.
Yeah, me too, they keep apologizing for the delay.
Similarly, there are many tasks you can do far better in Java.
Although clojure makes up for that.
Which ones?
I know it's popular to hate Java at this point, but there are really a ton of things that it does well... solid scalable reliable backend servers would be one.