Python and Hindi

So I’ve recently discovered that using Python to analyse data is, to me, like talking in Hindi. Let me explain.

Back in 2008-9 I lived in Delhi, where the only language spoken was Hindi. Now, while I’ve learnt Hindi formally in school (I got 90 out of 100 in my 10th boards!), and watched plenty of Hindi movies, I’ve never been particularly fluent in the language.

The basic problem is that I don’t know the language well enough to think in it. So when I’m talking Hindi, I usually think in Kannada and then translate my thoughts. This means my speech is slow – even Atal Behari Vajpayee can speak Hindi faster than me.

More importantly, thinking in Kannada and translating means that I can get several idioms wrong (can’t think of particular examples now). And I end up using the language in ways that native speakers don’t (again can’t think of examples here).

I recently realised it’s the same with programming languages. For some 7 years now I’ve mostly used R for data analysis, and have grown super comfortable with it. However, at work nowadays I’m required to use Python for my analysis, to ensure consistency with the rest of the firm.

While I’ve grown reasonably comfortable with using Python over the last few months, I realise that I have the same Hindi problem. I simply can’t think in Python. Any analysis I need to do, I think about it in R terms, and then mentally translate the code before performing it in Python.

This results in several inefficiencies. Firstly, the two languages are constructed differently and optimised for different things. When I think in one language and mentally translate the code to the other, I’m exploiting the efficiencies of the thinking language rather than the efficiencies of the coding language.

Then, the translation process itself can be ugly. What might be one line of code in R can sometimes take 15 lines in Python (and vice versa). So I end up writing insanely verbose code that is hard to read.

Such code also looks ugly – a “native user” of the language finds it rather funnily written, and will find it hard to read.

A decade ago, after a year of struggling in Delhi, I packed my bags and moved back to Bangalore, where I could both think and speak in Kannada. Wonder what this implies in a programming context!

Levels of polymorphism

Different languages have different levels of polymorphism, and it is a function of the environment in which the language developed. I discovered this last night when someone wrote on twitter that there is no word in Tamil for snow:

That got me thinking as to whether Kannada has a word for snow. Thinking of words for all the super-rain things in Kannada, I figured that “hima” is the word for fog, and “manju” means mist. But there is no word for snow in Kannada!

I put up the question on twitter, and the answers again were variations of the list I’ve put up earlier – some suggested “hima”, others “hani” (means “drops”, as in “raindrops”). One suggested “tushaara” for snow, but it’s not a commonly used word, so while it might be valid, I was looking for more commonly used words.

It then dawned on me that like the Tamil country, “solid rain” (apart from hailstones – which has its own Kannada word Anekal – translates to “elephant stone”) is not all that common in the Kannada country too. Yes, the Kannada country is cooler than Tamil country, and “solid rain” does happen, but it doesn’t happen on a regular enough basis for each type to have a word of its own. So, while I might think that “hima” is fog (since that’s the context in which it’s used in Bangalore), it also stands for “snow”! It’s all solid rain, and since it’s not all that common, you can have one word that describes it all! Interestingly, I can’t think of a Kannada word for “ice” also (again I haven’t learnt Kannada formally, though I speak the language at home. So what i know is the everyday spoken language)!

On a different note, in Japanese, the same word “Ao” is used to describe both blue and green! I’m again not sure if this because Japanese people are blue-green colour-blind, but the level of polymorphism in colour is interesting. At the other end of the scale, Italian has at least three words to describe different shades of blue (my knowledge of Italy, and Italian, I must mention, is mostly from football).

First, you have “celesti” or sky blue, as in the Biancocelesti of Lazio:

Then you have the blue of the sea or “azzure”, as in Inter Milan’s Nerazzuri

And finally, the word “Blu” is used for dark blue, as in Genoa’s Rossoblu. 

As if all this was not enough, they have Viola for purple!

It is interesting how different languages use different levels of polymorphism for different things!

Alco Haalu

Does anyone know why the colloquial name for liquor in Kannada is “oil” (eNNe) while the corresponding word in Tamil is “water” (thaNNi)?

Is there some kind of a caste/class origin to it, with me being biased given that most Tamilians I know are upper caste/class, and that there is a different colloquial word that is in vogue among other classes? Because “eNNe” has more of a working-class feel to it (the name, that is), and one that has been appropriated by all sections of society.

While on the topic, I learn that the Gult word for alcohol is medicine (mandu)!! Fantastic!

What is the colloquial name for alcohol in your language, and what does it mean? Put it down in the comments here.

