Monday, September 26, 2011

Book Reviews: The Sweet Shop owner, The Help, and Brief Interview with Hideous men

The sweet-shop owner
(Graham Swift)
The Sweet Shop owner

This is a good book. Though the author has not gone out of his way to make it easy to read. It is the story of a special kind of love, a love which is arranged, but still as rock solid as any other kind of love one is likely to find. Where the implicit rules forbid one from making explicit mention of "love". Where effort is made to keep everything static, unchanging and if love was to be brought into the picture, it would result in too much change. My favorite line from the novel is:
 He wrote "5050 helmets" which, of course, meant "I love you."
While reading the book, I often felt as if I was reading another novel by Virginia Woolf. The style of narration is multiple streams of consciousness. However, in case of Virginia Woolf, one still gets long stretches of thoughts of one person before switching to another. However, Swift jumps gleefully from one person's thoughts to another and even through time at occasional places. It is disorienting, but since there is little to surprise in the book, it does not hamper the reading much.

Overall, a decent read.


The Help
(Kathryn Stockett)

Brief Interviews with hideous men
(David Foster Wallace)


The Help

This book has been made into a movie, which I have not seen. After reading the book, I can see why.

The narration of the story is good. In my personal opinion, as good as Gone with the wind. However, I am not very much into storytelling anyway. There were some pages which just had to be turned in the same session, and there were some places of dullness which were apt places to stop reading and take a break. A comfortable read.

The most entertaining part of the book for me were the various references to the events of that time and of future events sprinkled throughout the book, like assassination of JFK and a joking reference to when they land a man on the moon.

Overall, an enjoyable read.



Brief Interviews with Hideous Men

I could not finish reading this book. This book too has had a movie made on it, but I found the writing of the book to be too repetitive to be engaging. Perhaps actual conversations go that way, but I could not take the deluge of drab repetitions which the men made. More over, one does not know what is the question they are answering and though at times I could infer the questions and at some times, it adds to the reading, but I found it too tiring.

I usually do not leave books unread, taking it one page at a time, hoping that the next one would be better, but I did not find it to be worth it for this particular book.

Sorry.

Sunday, September 11, 2011

What Perl got right and R got wrong

R tries to do the right thing by having very short names for functions one uses often:

c()
Creating vectors.
t()
Transpose a matrix.
q()
Quitting R
is()
Generic isInstanceOf
by()
apply after grouping
as()
Generic type cast
Common primitive functions in R

As much as I like not having to type extra characters to get to these functions, I have always had to be extra cautious when it comes to naming my variables out of fear of accidentally overwriting any of these. Interestingly, R selectively ignores such overrides letting the primitives prevail if possible:

> R.version.string
[1] "R version 2.12.1 (2010-12-16)"

> c <- function(...) { 42 }   # Accidentally overriding c()
> c(45, 67, 78)               # Expected behavior
[1] 42

> c <- "42"                   # Now it should be a scalar, right?
> c
[1] "42"

> c(45, 67, 78)               # Magical return from the dead!
[1] 45 67 78

This overriding of an identifier as both variable and primitive function is grossly inconsistent, specially since functions are first class objects, same as any vector or string. If I override an identifier, even a primitive, I expect it to be really overridden.

Though the intention of cutting keystrokes is clearly good here, this inconsistency feels avoidable.

On the other hand
In contrast, this highlights how well Perl does the same thing. Larry Wall, the creator of Perl, was a linguist by education and one of his tenets while creating Perl was making it as succinct as possible. To this end, it ventured to those corners of the keyboard which only APL had gone beyond. Also, on an unrelated note, he was the winner of the International Obfuscated C contest twice and some say that after Perl became mainstream, there wasn't much point left in obfuscation contests.

Perl also short-cuts most commonly used functions and type qualifiers:

my
Variable definitions
@a
Array variable prefix
%a
Hash variable prefix
$a
Scalar variable prefix
s//
Substitute function
m//
Match function
Common primitive functions in Perl

