Hello worlders vs. Factorialers
Wednesday, April 2nd, 2008
Image from WikipediaIt struck me today. There are basically just two kinds of programming languages and programmers in the world..
The first one can make output without even blinking but complex algorithms don’t smell to good to it..
The second one elegantly calculates complex sequences of useless numbers but you will need a degree if you want to print them out..
—
OK, there is a group of languages that bite the big chunk of elegance from the second with the careless (power) of first one.
To me a evolution towards more functional coding came by itself by just writing a lot of code and slowly progressing my imperative based coding style (before I even knew what FP is).
As a quick example of FP-ish solution vs. the Imperativ-ish. I was writing some AS3 code yesterday and I figured out that AS3 is less FP-ish than the very similar Haxe language that I am more used to.
Haxe..
function sayHi(name:String)
{
return "Hi" if (name != "") " " + name else "";
}
It hurt me but in AS3 I had to do it “yer olde” way
function sayHi(name:String)
{
var t = "Hi";
if (name != '') t += " " + name;
return t;
}
It’s not about lines of code. It’s about that in haxe I made simple “direct” expression. In AS3 I had to make some state, then modify it if certain case is true and then return it.
This solution is so ugly for this very simple problem that I am not sure if I didn’t miss some better way to do it imperatively too.