PS: and does anyone know why alcohol bottles are sold in black polythene covers? Never seen these things being used elsewhere so if you see a black polythene cover you know there’s a good probability it’ll contain a bottle of alcohol

The buffalo and the donkey

They are two much-abused animals but I think we can do well by adopting certain characteristics of them. The buffalo has a thick skin, and the donkey has the ability to kick (jaaDisi vadi as they say in Kannada), and I think these are qualities that one would do well to have in order to deal with society.

So there are people you care about and people you don’t care about. And then there are people you are forced to care about because people you care about care about them. And there are people you are forced to care about because people you care about care for people who care about them. And so forth. As you can see, in a few links (maybe a median of 6), you are forced to care about everyone on this planet because someone you care about cares for (someone who cares about)^n someone who cares about someone who cares about them…

So you need to put a stop to this somewhere, and that’s where a buffalo skin helps. It helps shield yourself from people who you don’t care about who might make snide remarks about you. After all, whatever you do, there are people who are bound to be negatively affected by that, and when they make snide remarks you are forced to care about that because of the chain I described above.

The donkey skills are good pre-empts. Once employed, they’ll stand you in good stead for a long time and make sure people won’t mess with you at all. But along with this it is also important that you have buffalo skills, else you will find that you have to employ donkey skills way too frequently and lose reputation. Sparing use of donkey skills is best, else it’ll dent your reputation severely and increase your need for buffalo skills beyond your means.

My father used to say that I was a good donkey. My mother used to say that I was a good buffalo. So I guess I’m not too badly placed when it comes to such animal instincts. Now if only…

Teaching Sustainability

So I was at an aunt’s place last night to celebrate Diwali, and we were celebrating with fireworks. Don’t raise a stink about my carbon footprint here since that’s besides the point. Also besides the point is that I spent a long time playing on the swing in my aunt’s house and thoroughly enjoyed himself.

So the deal is that most “night fireworks” are lit with sparklers (sursurbatti in Kannada). So in order to keep the fireworks going, it is important that there is at least one burning sparkler at any point in time. Now, it is a big pain to light a sparkler directly, using something like a matchstick or a candle. The easiest way to light a sparkler is from another sparkler. I’m reminded of the technical definition of a chain-smoker, who is defined as a smoker who uses only one matchstick a day – the rest of his cigarettes being lit from other cigarettes.

Anyways the point is that in order to light fireworks “sustainably” it’s important to keep a chain of sparklers going. It is important that before a sparkler burns out, you use it to light another, and so forth. That way you end up wasting little time in terms of lighting new sparklers from candles. So it is usually the duty of an “elder” (a role that I took upon myself last night) to keep the chain of sparklers going, so that the rest can have uninterrupted fun.

So what I found last night was that my niece and nephew, in their eagerness to play with fireworks, would end up taking sparklers from my hand faster than I could build the chain. It happened way too frequently. I would have just lit a sparkler when they would take it from my hands and not return it, thus preventing me from keeping the chain going. Clearly, they didn’t know how to light fireworks “sustainably”. They prioritized immediate gain to the “loss” in terms of time wasted in lighting new sparklers.

So it was down to incentives. Whenever the chain of sparklers was broken, it was up to either me or one of my cousins to make the effort to light a new sparkler “from scratch” and start a new chain. The kids weren’t involved in this, and were oblivious of the pain that their unsustainable practices caused. And got me thinking about how I could “safely” align the kids’ incentives with sustainability.

Soon the lamps in the garden ran out of oil, and that changed the whole ball game. Now, every time the chain got broken, someone had to go into the house to light a new sparkler and restart the chain. And being one of the younger ones around, it fell to my niece to go in each time the chain was broken and get her mother to light a sparkler. The incentives had changed.

Suddenly there was change in my niece’s behaviour. She suddenly became active in terms of keeping the sparkler chain going. She never took sparklers from me when I didn’t have a spare that would keep the chain going. When she saw sparklers in my hand burning out, she would bring new sparklers to me so that I continued the chain. Her change in behaviour was sudden, and significant. Her brother, who was deemed to be too young to run in to get new sparklers lit to start new chains, however continued in his profligate ways.

So this is like one of those posts that I call as “management guru” posts. Where I tell a long-winded story to describe a simple concept. The concept here being one of sustainability, and aligning incentives. So the point is that if you want to encourage sustainable use of natural resources, users’ interests should be aligned to sustainability. They need to be punished in the short run for drawing too much.

MGM Channel

