Monday, June 7, 2010

Haskell Scripting: Log Analysis

The other day I wanted to analyze some of my website log files to get a better idea of how many active users I have. I've been meaning to do this for quite some time, but have kept putting it off. I decided to see what I could accomplish by just doing some experimenting in GHCI. It was so easy and convenient that I decided to do a screencast demonstrating what I did and how easy it was. The conciseness of Haskell combined with the instant feedback of an interpreter make a very powerful combination. Here's the screencast on vimeo.

8 comments:

Anonymous said...

This would be equally easy with a "popular OO language" like Ruby. Never tried Python, but I'm confident it would be the same.

(Compiled OO languages are another story obviously... C++, Java etc.)

But it's not the kind of thing I'd do in any interpreter, to be honest; I'll stick with Webalizer.

T_S_ said...

The utility of Data.Function, groupBy, nubBy were the takeaways for me. Thanks!. Maybe say a few words about them next time.

Mike Machenry said...

I agree with T_S_, I'd never seen groupBy and nubBy before. Anyway, nice video. Thanks.

-mike

Louis said...

Obviously this analysis is pretty easy to do it with any scripting language, but I think the point is haskell is able to easily do it too (and so to break some "prejug├ęs")

it fits well the title of the book: real world haskell

joe said...

I love this vid. Great intro to usable simple powerful haskell without all the type business and complexity. How does one take it to the next level without bringing in a lot of complexity: simple program to find most frequent users, most common users to generate error pages, etc.

Great vid! Thanx.

mightybyte said...

joe,

Glad you liked it. In my experience the best way to learn more is to just write more Haskell code. Learning more of the functionality provided by the standard libraries will be helpful. Data.List is the obvious place to start.

I would suggest just trying to solve whatever problems jump out at you. You can play around in ghci, but I think you'll quickly find that you want to load code from an external file so you can more easily define your own functions.

If you're having trouble with something and it just seems like there should be a better way, there probably is. When that happens try searching on Google or ask on the #haskell IRC channel. I've found the real-time nature of IRC and the extreme friendliness of the people in #haskell very helpful.

Anonymous said...

I really liked a lot your screencast.

I'm a total noob on it. But decided to get into it just to do something like that you showed us in the screencast.

It's great to see it in action. Thanks.

Where could I find some more screencasts like this?

mightybyte said...

Anonymous,

Thanks. It's always nice to hear that other people have found it useful. I don't really know of much else in the way of Haskell screencasts, so Google is pretty much the best place I can point you to.