

The Power of The Functional or: I’ll bet you can’t do this in Java - smanek
http://arantaday.com/blog/the-power-of-the-functional/

======
calambrac
I don't get it, all of these things are simple to do in Java. Ugly, yes, but
still simple.

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

~~~
Tichy
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.

~~~
flashgordon
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:(

~~~
Tichy
Actually going back to C++ even seemed painful when I still was a Java
developer.

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

~~~
gaius
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.

~~~
lallysingh
I preordered. The blog talks about it being available in various stores
already, but I'm out in the middle of nowhere.

~~~
gaius
Yeah, me too, they keep apologizing for the delay.

------
axod
Similarly, there are many tasks you can do far better in Java.

~~~
Tichy
Which ones?

~~~
axod
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.

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

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

~~~
gaius
F#, don't forget. It has the backing of a major industry player and access to
all of the .NET libraries and tools already.

~~~
seertaak
Plus it's based on ML, which, while possessing a few wrinkles and warts, is a
very pragmatic language.

~~~
silentbicycle
Don't forget OCaml, for that matter.

~~~
seertaak
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.

~~~
silentbicycle
> [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).

------
drwh0
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

~~~
seertaak
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.

