Friday, June 19, 2009

Haskell: First Impressions

I first heard of Haskell while in college. I learned that it is a functional programming language, like Lisp. And that was the end of the story. Later, when I started working, I kept hearing a lot of praise of Lisp and even played a little with car and cdr and cons (Scheme in particular), but that was pretty much it, and a long time ago (Go here if you want to know how those names came to be). Recently (OK, yesterday) Haskell reappeared on my radar. Maybe because I discovered this online tutorial, and liked the look of it. I mean, cartoons!! So started reading. Haven't finished yet, but I already think it's quite good. Here's a program to compute the pairs of amicable numbers (OEIS: A063990).

answer = [(a,b) | a <- [1,2..], b <- [sum (proper_divisors a)], a < b && a == sum (proper_divisors b)] where proper_divisors n = [x | x <- [1..(n-1)], n `mod` x == 0]

The thing I find impressive is, it reads almost like the definition written on paper. And while I am sure I've coded it in the most inefficient way possible, it took only about 10 minutes and 168 characters to write. Think about it, by trimming a few unnecessary whitespaces, I can send it over SMS. Bwuhahah :p.*

Cutting the long story short, I am enjoying Haskell. I don't think I get the functional thingy yet, and I am not sure if I'll ever use it professionally. And while we are at it, I am also not sure how deep I will go. But one thing for sure, I am having fun, and that is pretty important.

Enjoy!!

[For the interested, there are quite a few good online resources for learning Haskell. In addition to the tutorial I mentioned above, there is The Haskell Tutorial, Haskell wikibook, and a series of posts by MarkCC whose writing I generally admire. Please let me know if you know anything else which is good].

Update:
Just discovered this. O'Reilly's Real world Haskell is available online. I don't know how good it is, but it was the Winner of Best Technical Book, Jolt Awards 2009, so it probably is.


* To whom might be a question ;-)

Wednesday, June 17, 2009

Oppie

In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite.
-Paul Dirac

That is a pretty famous quote. In fact, I think I've used it before. Ohh yes, in this post. But of course remarks are not made with the express intention of creating quotes. So today I provide some context. It comes from a letter Dirac wrote, and reads in full, "I understand that you are writing poetry as well as working at physics. I do not see how you can do both. In science . . ." And that letter was addressed to J.Robert Oppenheimer, the legendary director of Los Alamos during WWII, and a tragic figure by any count.

I read a biography of JRO (affectionately known as Oppie) by Abraham Pais recently. First a fact, the author passed away while in the process of completing the book, so this book reads more like a collection of essays than a coherent biography. And like any collection of essays, some are good and some I found boring. I had expected details of his Los Alamos days, but there is surprisingly little of that. The author felt there were other good books that covered those and decided to focus on other facets of JRO's life (I should probably get one of those books). Also there is not much about his personal life, but there is a lot of material on JRO's post Los Alamos political career. One important thing to note is that the author, himself a distinguished physicist, personally knew many of the players in the unfolding drama and there's a wealth of his personal observations and opinions. There are also sections about JRO's scientific contributions, and the important role he played as a mentor to younger generation of physicists. There are little interesting digressions too, like the history of the Institute, where the author was a professor and JRO became the third director. The biography is very extensively researched and draws heavily on original sources, so if you want to study these topics, this is the place to go. There is a lot of supplemental material about Oppenheimer trials by Robert Crease towards the end, but I did not read that. I felt the earlier parts gave a reasonable view of the man's life and work, and did not feel the inclination to find out exactly how the man fell.

The lesson to be drawn from JRO's life is about the great uncertainty of life. The man who became a legend in his own lifetime survived to see the dramatic fall of his public stature, to see former colleagues and friends turn into hostile enemies, or at least useless bystanders. Not that he did not make any mistakes, but the impression you get is he paid more than he deserved. As for the book, it was not everything I had wished for, but still, worth a try!

Thursday, June 11, 2009

Monday, June 8, 2009

First meet with the Monster

Everything should be made as simple as possible, but not simpler.
-Albert Einstein