Yesterday I upgraded my Tata Sky package to Annual Mega Pack (with the would-be-ladywife wanting all Kannada and Telugu channels, and all movie channles; and with me wanting all sports channels this was most economical). And got service to this channel called MGM which was earlier part of an add-on package I wasn’t sure I wanted (along with TCM, Lumiere and Warner Brothers).

So last evening I celebrated the upgradation of my Tata Sky package by watching this random (isn’t close to the same league as the dollars trilogy or once upon a time in the west) western called Hang ’em High. Decent movie, but what made it immensely watchable is that there were no ads.

Yes, you read that right. MGM doesn’t show any ads in the middle of movies. Not one. And given the Tata Sky pricing, I guess it charges a reasonable subscription fee to fund itself! The sad part is that they don’t advertise this enough and so probably they aren’t able to collect as much subscription fees as they could. Nevertheless, this is a beautiful model and I just hope they sustain (my assumption is that if they didn’t show ads during a Sunday evening movie, they won’t show ads at all).

Given the surfeit of advertising that plagues most of our movie channels, I knew something like this was going to happen sometime. A channel that subsists on user subscription rather than spoiling the viewing experience by flooding the movie with ads. And what has made this possible is direct to home television, where your choice of channels isn’t dictated by your neighbour’s. And one in which it is easy for the channel to monitor the number of subscribers without the distributor (in this case , Tata SKY) fudging the numbers.

We need to be thankful to DTH for enabling such beautiful concepts like no-ad-movies, and thank MGM for taking a bold step and starting a no ad channel. Now, can sports channels create “plus versions” of themselves where they’ll show uninterrupted sport rather than cutting the first and last ball of each over and showing  the rest of the over in a smaller screen? I’m sure there are enough people who will be willing to pay a premium for it.

And I wish a similar model comes up for radio (Worldspace RIP but you didn’t offer radio in car). Again, too many ads.

Chowka Baarah

Yesterday after a gap of about fifteen years, I played chowka-baarah. For starters, the name intrigues me. It translates into four-twelve (I suppose), but that doesn’t make sense. Essentially, there are two primary variations of this game depending upon the size of the grid used (5 by 5 or 7 by 7), and these two numbers are “big numbers” in different systems. In the 5×5 version, the “big scores” are 4 and 8, while in the “7×7” system, it’s 6 and 12.

A certain variety of seashells (called kavaDe in Kannada) are used as dice, four of them in the 5×5 version and 6 in the larger version. The “score” of the dice is determined by the number of kavaDes falling “face up”, and if all fall face down, the score is twice the number of dice. So if you have 4 shells and all fall face down, you get 8 points. I haven’t done much research on this but I do think the probability of a die falling “face up” is much more than the probability of it falling “face down”. I don’t know the exact probability.

The game itself is like Ludo; your pawns going round and round in circles and inward in order to reach the centre of the square when it “queens”. The first player to queen all their pawns wins. There are concepts such as doubling pawns (they act as a pair hten, move in pairs only on even throws of the die, etc.), cutting (if your pawn reaches a square where an opponent’s pawn is, the opponent’s pawn “goes home”, etc. Simple game, and widely played in a lot of “traditional households”.

Considering that I had stopped playing this game when I was still quite small, i had never realized the strategies involved in playing the game. Back then I’d just generally move whatever pawn i fancied nad somehow my grandparents would move in a way in order to simply enable me to win. It was only yesterday that I realized that the game is not as simple as I thought, and that strategy dominates luck when determining how you do.

It’s not like bridge, where card distributions are exchanged across pairs in order to take the luck out of the game. Nevertheless, I realize that the number of “turns” in the game is large enough for the probabilities in the seashells to balance out across players. Rather, the decision that you need to make at each turn regarding which pawn to move is so important that the importance of this drawfs the number you threw! Again you will need to keep into account stuff like the distribution of your next throw, your opponent’s next throw and so on.

I think I have a thing for games with randomness built into them rahter than those that are completely a function of the players’ moves (like chess). I think this is because even with the same set of players, games with randomness built in lead to a larger variety of positions which makes the game more exciting.

Coming back to Chowka Baarah, the other thing I was thinking of last night was if sunk cost fallacy applied in this, when I was trying to decide betwen a reasonably advanced pawn and a backward pawn to decide as to which one to save. Finally I decided that apart from the loss in terms of the pawn being sent home, other things that I had to take into consideration when I moved was about which pawn capture would be more valuable for the opponent, probabilities of differnet pawns getting captured, potential danger to other pawns, etc.

It’s a fun game, one of the most fun “traditional” games. Maybe one of the most “strategic” traditional games. Miss playing it for the last fifteen years or so.