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.


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:

Creating vectors.
Transpose a matrix.
Quitting R
Generic isInstanceOf
apply after grouping
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:

Variable definitions
Array variable prefix
Hash variable prefix
Scalar variable prefix
Substitute function
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.