Recently I finished reading Symmetry and the Monster by Mark Ronan. It was a chance find on my last Landmark trip, I happened to have read something about it on the net and picked it up. It is a history of Group theory, right from the time when E. Galois pioneered it in demonstrating the unsolvability of general quintic in Nineteenth century up to the present day. Galois, despite his genius (or was it because of it?), led a very tragic life and died in a duel at a very young age. The account of this tragic event presented in the book (which differs from Bell's) is very.. let me say senti. Significant theorems were later discovered by Langrange, Cauchy, Burnside and Feit-Thompson, including others.* [Please go and read the footnote in case you missed the last end-of-sentence marker. Thank You]. Simultaneously continued the discovery of all the finite simple groups (the atoms of symmetry), their classification (there are 18 countably infinite families), and discovery of exceptions that won't fit in any family (there are 26 of these). The Monster in the title is the largest of these exceptions, and exists in 196,884 dimensions. [Someone proposed the name 'Friendly Giant' for this beast, but it never caught on. Does it tell us something about human psyche? ;)]. It was a huge undertaking, spanning centuries and contributions came from many directions. The book captures the excitement of this endeavour well. Plus it explains how symmetry groups are related with leading edge physics like String theory (most of that stuff went over my head, but I can't blame it on Mark). There were other things that I did not understand as well, but I guess that can be a virtue for a book. If you think you understood everything too well, you might stop there. This book whets your appetite, and so at least a possibility exists that I'll look up some of these things elsewhere (not necessary that it will be realized though, at least going by my track record :). But that aside, if you want to meet the Monster, let this be your first step.

Enjoy!!

* I might give the impression that I understand this stuff. I want to assure you that I really don't. This is the first book I read about Group theory and it is a popular science book. But again, the following quote by the great John Von Neumann might be in order. "In mathematics, you don't understand things. You just get used to them."

Sunday, June 7, 2009

Why do people leave?

Well the title appears a bit misleading to me now that I have written it. That question might not have a satisfactory answer, and I don't feel qualified enough to tackle it, but what I actually have in mind is a very specific instance of that question, why do people leave blogging? I am not talking about people who did not quite get started, and their one or two posts stand there to pay testimony to this fact. I am talking about good bloggers (at least in my opinion), who had interesting things to share and readers to prove this, but consciously decided to quit at some point in time. The question popped in my mind while reading Stevey's latest post. His blog is very popular and I enjoy it, but he's about to leave. And let's not forget that it was his post, why you should write blogs that encouraged many, many to write their first post. And he's not alone. In my short life as a blogger, I've seen this happening more often than once. So what is it? Does it take too much energy, or you run out of things to share? Both of these reasons seem unlikely to me, but they might be true. Or is it that after a certain stage blogging starts turning into an obsession, interfering with the way we experience the world? (this was related to me by a friend, xkcd is as always helpful in making the point). Or is it that you lose interest, stop seeing the point, in a way? But if so, why? Or is their some other reason that I am too naive to see right now? I don't know. Myabe I will find out one day. But another question now pops into my mind, will the feel-like-leaving thingy ever happen to me?

Saturday, June 6, 2009

Rains

Rains are here, fellas! Now many of you just absolutely love rains, but I have a love-hate relationship with the season. I hate the chik-chik, I hate having to carry around a raincoat (one more thing to take care of), I hate having to be extra careful while driving; well, that's a long list; but again, can't say that anything beats sitting by the window on a stormy evening, a hot cup of tea in one hand (and bhujiyas nearby), and listening to nature's dance. Seasons are one of those few predictable things in life; you want it or not, remember it or not, when the time comes, they are there to say hello. But life keeps changing, you keep changing, and you end up with a store of memories, united by just a single theme, Rains.

The first memories of rains I have are from my school days. It was when the academic year used to start. I distinctly remember the fresh scent of new books. I was a story lover even then, and you could pretty much treat your language books like story books. That made it more special. This was accompnied by the usual activities like putting covers on new books, deciding how many pages a math notebook should be, and demanding a new compass box from papa. Even today, the cloudy sky invariably brings that scent back.

Then I moved to Kolhapur for Junior college. Spent two years there. The thing you won't forget if you've lived in the city is the constant pouring. It's happening all the time!!. To make matters worse the room had leaks, but the kindness of the landlord and his family more than made that up. I can say I've met few kinder people.

Then I moved to Pune. In rains, Mulashi was our favorite destination. Arranging bikes, fights over who drives with whom, the unending fun, and in the end, coffee at Relax, always! And five guys trying to fit inside one umbrella on their way to canteen!! (The sixth guy pretends to be enjoying the full fury of nature). And let me skip over all the fun of protecting journals, b'day bumps with muddy shoes and plans over which teacher deserves to be the first one to drown in VIT boat club :p (though I really don't want to).

Then came the first workex. I won't forget the first 3/4 months, constant rains, and I had to change two buses to get to the workplace. If you have any experience with PMT travel, you know the kind of pain what I am talking about :). But it was fun nonetheless, I think those first days always make an indelible impression.

And that brings us to this year. Who knows what it would be like? Maybe a year from now I will be writing about this time, maybe not. Becuase though seasons are predictable, life, for better or worse, is not. Happy Pawsala!!

Enjoy!!

Wednesday, June 3, 2009

Something about The Search

John Barrow is one of the best popular science writers we have. I was quick to pick his New Theories of Everything on my last trip to Landmark. I had expected a discussion of the current candidates for TOE, especially string theory. The book has that, but rather than focus on particular theories it takes a broader approach. It begins with the concept of 'Laws of nature', how the idea came to be, how we discovered some, and are they really there, or as some philosophers (especially Kant) would have us believe, are just constructions of the human mind. Then it ranges over Godel's incompleteness theorem and its possible implications for Physics, the relationship between Mathematics and Physics, the role of initial conditions and symmetry breaking (which is essentially random) in the birth of the universe, the emergence of complexity and a lot of other relevant stuff. It's more of a sketch of how a TOE might look like and whether it could be really present. And Barrow is remarkable not only in the breadth of the material but also in the lucidity of explanations. Let me give you an example. Conservation laws (notably the one for Energy) were discovered in Nineteenth Century. It's a standard scientific fact. What Barrow adds is it lead to a growth of Atheism among the scientists because earlier they all had believed that some divine control was required (at least periodically) to keep the world from going astray. What conservation laws showed was Nature has measures of her own. To take another example, at the beginning of the twentieth century it was discovered that the conservation laws can be expressed as invariances, like the conservation of angular momentum as invariance of the laws of nature to orientation in space. But it also lead to the deemphasis of the nature of time, with a revival of Parmenidan Philosophy from some two thousand years ago, because the focus shifted from studying change to studying invariances. Barrow has written entire books about some of the topics discussed here eg. Infinities (The infinite book) or fundamental constants of nature (Constants of Nature), so the discussions here may serve as useful summaries of those more detailed works.

If you want a readable view of the current search for TOE (with a lot of stuff about how that reflects upon other areas of enquiry, like philosophy or theology), you should read this book.

Enjoy!!