Comments on Haskell

From Slashdot:

The thing about functional languages, and strict lazy functional languages like Haskell, is that the underlying principles are quite different from procedural languages like C. In C, you tell the computer to do things. In Haskell, you tell the computer the relationships between things, and it figures out what to do all on its own.

Personally, I suck at Haskell — I’m too much of a procedural programmer. My mind’s stuck in the rails of doing thing procedurally. But I’d very much like to learn it more, *because* it will teach me different ways of thinking about problems. If I can think of an ethernet router as a mapping between an input and output stream of packets rather than as a sequence of discrete events that get processed sequentially, then it may well encourage me to solve the problem in a some better way.

Hascal, and other functional languages may be good for multi-core development. However not to many programmers program in them… Plus I find they do not scale well for larger application. Its good for true computing problem solving. But today most developopment is for larger application which doesn’t necessarly solve problems per-say but create a tool that people can use.

The truth is that the vast majority of the software out there does pretty dull, mostly procedural jobs. That’s why the main languages in use are just dull variations on the procedural, C/Java/Perl style. No matter how much maths geeks go on about functional programming, procedural systems will always be more suited and easier to use for most of the problems out there.

The point is that there’s nothing those languages can do that can’t be done, often more easily, with the current crop of popular languages. Elegance cannot beat convenience in the workplace, or in most at any rate.

Your real problem with Haskell is that it is more complex per written token, and so you have to think more per token. Most people seem to generate some inner fear for things they don’t understand as good as they expect. And that’s the base of all your motivation to find reasons why you dislike Haskell. Of course you could simplify it, and get something like Python. But this is a bad idea on the long run, because then nature will only create bigger idiots. It’s better to wise up a bit, because what you get then, is really really nice!

A pure functional language would be a language where there are no side effects. I.e., you can’t change the state of anything, you can only construct new things out of existing things. As this gives some problems with IO, Haskell, taking purity to the extreme, had to wait for the invention of Monads to be able to do IO. Yes, Haskell was not capable of IO (reading/writing) for years. Functional languages follow this pattern: side-effects are only permitted if there is no other way. Examples are Lisp and Scheme, but also Matlab, Mathematica and Scala. Other languages allow side-effects by default, and have functional aspects in other respects. Examples of these are Javascript, Ruby, Python, Java, C++, C and even assembler (programming without any functional aspects is going to be hard). Quite likely Javascript programming can be done almost purely functionally. But so can C.

Don’t be ridiculous. Functional vs procedural isn’t a matter of intelligence. It’s simply a way of thinking. And the reality is that procedural languages better match the way the human mind works.

IMHO, learning to program in a functional style is like a right-handed person learning to write with their left. Yeah, they can do it, but it requires a ton of work for dubious real-world benefit, and in the end, it’s never really natural, simply because that’s not the way the brain is wired (except for the odd freakish exception ;).


The Vulnerable Password Recovery Schemes

Dare Obasanjo has a eye opening post in his blog about how Sarah Palin’s email account is hacked. The hacker who hacked her account had, apparently, used common sense (and Google of course) to crack it.

This is a serious security issue:

The fundamental flaw of pretty much every password recovery feature I’ve found online is that what they consider “secret” information actually isn’t thanks to social networking, blogs and even Wikipedia. Yahoo! Mail password recovery relies on asking you your date of birth, zip code and country of residence as a proof of identity. Considering that this is the kind of information that is on the average Facebook profile or MySpace page, it seems ludicrous that this is all that stops someone from stealing your identity online.

Even the sites that try to be secure by asking more personal questions such as “the name of your childhood pet” or “where you met your spouse” fail because people often write about their childhood pets and tell stories about how they met on weddings sites all over the Web.

Either keep your mouth shut on the Internet or use better secret questions/answers. 🙂

Business vs Tech

There is an article on business vs tech in Slashdot and this comment made good sense:

The business guys want it fast, cheap, first.
Engineering want it correct, perfect, however long it takes.
There’s the struggle.
Any good business needs to strike a balance between the two. The tension is inevitable, and [should be] healthy.

Whatever happened to reddit?

I am not able to see more than 1000 of my saved links. Is this a new [mis]feature of reddit? I have opened a ticket for the same, but since it was on weekend, did not get any response. I really hope I still have all of my saved reddit links somewhere in the reddit database. If reddit is having space crunch, then atleast they should intimate us to download all our saved links and can later siphon off those links.

I really really hope I have my saved links. 😦

Update: I got a response from the reddit folks saying that it is because of a performance issue and should be dealt with asap.

Fetching Saved Links in

Been saving a lot of links in and wanted to start from the beginning. Having been lazy in reaching to the first saved link manually, I wrote a small perl script to output all the next links:

#!/usr/bin/perl -w

use LWP::UserAgent;

$ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20080702 Firefox/");

$begin_url = "";

$url = $begin_url . "/saved";
while (1) {
print "Fetching $url\n";

my $req = HTTP::Request->new(GET => $url);
$req->header(Accept => "text/xml,application/xml,application/xhtml+xml,text/html");
$req->header("Accept-Language" => "en-us,en;q=0.5");
$req->header("Accept-Charset" => "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
$req->header("Keep-Alive" => "300");
$req->header("Connection" => "keep-alive");
$req->header("Cookie" => "reddit_first=first; reddit_session=XXXXX");

my $res = $ua->request($req);

if ($res->is_success) {
if ($res->content =~ m/\/saved?\?count=[0-9]+\&(amp=&)*after=[a-z_0-9]+/g) {
$url = $begin_url . $&;
} else {
print "Match not found...\n";
} else {
print "Unable to fetch $url: $res->status_line, \n";

Been struggling for a while to get syntax highlighting for my code. Finally found a couple of links that get this going. But the sad thing is that perl is not supported. 😦