January 27, 2005
The Aunties' Network
One of the questions I get asked most often is, "Vishy, are you going to have an arranged marriage?"
I am not going to answer that question in this post (apologies to the 100 million or so beautiful eligible women out there -- you are just gonna have to hold your breath). Neither am I going to say if they are a good or a bad thing because cultural phenomena always seem weird in a different cultural context. However, I am going to try and explain the wonderful and awe-inspiring mechanism by which thousands of young Indian men and women are arranged to live happily ever after.
This is a slightly edited version of a write-up I did for Everything2 earlier. Your comments, as always, are much appreciated.
The Aunties' Network (SM) is a wide-area, distributed, reliable, multiply redundant and highly efficient peer-to-peer network of middle-aged ladies of Indian descent that stretches across India and any country with an Indian Diaspora. (Note: A middle-aged lady in India may generally be called 'aunty', in a context of respect and endearment. This term has nothing to do with other aunties of the Far East, who may be engaged in the world's oldest profession). It exists with the sole purpose of bringing together eligible bachelors and bachelorettes in arranged marriages. It is probably the world's earliest implementation of a Friendster-like system, where parents act as proxies for the actual individuals to be married. Some, who abhor the concept of arranged marriage, may even call the Network an international conspiracy, in the same league as the Illuminati, the Freemasons and The Matrix.
Young gentlemen and ladies generally get "plugged into" the Network when they finish their higher education. Whether explicitly informed of it or not, the ladies get plugged into the Network in their early 20s. The gentlemen are usually plugged in during their mid 20s, thus allowing them some time to earn some money, stature and a foothold for themselves in the grand scheme of things. A side-effect of this plug-in lag is that the groom in an arranged marriage is usually a few years older than the bride. With the recent mass exodus of young Indian gentlemen to faraway shores, their median age of entry into the Network is falling for two reasons:
- Enough money gets accumulated sooner because salaries are higher abroad and
- Care should be taken that they don't get hitched of their own volition with local women, in their loneliness as expat bachelors.
Once an eligible individual has been plugged in, search messages are trickled along a wide Network of Aunty peers until a suitable match is found. Once a suitable match is found, a thorough background check is conducted to see if there could be a match. Matches may be verified using alternate connection paths in the Network until a reliably positive opinion of the individual in question is reached. The Network is powered entirely by goodwill and a genuine desire to find the best possible member of the opposite sex (can't imagine a Network for gay marriage anytime soon) for someone whose interests are close to your heart.
While there are few general-purpose strategies that ladies can follow to put off being plugged into the Network, gentlemen may engage in time-consuming and ungainly pursuits such as graduate school to postpone the day when they have a viable source of income and an automatic ticket into the Network.
Am I plugged into the Network? If you're so curious, be so nice as to ask me in person or drop me a personal email.
Posted by Vishy at 09:38 PM | Comments (2)
January 26, 2005
Mythic archetypes in the Lord of the Rings and Harry Potter
The title of this post may make sound like the opening to a hand-wavy term paper by a cultural anthropology undergrad, but I promise you it is not! In recent years, books in both The Lord of the Rings trilogy by J. R. R. Tolkien and the Harry Potter series by J. K. Rowling have been made into movies. The movies have often been released close to each other as well. Juxtaposing these movies in people's collective short term memories makes it easy to draw parallels between the two stories and bring out some similarities between them that cannot be explained by the realm of coincidence alone. This blog post outlines some similarities between the two storylines and calls them by a fancy name -- mythic archetypes.
The Obvious Ones
Harry, a malnourished orphan, is the hero of the Harry Potter series. He grew up in a magic-hating Muggle family. Readers wouldn't immediately associate him with a stellar wizarding tradition, unlike some of his classmates, like Ron Weasley or Draco Malfoy, who come from pure blood wizarding families and have grown up with magic surrounding them. Similarly, the hero of the LotR trilogy, Frodo, is from the race of hobbits, a race mostly ignored in the history of Middle Earth because they were content to eat, drink, be merry and generally stay out of trouble with the rest of the world. One wouldn't expect a member of this out-of-the-way, unimpressive race to be the person who finally destroyed the evil that was the Ring. In sum, Harry and Frodo didn't ask for greatness -- it was thrust upon them.Both stories feature a dark, fearsome and all-pervasive evil force. Sauron was the central evil in LotR (indeed, it isn't clear if the Lord of the Ring doesn't refer to him), whereas Lord Voldemort/Tom Riddle, Jr. was the central evil in Harry Potter. Both Sauron and Tom Riddle covertly engaged in evil deeds when they were spending time at Numenor and Hogwarts, respectively. Sauron had undead agents, the Nazgul, who were drawn by the Ring. Everything they touched was instantly robbed of vitality, which might remind of the Dementors in Harry Potter. The dementors guarded the much-feared wizard prison, Azkaban and sapped prisoners of their mental strength by reminding them of their worst memories. In the latest books of the Harry Potter series, they had been assigned tasks much more evil than merely guarding a prison -- ambushing Harry and harming him in some way.
Of course, Harry wouldn't have made it alive through five instalments of the series by J. K. Rowling unless he got his ass saved from tight situations by the powerful wizard Albus Dumbledore. Guess who was saving Frodo's and the Fellowship's collective ass when the Balrog was almost upon them at the close of Book I of the trilogy? That's right, Gandalf the Grey (ever notice how both of them are called 'wizard'?). He paid for it with his life, of course, but being an Istari, the normal rules didn't apply to him and he came back as Gandalf the White. I wonder if this will happen sometime with Albus Dumbledore as well. Heck, he was practically not around at all for most of Harry Potter V, because he ph34red Harry's brain lacked a firewall and was ownz0r3d by \/01|)3^^0|2+. Okay, I'll stop with the geek and cracker references already.
For some reason, Dobby reminds me of Gollum, and in more than the CGI nature of their characters on screen. Gollum acted as a guide subjugated to Frodo until he destroyed the Ring, even if their relationship was a tad uneasy. Similarly, Dobby, who is subjugated to Harry, guides him in difficult situations like the Triwizard Tournament, even if Dobby tries to save Harry's life in ways that annoy Harry.
Karolina points out to me that Wormtail is the analogue to Saruman. They are both accessories to the real evil and are weak of character. I am tempted to notice a similarity in the names of Wormtail and Wormtongue, the counselor to Denethor installed by Saruman.
Aragog is the analogue of Shelob. I am so utterly freaked out by the idea of giant spiders.
The Not-So-Obvious Ones
Both the stories occur in the elaborately constructed universes of Middle Earth and Magic-Land. They have spawned an entire class of fans who are interested in the worlds in which the stories occur, in and of themselves. Both the stories and their associated movies have also spawned an elaborate collection of kitsch in one corner of our era's collective attic, which our future generations will look back upon and laugh. I would have to give it to Tolkien for the astounding level of detail he achieved in painting his universe. He was a linguist by training and started out designing his universe by first designing its languages. The songs in the book are pieces of poetry that stand by themselves. Compare this to the measly lone poems in each Harry Potter book, always sung by the Sorting Hat. Most of the spells in Harry Potter consist of touched up Latin (Expecto Patronum -- cough/spit out a Patronus; lumos -- Light Up). I have read somewhere that Avada Kedavra (kill -9 anyone?), the lethal instant-death spell is derived from Aramaic.
Both the Harry Potter series and the Lord of the Rings trilogy are about the triumph of good over evil. This is a lingering theme found in mythologies all over the world, so one wouldn't think too much of it ordinarily. However it is interesting how both stories paint a complex, ambivalent and muddled picture about these concepts. Frodo stands for the hope that the rest of Middle Earth is holding out against Sauron. However, even he is not immune to the mental tricks played by the evil Ring. Similarly, Harry represents the war of decent wizards against the troublemakers. Yet, as we see in the later books of the Harry Potter series, he is not immune to being so taken by thoughts of Voldemort and feeling like he is actually performing evil deeds as Voldemort himself. By trying to kill Harry but only succeeding in giving him a scar, Voldemort left a little of himself inside Harry. Likewise, at the end of Book IV, Voldemort takes a bit of Harry blood and transfuses it into himself. What better analogy to the figurative mixing of good and evil in the same person than these two example of literal mixing?
Authors of both the stories have chosen to personify good and evil not just a few key characters, but have chosen instead to portray the fight between good and evil in epic proportions. It is not just Frodo against Sauron -- it's Frodo and the Elves, Men and Dwarfs against Sauron and the Orcs. It is not just Harry against Voldemort -- it is Harry, Dumbledore and all the decent wizarding families against Voldemort, the Death-Eaters and the evil wizarding families.
Perhaps in 10 or 20 generations, these will be the mythologies about our times that the kids then will read. One thing is for certain, though -- the mythic archetypes of that time won't be much different!
Posted by Vishy at 12:20 PM | Comments (0)
January 24, 2005
Vishy's Vonderful Vitticism #2
Who said they always had to be authored by me?
Perfection is attained not when there is nothing to add but when there is nothing to take away.
--Antoine de Saint-Exupery
Yes, that's the author of The Little Prince.
In the original:
La perfection est atteinte non quand il ne reste rien à ajouter, mais quand il ne reste rien à enlever.
When I saw this quote somewhere on the Web, I was so floored I wanted to kiss my computer screen. An infinitely more poetic and palatable expression of Occam's Razor.
Posted by Vishy at 11:13 PM | Comments (1)
January 21, 2005
Useless Factoid of the Day #2: The Golden Ratio in the C++ STL
The Golden Ratio is any ratio where the following holds true:
a:b == (a+b):a
The Golden Ratio can also be defined as the ratio of successive Fibonacci numbers. Its approximate value is 1.618:1 and its exact value is (1 + √5)/2. This ratio occurs in the radii of successive spirals in the shell of a nautilus and in the numbers of successive generations of wild rabbits. The Golden Ratio is also said to resonate very well with the human visual system's sense of esthetics. The navel is said to divide the length of the human body into sections related by the Golden Ratio. Indeed, the ancient Greeks used the Golden Ratio in several of their buildings. Mathematicians and philosophers have cited the Golden Ratio as proof of how apparently unrelated aspects of the universe still speak the universal language of mathematics.
Did you know how the Golden Ratio is linked to the C++ collections implementation in the Standard Template Library? What in the world do wild rabbits, nautiluses and buildings in ancient Greece have to do with code to grow a resizable collection of objects in C++? Read on for what is probably one of the more unusual places in which the Golden Ratio appears.
Dynamic memory allocation
Computer programs can allocate memory to store values in two ways: statically and dynamically. Static memory allocation refers to a situation where the amount of memory needed is known in advance and can be specified in the source code of the program itself. Dynamic memory allocation refers to a situation where a program may request an amount of memory which may change depending on conditions during its execution. Dynamic memory allocators dole out memory from an area of program-accessible memory called the heap. Typically, they maintain a linked list of available blocks of memory, using which they respond to dynamic memory allocation requests. Given a request for a certain number of bytes of heap memory, an allocation could take place in several ways. An allocator could traverse its list of available blocks and return the first block that would accommodate the number of bytes requested. Such an allocation is called a first-fit allocation. Alternatively, an allocator could traverse its list of available blocks until it finds an available block, whose size is closest to the number of bytes requested. This type of allocation is called a best-fit allocation. For the sake of simplicity, we will assume for the rest of this entry that allocators perform first-fit allocations.Resizable collections
Collections are entities in a program that can be treated as one cohesive object and addressed in a unified and predictable manner. For example, arrays are contiguous areas of memory which start at a well-known address in memory and have a fixed length once they are allocated. Dynamically resizable collections are those that grow to accommodate any number of items that are added to them, even if the number of items to be added was not known in advance. An example of a dynamically resizable collection is theArrayList class in Java and C#. This collection is based upon an array which is usually larger than the number of items in the collection. It is time to resize an array when it gets "too crowded" and the number of items in the collection comes too close to the size of the array. A new array of a bigger size is dynamically allocated from the heap and the members of the old array are copied to the new array.
Let's consider how the size of the new array is related to the size of the old array. Let us suppose the size of the old array is x. The size of the new array could then be some multiple of x, say k · x. A naive implementation would request the new array to be simply twice the size of the old array. This expansion would guarantee that all the items from the old array would fit into the new array, leaving plenty of room for any new additions. In this case, k = 2. However, let us see if we can get away with smaller values of k to save some space.
Let us say the initial allocation of an array is x.
Upon the first resize, the allocation would be k · x.
Upon the second resize, the allocation would be k · k · x.
We have to ensure that the second resize can accommodate the results of the previous two allocations. In other words, x + k · x <= k · k · x. Assuming a nonzero initial allocation (why would anyone want to dynamically allocate *no* memory?), we can factor out x, leaving the quadratic inequality
k2 - k - 1 <= 0
which can be solved to produce k <= (1 + √5)/2. In other words, we can get away with a resizing factor as low as the Golden Ratio, or even lower! A few STL implementations resize their collections using a factor of 1.5, for a good mix of efficiency and convenient memory.
This has been a presentation by the World's Largest Repository of Useless Knowledge, me. For more information, look up Andrew Koenig's paper on this subject using Google.
Posted by Vishy at 01:13 AM | Comments (1)
January 17, 2005
MIT Mystery Hunt 2005
The Mystery Hunt is an annual competition held every January, during IAP at MIT. Teams of hunters solve mind bending puzzles for a shot at a treasure, plenty of geek glory and a chance to design the Hunt the following year. I spent only one IAP at MIT, because for the others I would go to India and visit family. During that year, I lent just a little bit of my puzzle solving efforts to the East Campus team, "EC come, EC go", but because I hadn't made that many friends, it wasn't as much of a social experience for me. I made friends who were big on Mystery Hunt in the following years. They would invite me every time, but I would just not be there for the later IAPs. I definitely started to see how the Mystery Hunt could be loads of fun. The Hunt was definitely going to be something I would regret not being involved in a lot during my time at MIT.
Or wouldn't I? Now, a year after I left MIT, one of my friends from work, Oana, came up with the idea of getting together a team of people from work to take a shot at this year's Hunt. I never thought I would be hit by this pleasant blast from the past, thanks to Oana. It would definitely be interesting doing this Hunt remotely. My friends at MIT who were gung-ho about the Hunt were happy to have us join them this year from New York.
Oana and I wanted not just to solve puzzles but to make this fun and entice as many of our coworkers to participate as possible. So we sent out emails to everyone in our group and to our trainee classes -- our famed "instant social networks". We attached a sample puzzle from the 2004 Hunt to give people a flavor of what it was like. As poor luck would have it, we picked a puzzle that was quite MIT specific, which seemed to turn off some people. However, we convinced others who had similar reservations that puzzles change every year and the one we sent out as an example wasn't very representative. (As we learned later, we were right.) During the rest of the week leading up to the Hunt, we went around gently prodding people to swing by and stay for a while to look at puzzles. This involved walking up to people you don't frequently speak with, passing the time of day, and telling them how cool it was to solve puzzles. Other honorable efforts included *ahem* appealing to the rather sad-sounding fact that people really had nothing better to do on Friday night than get together with a bunck of geeks and solve puzzles. Of course, not everyone bought it. Still, it was better than nothing... =)
Friday finally dawned. At 6:00 pm, I changed from business casual into my casual
We sucked.
The puzzles were harder than many people expected. Their solutions also depended on insights a bit more obscure than people expected. Who is to say we didn't have fun, though? Several people stayed till 9:30 or 10:00. A few of us continued working on puzzles till 1:00 am. There was one puzzle which rocked, no pun intended. We had to identify 15 rock songs and then use the opening words to solve a puzzle, whose solution was another rock song. We had had less than amazing luck with the puzzles earlier, but as soon as we knew we were on the right track with this one, our sagging self-esteem was boosted and we were motivated to carry it the rest of the way. Later four of us went out for coffee to a 24 hour diner and exchanged, you guessed it, more puzzles and interview questions as we devoured our late night snacks. In sum, the puzzles we got far on we didn't get right, and the ones we got right, we didn't get too far on. However, at the end of the weekend, it did give me a massive, well-deserved sense of closure to look at all the puzzles and their solutions.
How about you try your hand at them too? https://normalville.org/setec
Mad propz to Alisa and everyone else of Team Uplate. It was great to be able to work on Mystery Hunt with you folks!
Posted by Vishy at 12:22 AM | Comments (1)
January 10, 2005
Reviews of Subway Reading #1: Brave New World
Brave New World, by Aldous Huxley, is a fantasy about a futuristic, eugenic, class-conscious dystopia, where most norms of today's society are nonexistent. The book was written in 1931, which, in the book, is the start of a new era, the era of Ford. It was the beginning of an era when cars could be mass produced off an assembly line, and the considerably increased efficiency led to new comforts and a feeling of happiness amid all the plentiness.
Why stop at cars, electronics and other consumables though? What if human beings could be mass produced as well? With the right numbers of each kind of human, all perfectly conditioned to love their life and not think of any other possibilities, there would be no unrest. Nobody would sidestep the roles into which they are born and society would be much happier in general. This is the peaceful, plentiful vision of civilization that Brave New World presents to us.
Disclosure: The following paragraphs may contain spoilers and other points crucial to the plot. Read ahead at your own risk. Feel free to skip ahead to the section titled The Review if you are anxious to avoid spoilers.
More on the Dystopia
Brave New World is set in London of approximately 2550 A.D. (approximately A.F. 600) Society is divided into five castes -- the Alphas, the Betas, the Gammas, the Deltas and the Epsilons. Alphas perform all the highly skilled and desirable tasks in society. They are the scientists, doctors, statesmen and sportsmen. Alpha embryos are born of one egg fertilized by one sperm cell. Everyone other than the Alphas performs tasks requiring progressively less mental effort. The lower castes, Deltas and Epsilons, come in groups of identical twins, called Bokanovsky groups. Early in the life of the fertilized egg that eventually gives rise to a Bokanovsky group, it is subjected to hostile conditions, which causes it to multiply over and over. Sometimes, Bokanovsky groups numbering 72 can be manufactured from just one egg. Because individuals from the same Bokanovsky group are overwhelmingly genetically similar, they think in similar ways, which favors people from the same Bokanovsky group performing tasks like working in factories and assembly lines.
People are no longer born to their parents. In fact, the words father and mother are vulgar and generally unmentionable in so-called 'civilized' society. Instead, people are decanted out of bottles, in which they spend their embryonic life. The bottles are lined with the uterine tissue of pigs and have a blood-like surrogate circulating inside them, carrying oxygen and nutrients to the embryos within. Depriving lower-caste embryos of oxygen by reducing this rate of circulation is another way of ensuring that their mental development will not be at par with higher-caste embryos. Once babies are decanted (and in some cases, even before), they are subjected to several rounds of Pavlovian conditioning, which will ensure that they lead their lives just as the Director of Predestination intended for them. Moral and pseudo-factual statements are repeated to young children in their sleep for much of their early lives, in a process known as hypnopaedic learning, so that these statements become instinctive and self-evident to them.
These statements include dictums such as "Everyone is happy now" and "Everyone belongs to everyone". Monogamous relationships are uncommon and are, in fact, discouraged. When somebody wants to have sex with somebody else ("to have them"), all they need to do is go up to them and ask. Men and women are encouraged to be as promiscuous as possible, for after all, everyone belongs to everyone else. What's more, a free exchange of sexual favors doesn't lead to pent up emotions, which could be the cause of unrest in society. If anybody in the civilized society of Brave New World experiences any remotely unpleasant emotion, it is easily cured by popping a gram or two of soma, a mass-produced form of purified cocaine.
Dramatis Personae
It is against the backdrop of this civilized, happy dystopia that the chief characters Bernard Marx, Lenina Crowne and Helmholtz Watson lead their lives. Bernard is an Alpha who has an uncommonly small physical stature, supposedly due to alcohol added to his blood surrogate when he was still in the bottle. Helmholtz is an Alpha who is almost too successful. Lenina, a Beta woman, accompanies Bernard on a trip to a 'savage reservation' in New Mexico in the United States. A savage reservation is a place untouched by the civilized dystopia described above. Its inhabitants lead a squalid, relatively primitive existence, speak dead languages like Spanish and believe in Jesus and other deities. Lenina and Bernard encounter Linda, an emigre from the civilized world brought to the reservation by circumstances, not by choice, who has given birth (*gasp*) to a child, John, in the reservation. John learns the ways of the reservation from his peers, much to the disdain of Linda, who tries to impart as much civilization to him as she can, nonetheless. John is well versed in Shakespeare's works, one of which lends the book its title. Bernard and Lenina manage to procure permission to take Linda and John back with them to London. The rest of the story revolves around John's experiences in the civilized world.
The Review
The novel is a satirical fantasy at its core. As far as alternative reality novels set in London go, one can't help but be reminded of another scary and influential novel, 1984. Brave New World appears at the 5th position in a list of the Twentieth Century's 100 Top Novels compiled by Random House, Inc. 1984 checks in at #13. I, for one, felt that this novel didn't deserve so high a spot in that list, especially a spot much higher than 1984.
The characters of 1984 are very real and readers can easily identify with the ordinary, yet terrifying life of Winston. The sense of horror one experiences as one reads 1984 is very palpable and realistic. This impression is further enhanced by the fact that it is set in a stark, yet credible world. In contrast, the events of Brave New World, grotesque and stark as they stand in comparison to those of today's world, do not evoke the same empathy and character identification in readers. The Brave New World is also far less believable relative to today's circumstances. If characters readers don't identify with well are set in a barely believable set of circumstances, the end result doesn't leave as deep an impression on the readers anymore. The plot of Brave New World seems to be little more than happenstance set in a fantasy world, where the reader gets bombarded continually with new facts about the world along the way. In 1984, the development of the world is much more deliberate and quite complete by the time readers get into the thick of the plot.
However, Brave New World isn't without its flashes of brilliance. The introductory parts of the book, before the main characters are introduced, makes for good reading. The climax, when the Controller for Western Europe explains the rationale for the way things are in the civilized world, is undoubtedly the best part of the book. Despite the iron grip the Controller and his administration hold on the lives of the people, the Controller is shown to be a well-meaning renegade who had to learn to love the system he administered. In well thought out, precise, amoral terms, he explains that the painful history of humankind necessitated a society where happiness was valued over everything else, including passion and achievement. The snippets of Shakespeare that John quotes in the book are poignant and well chosen.
The book leads to interesting discussions and thought experiments on the state of the world and its problems today, and ways in which they could be solved. The book presents one solution that seems to work on the surface. Readers can quickly see the problems with the approach presented in the book. However, the striking amorality with which this fantasy world is presented is commendable. A few strangers on the subway did make passing remarks about how they liked the book. I concur with them. Overall, I would definitely recommend this novel as a great piece to read on the subway or any other public transportation of your choosing.
Overall grade: A-
Posted by Vishy at 10:17 PM | Comments (1)
Vishy's Vonderful Vitticism #1
It is a lot easier to fake knowing something than to fake not knowing it.
Posted by Vishy at 08:00 PM | Comments (0)
January 08, 2005
The technological generation gap
Just the other day, I was telling my manager, who is in his mid-30s, to begin using our company's internal instant messaging program. All I got was a horrified, disgusted look."How do you expect me to stand that thing on my desktop all day? If someone sends me a message, it blinks in my taskbar and I can't do anything else until I answer it. A phone call from someone would be easier to handle!"
But as many of us in our teens and 20s would know, that's the best part about instant messaging. In terms of communication between two people, it is a happy medium between the urgency and immediacy of a phone call, where one makes *gasp* actual human contact, and the aloofness and distance of a letter (does anyone write letters anymore?) or an email message. (And yes, my generation does prefer "email" over "e-mail". Want to know why?)
How does the MTV generation take technology like instant messaging in its stride so easily? Why do Gen X-ers and former flower children balk at it? Welcome, my friends, to the phenomenon of the technological generation gap.
Generation gap -- why does it even occur?
Every generation has disagreements with generations that come before and after itself on a number of subjects, both trivial and important. We will not dwell too much on the disagreements of importance, because they arise as a result of the changing values of successive generations. Values are tricky to pin down and any treatment of them here would make me ramble, something I am already prone to doing. However, before moving on to talking about discussing inter-generational disagreements on trivial subjects, I'll leave you with two quotes to think about:It is possible for a man to go from being a liberal to a conservative in twenty years without changing even one of his opinions.(Unknown)
Any man who is under 30 and is not a liberal has no heart; and any man who is over 30 and not a conservative has no brains.(W. Churchill)
Is there any reason why it makes sense for generation gaps to exist? When I took a class with Prof. Marvin Minsky, I came across a reasonable explanation. Early in our lives, it is essential for us to learn about the world around us because our own survival depends on it. In learning about the world and satisfying our natural curiosity, we pick up the trends and values of the time uncritically, because we're in learning mode. Somewhere along the line, a switch flips and we stop learning, so that we are not so overwhelmed by the continuously changing world around us that we cannot teach what we have learned so far to our kids. When this switch flips, our perceptions of the world start to ossify slowly and everything new seems to start being strange, weird or unnecessary. In practical terms, this translates to the generation gap.
The Technological Generation Gap
Now, on to the real subject of this post. According to a recent Slashdot poll, most readers agreed that 25 is the age when the music of the present-day starts to sound weird. In other words, according to the Slashdot readership, a musical generation lasts approximately 25 years. What about clothes? Clothes seem to change basically every decade. Perhaps they change twice every generation! What about technology, specifically computing technology? Computing technology offers an interesting case study at the moment because the IBM PC came out less than 25 years ago. This interval would mean that we, in 2005, are at a point where a generational changeover is taking place in computing technology.In the good old days, my father worked quite comfortably with Microsoft Excel on MS-DOS. Several of the other people I knew were comfortable working with an MS-DOS command prompt, *cough* minimalistic *cough* as it was. However, once computers started to come with Microsoft Windows pre-loaded, these same people shrank in horror from the same applications now reincarnated as parts of Microsoft Windows and Microsoft Office. In some cases, the reason was an unwillingness to learn the new versions of the applications because it was no longer necessary to use them. In other cases, however, it was the fear that has stayed with humankind since before the beginning of time, the fear of the unknown.
I have myself had an interesting experience with the technological generation gap. I was introduced to computers in India, which was then about 5 years behind the hot new developments in the United States. My first computer, in 1992, was an 8086/88 at my school, which had to be booted from a 5.25" floppy disk. When Pentiums were just coming out in the United States, 386DXs were state of the art in India. I saw my first copy of Windows 95 in late 1997. I also got on the Internet for the first time in late 1997. Then I left India to attend college in the United States. This was an extremely abrupt shift upwards in terms of technological sophistication. Just before I left India, we bought a 333 MHz computer for my family so they could be in touch with me. As soon as I arrived in the United States, I bought a 600MHz computer, which wasn't even state of the art back then. Back then, the 800 MHz Coppermines and Xeons were just coming out. From Windows 95, I directly jumped to Windows 2000 (I know the two OSes aren't genetically related). From praying at the keyboard that an Web page would download completely, I went to a blazing fast T-1 connection where 200 kbps download speeds were not uncommon. In generational terms, it was a warp from being 40 to suddenly being 14. Of course, the other 14 year olds you run into don't know that you've recently been 40. They certainly have no idea how cool the music or culture of youf former generation was. In a similar way, I found that people my age in the United States were extremely uncomfortable with a DOS prompt and had no idea what cool beasts terminate and stay resident (TSR) programs were. I, on the other hand, cut my teeth on PCs using a DOS prompt and had written a couple of TSRs myself. Needless to say, I wowed a few of my friends who weren't Linux hackers with long strings of computerese that I could type at a command prompt to make things happen. Overall, this sudden generational warp was an extremely singular situation in which to find myself, but a very fun one, nonetheless.
I found myself on the losing side of this generational warp as far as cellular phones were concerned. Ordinarily I tend towards early adoption of technology, money and other resources permitting. However, my reluctance to include cellphones in my life bordered on Luddism. Meanwhile, most of my friends and peers were constantly on cellphones, chatting to family and friends. Soon, the cellphones began to have an effect on our social conventions. Meetings were hardly made for a set time and place. Groups of people began to pick meeting times and places fluidly once they were in the same area. Eventually, so many of my friends got cellphones and I heard so much about how quickly they become indispensable that I decided to try one out. Since then, I have never quite realized how I lived life without one before. I am at an age in my life when I will begin to notice these generation gaps in technology and other aspects. As a imperfect human being, I too will be prone to the effects of the technological generation gap. However, I hope fervently that every so often, I'll have the good sense to get out of my comfort zone and try out new technologies like the cellphone. Or else, people might start communicating with brain waves next and I might be stuck staring at a blinking instant messenger button on *my* taskbar for the rest of my life.
Posted by Vishy at 02:35 AM | Comments (0)
January 05, 2005
Perl 6: A Cool Programming Language
Perl may inspire strong feelings of love and hate in people, but it is unarguably a unique language.On the surface it sort of looks like C and was initially meant to be an awk-killer. However, you quickly realize that except for the semicolons, braces and a few functions names, Perl has little in common with C. Perl was designed by Larry Wall, a linguist by training. If you read Perl scripts you'll quickly realize that they read like some other languages you may know, like *gasp* English! Heck, Perl is probably the only programming language that has a culture of poetry!.
Programming in Perl can be a LOT of fun (more on that in the extended entry) Nevertheless, Perl 5, which is the latest and greatest Perl out there, suffers from some stodgy constructs that seem to take some of the fun out of hacking up a quick and dirty Perl script. Perl 6 goes a long way in fixing some of it, as can be seen in this great article. This blog entry is about why programming in Perl is fun and about what I think are the best new features of Perl 6!
Perl is fun!
Just compare
open(INPUT, $file) or die("Cannot open $file!");
with
try {
File f = new File(filename);
FileInputStream stream = new FileInputStream(f);
} catch(FileNotFoundException e1) {
// Handle this exception
} catch(SecurityException e) {
// Handle this exception
}
The code excerpt on the top is a line of Perl, while the code excerpt below accomplishes the same thing in Java. It is clear that the Perl reads like something you would say in everyday speech. "Open the file or die trying!" The Java example has much more structured exception handling and a more formal way of opening a stream to a file. The Perl script, on the other hand, Does What You Mean (tm) and worries about the error handling in a different way entirely.
Perl has a type system that may seem weird if you come from a C/C++/Java/C# background. However, very soon you'll learn to like it because Perl's types correspond roughly to how our linguistic system is wired. Perl has a scalar type, which could be a number, a word or "one of anything". In Perl you would say, "Pass me the ball", in C you'd be saying "Pass me the ball which is exactly 14.75 inches in diameter". Do you really care so long as it's clear you want just one ball?
Perl also has an array type, which is "something made of other things". In Perl, you'd be passing around a basket of apples. The basket may be empty or full and if you need to put in more apples at any time, you just add in the apples. What's more, you can also put in apples, pears, cupcakes, knives and anything that could go into a basket. In C and C++, you'd be required to indicate exactly how many apples that basket can take before filling it up with apples. If you have to put in an extra apple, you either can't do it or you move all the apples from this basket into an entirely new basket on your own. If you didn't put in enough apples to fill up the basket, random undesirable things may appear in the space that is left over. But no, you can put in only apples and not anything that could go into a basket.
Perl has a hash type, which is "a bunch of pairs of things" which are associated with each other in some way. You could use a hash to indicate the concept of relationships. You could use a hash to say "George Bush is related to America in the same way as Queen Elizabeth is related to the United Kingdom" And later, you could say "Oh wait! Jacques Chirac is related to France in the same way too!" Without using a special data structure called a hashtable in C, you'd have to come up with your own way of keeping track. You could keep two arrays of things where a country and its head of state are stored at the same place in each array, but that doesn't make their relationship explicit enough.
Perl deals in things, groups of things and relationships between things. It doesn't much care what the thing is, how it is stored and so on. Contrast this with a C-like language, where the language imposes terms on what a thing could mean. Is the thing stored using 16 bits, 32 bits or 64 bits? Or, is it a letter instead? Or *gasp*, a word? Perl is this magic language, but ultimately it runs on real computers that unfortunately deal in ugly things like 16, 32 and 64 bit chunks. But rather than expose all that to you, it runs around pasting pieces of duct tape everywhere so your program holds together.
Another big feature of Perl is that it is a programming language with pronouns. This fact plays a big role in the natural feeling you get when you read Perl, because we use a lot of pronouns to refer to the immediate context of a sentence, when we understand and process English. In a set of instructions like "Soak shirt in laundry detergent for two hours. Wash. Rinse. Repeat until stain is gone.", there is an implicit 'it' after the verbs at the start of the last three sentences. We know exactly what each 'it' refers to. The first two its refer to the shirt and the last it refers to the set of instructions itself. Consider what would happen if we were really explicit about everything and did not use the implicit 'it's at all. The instructions would read "Soak shirt in laundry detergent for two hours. Wash the shirt. Rinse the shirt. Repeat 'Soak shirt in laundry detergent for two hours. Wash the shirt. Rinse the shirt.' until the stain is gone." Sounds a bit convoluted, doesn't it?
If you wanted to cut every apple in a basket of apples in C, your code would look something like this:
Apple basket[10];
// ...
for(int j = 0; j < 10; ++j)
{
Apple an_apple = basket[j];
cut(an_apple);
}
In English, your code would read something like "Counting from 0 upwards until 10 (because that is *exactly* how many apples this basket can hold), let us assign it to a number J. Pick up the Jth apple from the basket and set it on the table. Let's call this apple A. Now, cut A"
In Perl, your code would read like this:
my @basket;
foreach(@basket)
{
cut;
}
You can practically read it out aloud and figure out what it says! Notice that you don't ever explicitly refer to the apple you're cutting right now. All you say is "for each apple in the basket, cut it". Perl has a magic variable called the "topic variable", to which it automatically assigns the apple you're working on right now. Its value can be accessed through the variable name $_. The same $_ acts as the 'it' and is passed into the subroutine 'cut'. See how simple and natural it is? So natural that even a C-style language like C# has borrowed from Perl and introduced a foreach loop, in addition to the usual for, while and do...while loops.
Perl also has flexible clause ordering, a distinctive feature that makes it seem chatty and colloquial compared to other programming languages that mandate a fixed order of if(condition) action(); You can write valid Perl that reads like so:
print("$variable not defined!") if !defined($variable);
or
print("$variable has a value!") unless !defined($variable);
Perl allows an if or a while checking for a condition to be placed after the set of actions associated with that condition. The statement has exactly the same effect as if the if or while were placed before the set of actions for a condition. This flexibility mimics how we occasionally put ifs or whiles at the end of our sentences when we speak English. Note that this flexibility parallels English in another subtle way. If we are about to issue a complicated set of instructions for some condition, we usually express the condition before the actions. For example, we might say "If the cabin pressure goes down, grab the oxygen masks that appear. Put the mask over your mouth and nose. Continue breathing normally" However, if we're describing only one action to take when a condition is true, we might say "Turn off the A/C if it gets too cold" Perl supports the post-action if only if the action consists of one statement.
Another reason Perl is so much fun to write is that the wonderful hacker culture around Perl has given rise to remarkable function names, such as croak, carp, warn and bless. Variables can be "my" variables or "our" variables. The language really starts to be fun when you think you can get away with common words like my and our in something as official, boring and formal as a computer language.
So by now, you must be convinced Perl is a lot of fun to write, but it is definitely not fun to read, especially if you didn't write the code. Perl is well reputed to be a write-only language. Code once written, even by you, can be really hard to figure out, if you're trying to make sense of it later. Perl also lacks important constructs like C's switch..case, which takes a set of actions based on the different values that can be taken by a variable. It could be achieved with an onerous sequences of ifs and elses, but that's the best Perl can offer in terms of language support, without going into complicated constructs like hashes of function references. This language, with a culture of poetry, is also one with a tradition of programmers competing to write the most obfuscated code.
And Along Comes Perl 6...
Perl 6 is the next redesign of Perl. It is a rather ambitious departure from the currently available versions of Perl. It adds a few new language constructs, changes the feel of the language a little bit and makes it easier for programmers to avoid common mistakes. I'll briefly mention a few things I love about Perl 6 and let you read about the rest at http://www.linux-mag.com/2003-04/perl_6_01.html.The given...when construct
Perl 5 lacks a switch...case, but Perl 6 has one. It's calledgiven...when. If you want to take different courses of action based on the values of a variable, you can write Perl 6 code that reads like so:
given $country
{
$nbsp; when 'U.S.' { print 'North America' }
$nbsp; when 'India' { print 'Asia' }
$nbsp; when 'France' { print 'Europe' }
$nbsp; when 'Egypt' { print 'Africa' }
}
See how wonderfully and naturally it reads? The designers of Perl 6 have clearly prioritized a natural feel for this construct over sticking with the analogous switch...case construct in Perl's forebears.
Junctions
Perl 6 introduces a new fundamental type in the language, called a junction, which converts long and onerous boolean conditions in other programming languages to statements that practically read like English! Let's say you wanted to see if any of the numbers in a list was greater than 10 and print a message if that were the case. In classic Perl, you could do something like
foreach(@numbers) { print "Too big!" if $_ > 10; }
of if you wanted to get fancier,
map { print "Too big!" if $_ > 10; }, @numbers;
But, with Perl 6, you can say
print "Too big" if(any(@numbers) > 10);
The function any returns a disjunction (a collective OR) of all the variables in the list, so that each number, in effect, is compared against 10 and the condition is true if any one of them is greater than 10. Another kind of junction is a conjunction, which lets you write code like
print "$num is the biggest so far!" if(all(@numbers)) < $num;
What I am most excited about is that this will let you reduce the somewhat clunky
if($foo > 1 && $foo > 2 && $foo > 3)
{
do something
}
to the considerably less clunky
if($foo > all((1, 2, 3))
{
do something
}
where you don't keep mentioning $foo repeatedly. If you aren't impressed, try an abjunction:
if(one(@roots) == 0)
{
print "This polynomial has a unique root"
}
Now, if reading code with junctions doesn't remind you of another language you know (*cough* English *cough*), then who knows, maybe you don't know it that well? ;) Junctions are also ideal candidates for optimization, because the inherent parallelism in comparisons and other operations scripts perform with junctions lets compilers allocate them to different threads or processors as it sees appropriate. This junction stuff packs a powerful punch.
Consistent sigils
This is a fairly major change that helps Perl programmers avoid common and hard to spot mistakes and brings the language more in line with our own linguistic intuitions. This would have to be my favorite feature of them all.
As you may know, Perl uses different prefixes on variables depending on the context in which the variable is used. For example, you'd declare scalars, arrays and hashes as follows:
my $scalar;
my @apples;
my %hash;
These prefixes are known as sigils. Perl programmers: did you even know they were called sigils? A sigil in a non-Perl context means a symbol or a sign.
However, when referring to the 5th element of @apples, you might think you could use @apples[4], but Perl 5 makes you use $apples[4]. In other words, you are supposed to use the scalar sigil even if you are referring to an element from an array. As you will see explained in the article about Perl 6above, sigils are like demonstrative pronouns. $ would roughly correspond to 'that' and @ would roughly correspond to 'those'. $number would be 'that number' and @apples would be 'those apples'. In English you'd refer to an apple as 'one of those apples'. However, Perl 5, in its infinite wisdom, makes you refer to it roughly as 'one of that apples'. This convention in Perl 5 isn't bad once you get used to it, but it is counterintuitive to begin with. This counterintuitiveness alone lets inadvertent mistakes slip in every once in a while. Sometimes these mistakes are caught by the Perl compiler. Otherwise, depending on which sigil you mix up with which other, these mistakes can cause your script to fail far away from the site of the mix-up, or worse, produce utterly unpredictable behavior.
Perl 6 fixes sigils to bring them in line with our linguistic intuitions. In other words, you can refer to the fifth apple in a basket of @apples as @apples[4]!
Summary and conclusion
I hope the above gave you some flavor of why Perl is a fun programming language in which to write code. Perl 5, the latest Perl out there, is undoubtedly fun, but also a bit rough around the edges. Perl 6 is an ambitious redesign of the language which adds a few new language features, fixes some of the rough edges and adds considerable power.Posted by Vishy at 09:31 PM | Comments (0)
Useless Factoid of the Day: Psittacosis
I heard the word 'psittacosis' in a medical context on TV the other day and found that I have really no clue what sort of a condition it was. So, I got curious and decided to look it up. If you have a pet parrot or parakeet, you better listen up. Psittacosis is an infectious disease that can spread from parrots to humans. Psittacus is Latin for parrot, in case you were wondering. In human beings, psittacosis manifests itself as flu-like symptoms (fever, chills, headache, muscle aches and a dry cough). Hepatitis and neurological complications can also occur. Don't inhale dried secretions from your bird ;) That's how it gets transmitted. Today's Useless Factoid was brought to you by the World's Biggest Repository of Useless Knowledge, me.Posted by Vishy at 09:06 PM | Comments (1)
Hello, blogworld!
Hello, blogworld! Welcome to my spout, where you might get a glimpse of what goes on in the mind of the World's Biggest Repository of Useless Information, moi. I'll write about random interesting things I run into during my life as a yuppie in New York. You might read here about a tech nugget I think is cool. You might read my take on a book I am reading right now. You might hear about my opinion about some news item or current event. You might be asked to give your opinion on something I write. Or you might get to see me vent, in a good or bad way, about something going on in my life.Why a blog?
2004 was the Year of the Blog. I started a blog when I moved to New York in early 2004, but that petered out quickly because it was on a free blogging site and because I was involved in an intensive training program at work. With this blog, it's different. It's attached to my domain, my personal presence on the Web. What's more, I seem to have more time on my hands now than last year. I'll try and blog as often as I can. As some of my friends would agree, I am phenomenally bad at keeping in touch. Blogging is a good way for people that I am not regularly in touch with to still get a flavor of what's going on in my life. I am also trying to improve my writing skills to the level of a decent creative writer. Blogging will hopefully give me enough practice that I can write short stories of my own. I am also phenomenally bad at keeping records of my life. I fear that one day, 40 years from now, I will have absolutely no idea how I spent my 20s. This blog, hopefully, will be a legacy unto my future self.Posted by Vishy at 01:33 AM | Comments (2)