However, in Perl, the domain of the abbreviations looks completely different from identifiers; it is impossible to even imagine confusing them. In R, the use of identifiers and built-in primitives seems uniform, and is actually inconsistent.

And we have a winner ...

I think between R and Perl, Perl is the one which got it completely right.

The design principle to be learned here perhaps is that of having different keystrokes for different folks. The onus of preserving the (abbreviated) primitive functions should lie with the language, and it can be done:

  • the right way by syntactical obviousness as Perl does it,
  • the good ol' way by reserving keywords as Python does it or,
  • the wrong way by allowing overrides and resuscitating primitives as R does it.



Wednesday, August 31, 2011

R: Going faster than vectorization

Introduction

Update: The by function of R can be used for the same task since data for me is stored in the same data.frame. I have tested that out later on in the post.


Recently I had to run though a large data.frame in R, selecting values from a given column based on an equality constraint on another column, in this format:

for(i in 1:length(values)) { 
  t <- my.var$row2[ my.var$row1 == value[i] ]; 
  do.something.interesting(t); 
}

This is a fairly common operation and I had thought that beyond the vectorization I had done (borrowed term from MATLAB), R would take care of optimizations under-the-hood.

At this point, I thought how I would do it on a larger database and it struck me that perhaps I can do better than R if I manually index the data and find relevant intervals myself. How much faster can that be?

Thursday, August 25, 2011

Getting powerdot to work

Powerdot is a presentation package for LaTeX, much like beamer.

I recently got it up and running on my system and I thought I'll setup a quick guide for it:

Tuesday, August 23, 2011

Book Review: Half Asleep in Frog Pajamas

Half Asleep in Frog Pajamas
This is a book about a stock broker. Rather about two stock brokers, one current and one has-been; a she and a he broker. However, this is not a book about the Stock Market per se, neither is this a book about love, nor sleaze.

The book is written in a diary format, with time progressing linearly, with each entry marked with a day and time. The entire book, as advertised, is over in about the time-span of a long weekend.

Each entry in the diary begins off-topic and slowly careens into the old story line: sometimes in enlightening and sometimes in ridiculous ways. It probably reflects how a stock broker thinks when she is not thinking about the stock market. The book is sort of a drag in the beginning, until one gets to the evening of Friday and something of interest happens.

Monday, August 15, 2011

Gabriel's gift : A review

This has to be one of the most inspiring books I have read in a long, long time.

It starts with a magical touch, and a despairing look at the life of a broken family. And it goes uphill from there. There are moments where the book seems about to be taking a sinister turn, but instead it surprises the reader. A quite adorable tale indeed.


It is a very easy read, has a simple story told from the point of view of a precocious school-going teenager Gabriel. Kureishi managers to keep the narrative as well as the ideas extremely simple without losing any credibility at all. What we see in-front of us in the book is London with its motley populace, with stories of inhabitants intertwined and where opportunities seem to be hovering around every corner:
What a bright place London was, he (Gabriel) thought. Here anything could be achieved! You only had to wish high enough!
Opportunities waiting to be grasped by all but the hopelessly self-destructive. And Kureshi's London seems to have many of those, which somehow rings true with London we see today. 

It is amusing to see him trying to avoid vulgarity just like Dickens tried to keep the young readers in the dark about Phillip's exploits in London, but only in Garbiel's thoughts and words. He carefully avoids any detailed descriptions of Speedy's pose or what secret things happened in the bathroom while he drew his mother and her company or the indelicacy of bed's creaking while he was hidden under it. However, whatever we manage to see of London beyond Gabriel, it looks as colored as ever.


Wednesday, August 10, 2011

Humble Indie Bundle 3: A review

It was jolly good ride for the Humble Bundle 3, and it was far better and more exciting in the second half than the first one:
15 days of Hunble India Bundle 3