Tuesday, April 16, 2013

Building a Lisp Interpreter from Scratch -- Part 5: Compiler, Virtual Machine

(This is Part 5 of a series of posts on pLisp)

Using a compiler and a virtual machine for an interpreter may seem somewhat of an overkill, but makes sense for two reasons:
  1. Incorporating continuations in pLisp showed me that a VM-based approach (hence a compiler) is a straightforward way to do so -- virtual registers, call stack, the whole works -- rather than mucking around with code walkers and the like.
  2. Writing a compiler would also be useful when we want to run pLisp code natively.
Before we proceed further, some attributions are in order: Kent Dybvig's PhD thesis is pretty much the reference for much of this post.

The last time we spoke about the interpreter per se, we had just converted an expression_t struct into a native pLisp object (OBJECT_PTR). We are now ready to do further things with this pLisp object:
  1. Compile it
  2. Interpret it
(who could have seen that coming?)

The compiler converts a pLisp source form into a simplified Lisp form that is understood by the VM/interpreter. The following are the constructs in the simplified Lisp:

HALTHalts the virtual machine
REFERLoads a variable reference
CONSTANTLoads a constant
CLOSECreates a closure
MACROCreates a macro
TESTImplements IF/ELSE
ASSIGNStores a value in a variable
DEFINECreates a variable binding in the top level
CONTICreates a continuation
NUATEExecutes a continuation by replacing the current stack with that of the continuation
FRAMEStores the register contents in a new frame and pushes the frame on to the call stack
ARGUMENTAdds the results of the last evaluation to the value rib
APPLYClosure/Macro/Continuation application
RETURNPops a frame, restores registers
BACKQUOTEProcesses a backquote (can't be done by the compiler because we need to do some compiling at run time; see below) 

These constructs are predicated on the existence of the following, for want of a better term, ISA elements:

//register that stores the 
//results of the last computation
OBJECT_PTR reg_accumulator;

//the next expression to be 
//evaluated by the VM
OBJECT_PTR reg_next_expression;

//the environment in which the
//current expression is to be evaluated
OBJECT_PTR reg_current_env;

//holds the arguments evaluated
//till now (for closure applications)
OBJECT_PTR reg_current_value_rib;

//the call stack
OBJECT_PTR reg_current_stack;

The VM interprets the form pointed to by reg_next_expression, by suitably manipulating the registers, and sets the next expression to be evaluated, thereby perpetuating the computation, till it runs out of expressions to evaluate.

The astute reader will observe that all these elements are first-class pLisp objects. This is imperative especially for the current stack, since continuations encapsulate the call stack (although, to be fair, there are ways to reify the stack using native mechanisms and still end up with a first-class continuation object).

The call stack itself is a CONS object made up of frames, themselves pLisp arrays containing the next expression, environment, and the current value rib.

The working of the compiler is somewhat peculiar; the simplified Lisp that it produces from a pLisp source form is something like a Russian-doll-within-doll toy. An example will make this clear:

The source form

(define x 10)

gets compiled into

(CONSTANT 10 (DEFINE X (HALT)))

i.e., we have three 'instructions' to be interpreted by the VM (CONSTANT, DEFINE and HALT), and the first instruction contains the second, the second contains the third, and so on. Looks a bit disconcerting at first, but it works.

The compiler and interpreter work pretty independently of each other, except when it comes to macros and EVAL. If the compiler detects that it's dealing with a macro, it sets things up so that a call is made to the interpreter, and receives the results of the interpreting for compilation. The interpreter enlists the help of the compiler to process BACKQUOTE, COMMA, COMMA-AT and EVAL.

Thursday, April 11, 2013

Building a Lisp Interpreter from Scratch -- Part 4: Memory System

(This is Part 4 of a series of posts on pLisp)

(Note: This post is quite out of sync with the code base; please see Part 13)

As I mentioned briefly in Part 3, memory in pLisp is allocated from a fixed-size heap and objects are referred via indexes (called RAW_PTRs) into this heap.

Memory is addressed in pLisp not at the byte level, but at the word (32 bit) level, as indicated by the typedef for OBJECT_PTR (unsigned int). This is inefficient when we're dealing which characters, for example, but efficiency is not the primary concern for us.

The interface to the memory system is through three calls:

RAW_PTR object_alloc(int);
void set_heap(RAW_PTR, OBJECT_PTR);
OBJECT_PTR get_heap(RAW_PTR);
  1. object_alloc() is the equivalent of C's malloc(). It takes as argument the number of four-byte words to be allocated, and returns a RAW_PTR that points to the newly allocated space in the heap.
  2. set_heap() sets the pointed-to memory location in the heap to the given OBJECT_PTR value.
  3. get_heap() is the read counterpart of set_heap().
There is no deallocation procedure because we have GC that kicks in right after a form has been evaluated and its results reported to the top level. GC is a topic for another post.

The memory system is a straightforward text book implementation. We maintain a list of available chunks/segments of memory in the form of a linked list (initially there is just one big segment as big as the full heap; this gets chopped up as allocation requests are serviced).

The first word of a segment contains its size; the next word points to the next available segment. The subsequent words constitute the space available in that segment:



We maintain two variables called 'free_list' and 'last_segment' to store the start and end of the linked list respectively. To allocate memory of a certain size, we walk the free list and stop when we encounter the first segment that is large enough for our needs. The segment is removed from the list and its space is given to pLisp; whatever is left over is packaged off into a new (smaller) segment. An obvious improvement would be to look for the segment whose size most closely matches the amount of memory requested, rather than settle for the first segment that meets our needs. When it's time to free memory -- through GC -- the segment to be deallocated is simply attached to the free list at the end.

To illustrate this with an example, here's the implementation of the CONS operator:

OBJECT_PTR cons(OBJECT_PTR car, OBJECT_PTR cdr)
{
  log_function_entry("cons");

  RAW_PTR ptr = object_alloc(2);

  set_heap(ptr, car);
  set_heap(ptr+1, cdr);

  insert_node(&white, create_node((ptr << CONS_SHIFT) + CONS_TAG));

  log_function_exit("cons");

  return (ptr << CONS_SHIFT) + CONS_TAG;
}

Ignore the call to insert_node() for now; this is for GC and doesn't have a bearing on what we've discussed so far. Creation of objects of other types in pLisp follows the same template:
  1. A call to object_alloc() to allocate the memory
  2. Call(s) to set_heap() to populate both the type-specific information (e.g. length for array objects) and the object content itself (array elements, for example)
  3. Decorating the RAW_PTR with the relevant object tag and returning it.
And we're done with memory.

Tuesday, April 09, 2013

April 9, 2013

Netherlands is the next crisis candidate to fall (via Mish):
The Netherlands is still one of the most competitive countries in the European Union, but now that the real estate bubble has burst, it threatens to take down the entire economy with it. Unemployment is on the rise, consumption is down and growth has come to a standstill. Despite tough austerity measures, this year the government in The Hague will violate the EU deficit criterion, which forbid new borrowing of more than 3 percent of gross domestic product (GDP).
It's a heavy burden, especially for Dutch Finance Minister Jeroen Dijsselbloem, who is also the new head of the Euro Group, and now finds himself in the unexpected role of being both a watchdog for the monetary union and a crisis candidate.
Is this the same joker who got into trouble over his 'what's happening in Cyprus is a template' comment?  What do you know, it is. If you swing your leg too far back to kick someone, watch out, it could be your own ass that's gets the whupping.

Shouldn't speak ill of the dead, but this is hilarious:
"How should we honor her? Let’s privatize her funeral. Put it out to competitive tender and accept the cheapest bid. It’s what she would have wanted." said left-wing film director Ken Loach, according to Yahoo Movies. The funeral at St Paul's Cathedral is expected to cost around £8 million.

Friday, April 05, 2013

Building a Lisp Interpreter from Scratch -- Part 3: The Object System

(This is Part 3 of a series of posts on pLisp)

(Note: This post is quite out of sync with the code base; please see Part 13)

As I mentioned briefly at the end of Part 1, objects in pLisp are denoted by OBJECT_PTROBJECT_PTR is nothing but a fancy name for unsigned 32-bit integers:

typedef unsigned int OBJECT_PTR;

The 32 bits in an OBJECT_PTR do two things:

1. Specify what type of object we're looking at
2. Depending on the type of the object, either store its value, or point to where the value is stored.

#1 is accomplished by the last four bits, called the tag bits, and the remaining 28 bits take care of #2. Before dissecting OBJECT_PTR, a brief digression is in order: we need to understand how memory is handled in pLisp. I plan to do a separate post on the memory model, so I'll stop with a few key pieces of information that are relevant here.

Memory is allocated out of a heap, whose size is specified in the code (TODO: pass this as a command line parameter):

#define HEAP_SIZE 8388608

This memory is in the form of an array indexed by RAW_PTR values which are, surprise surprise, unsigned integers in drag:

typedef unsigned int RAW_PTR;

Digression over.

The table below lists the pLisp object types and how an OBJECT_PTR value is deconstructed to yield them (click to see full size):




Most of this is pretty self-explanatory, however a couple of explanations are in order:


First, implementing the full IEEE floating point format is too painful (I had done this for Vajra), so I enlisted the help of the C runtime for this. A float value is stored in a union:


union float_and_uint
{
  unsigned int i;
  float f;
};

When we want to extract the float value from an OBJECT_PTR, we simply extract the first 28 bits from it, index into the heap using these bits,  and store the heap content at that index into the 'i' value of the union, and voila, the 'f' value automagically contains the correct float representation. The same process in reverse works for creating the OBJECT_PTR value.

Second, we resort to some hackery for continuation objects as well. The only piece of information a continuation object has to store is the stack object active at the time of the creation of the continuation, so it seems wasteful to use the heap for this. Instead, we simply convert the stack object (a CONS) into a continuation object by manipulating the last four tag bits.

Thursday, April 04, 2013

Building a Lisp Interpreter from Scratch -- Part 2: Core Forms

(This is Part 2 of a series of posts on pLisp)

Before looking at the object model of pLisp, we turn our attention to the core forms in our interpreter. Core forms are the primitive expressions that need to be handled by the interpreter; they cannot be palmed off to the libraries, where they could be implemented in pLisp itself.

Here's a list of the core forms. Quite a few of them are there because of necessity (see above), while some of them are more for convenience, i.e, life as we know it would not end if they were absent. Also, if you want to do anything practical, say arithmetic, strings, arrays, and so on, and not end up with an interpreter that just manipulates symbols, you need things like +, -, ARRAY-GET, and ARRAY-SET (not to mention PRINT for output).

'Core' core forms QUOTE, LAMBDA, IF, SET, CALL-CC, DEFINE, CONS, EQ, ATOM, CAR, CDR
Basic real-world stuff+, -, *, /, GT, PRINT, ERROR
Intermediate real-world stuffSTRING, MAKE-ARRAY, ARRAY-GET, ARRAY-SET, SUB-ARRAY, ARRAY-LENGTH, PRINT-STRING
Advanced real-world stuffCREATE-PACKAGE, IN-PACKAGE, CREATE-IMAGE, LOAD-FOREIGN-LIBRARY, CALL-FOREIGN-FUNCTION
ConveniencePROGN, SETCAR, SETCDR, LISTP, SYMBOL-VALUE
MacrosCOMMA, COMMA-AT, BACKQUOTE, MACRO, GENSYM
DebuggingENV, BREAK, RESUME, BACKTRACE, EXPAND-MACRO
Up to elevenEVAL

A few things:

1. EQ tests for equality of content.

2. QUOTE, BACKQUOTE, COMMA and COMMA-AT are not the operators' real symbols; they are indicated so to avoid confusion with punctuation (ditto for GT, but this has more to do with my laziness in working with HTML tags).

3. PROGN can actually be implemented as a macro using a series of LAMBDAs; I just went with a native implementation. Macros involving LAMBDAs are used for implementing WHILE and LET, however (the LET macro uses the MAP function in turn):

(defmacro while (condition &rest body)
  `(((lambda (f) (set f (lambda ()
                          (if ,condition
                              (progn ,@body (f)))))) '())))

(defun map (f lst)
  (if (null lst)
      nil
    (cons (f (car lst)) (map f (cdr lst)))))

(defmacro let (specs &rest body)
  `((lambda ,(map car specs) ,@body) ,@(map cadr specs)))

4. The other comparison operators are implemented using macros. 

5. LISTP can be implemented as a macro as well, through ATOM.

6. Strings are implemented as arrays, the corresponding GET and SET are again taken care of by macros.

7. DEFUN and DEFMACRO are macros that build on LAMBDA and MACRO respectively.

8. Did I mention that macros are awesome?

Astute readers may be wondering by now what kind of a bastard Lisp they're looking at. I initially started out with Common Lisp in mind (though building pLisp as a Lisp-1), then made a detour into Scheme -- mainly for the continuations -- before I decided to persist with the veneer of CL (maybe not just the veneer; the macro system is more or less full CL; I didn't venture into Scheme syntax rules territory at all). Anyway, to a large extent, one dialect of Lisp can be made to look like another by liberal and injudicious usage of macros, so it doesn't matter that much for our purposes, I guess.

Tuesday, April 02, 2013

Building a Lisp Interpreter from Scratch -- Part 1: Syntax and Parsing

(This is Part 1 of a series of posts on pLisp)

OK, first things first. Before we can start interpreting our lisp code, we need to parse it. Conventional wisdom says that we don't need to use tools like Flex and Bison for this, since Lisp syntax is simplicity itself, and we can roll out our own parsing and scanning functionality. We're not bowing to conventional wisdom; at least I didn't, so Flex and Bison it is. I can hear somebody in the back benches muttering "so much for the 'from scratch' bit": I assure you, this is the only place where we don't roll out our own (actually there are two other pieces of functionality where we make use of third party code, but those are orthogonal to or not directly related what we're trying to achieve, so they don't count. Sue me).

The tokens we're interested in are:
  • Symbols (abc, x, ...)
  • Integers
  • Floating point numbers
  • String literals ("Hello world")
  • Character literals (#\a)
  • Left and right parentheses
  • Quote
  • Back quote
  • Comma
  • Comma-At
Inquiring minds can now mosey over to GitHub for a look at plisp.lex.

In addition to these, we also handle single- and multi-line comments, ignore white spaces and arrow key presses.

A Lisp form begins and ends with parentheses. When all the currently open parentheses are closed, it means the interpreter has something to start interpreting. Needless to say, if you pass the interpreter a parenthesis-less form, i.e., a symbol, a literal or a number constant, this will also be interpreted.

Before we feed the interpreter the form in a, well, form suitable for interpretation, we need to discern its structure. This structure is represented by a typedef (oh, by the way, now would be as good a time as any to mention this: we're doing the whole thing in C):

typedef struct expression
{
  int type;
  char *package_name;
  char *atom_value;
  int integer_value;
  float float_value;
  char char_value;
  int nof_elements;
  struct expression **elements;
} expression_t;

The type member indicates what is the type of the expression, captured in these #define's:

#define SYMBOL 1
#define LIST 2
#define INTEGER 3
#define STRING_LITERAL 4
#define CHARACTER 5
#define FLOAT 6

(Source)

The rest of the fields store the value of the expression, depending on its type (e.g. atom_value will be for the case where the expression is a symbol, char_value for when it is a single character, and so on). The elements member stores the elements in case the expression is a list. An added wrinkle is the package name, to handle cases where the symbol name is preceded by the package name, as in 'math:power').

The conversion of the token stream into an expression_t structure is done in plisp.y, the scanner. The distilled logic is as below:

expression: atom | list;
atom: integer | float | string_literal | character_literal | symbol;
list: expressions_in_parens | quoted_expression | backquoted_expression | comma_expression | comma_at_expression;
expressions_in_parens: left_paren expressions right_parens;
quoted_expression: quote expression;
backquoted_expression: backquote expression;
comma_expression: comma expression;
comma_at_expression: comma_at expression;
expressions: /* empty */ | expressions expression;

On a side note, by suitable manipulation of the yyin variable, we can feed the interpreter input from stdin, or from a file of our choosing (e.g. to load the pLisp library).

Once yyparse() has had its way with the input, the interpreter is all set to begin. But we'll delay things a bit more, for a very good reason: in Lisp, code and data are the same (the fancy word for this is homoiconicity), so we get a lot of bang for our buck if we convert an expression_t object to a pLisp object (denoted by OBJECT_PTR) before giving the interpreter the go-ahead. The pLisp object model is the subject of another post.

Building a Lisp Interpreter from Scratch


pLisp now has continuations. It took a lot of effort, slogging through the relevant literature, and a significant rewrite of the code, but it's finally done (I have not updated the GitHub repository yet; plan to do it shortly [Update: Done]).

Before proceeding further with other features, I thought I'd do a series of how-to posts on pLisp. These will serve as a sort of de facto documentation of pLisp (beats the 'You want documentation? Go to The Source, my friend' approach), and also provide pointers to folks looking to do their own projects (there's plenty of material out there on building/embedding an interpreter within a Lisp implementation; in my opinion, while this is good, it's a cop-out; such interpreters are meant mainly for illustrating concepts, trade-offs in design choices, etc. We still don't pierce the veil, so to speak. Not to mention the obvious hit in performance).

Here's a tentative list of posts:
Stay tuned.

Tuesday, March 26, 2013

March 26, 2013

"I personally believe that Hugo Chávez was murdered by the United States"
-- William Blum

I have been meaning to mention this earlier, but got around to it only now: kudos to William Blum for stating something that is on every progressive's mind but not voiced out loud for fear of being accused of tin-foil hattery.  From the referenced essay:
Chávez said he had received words of warning from Fidel Castro, himself the target of hundreds of failed and often bizarre CIA assassination plots. “Fidel always told me: ‘Chávez take care. These people have developed technology. You are very careless. Take care what you eat, what they give you to eat … a little needle and they inject you with I don’t know what.”
 Six words for doubters: Confessions of an Economic Hit Man.

Sunday, March 24, 2013

March 24, 2013

After seeing that their whining full page ads (grammatical errors, misplaced commas and extra-liberal application of exclamation marks and all -- couldn't such a wealthy industrial house afford a decent copywriter?) failed to elicit any support or sympathy for their cause, the Sahara parivar have resorted to more blatant means: flaunting their political connections by publicizing (through full-page ads, natch) pictures of the movers and shakers who attended the rice-eating ceremony of one of their scions (didn't know the rich and the famous celebrated something as mundane -- and yet out of reach for millions of Indians -- as eating rice; maybe that's why they're rich).

Saturday, March 23, 2013

March 23, 2013

From a column (via Deccan Chronicle) about the Sri Lankan issue:
What’s clear is that India’s ability to influence the course of events in the island nation is negligible. Sources close to the powerful first family have told this writer that they see India as an “irritating gnat that can be smacked away at will”.
This is exactly what's wrong with journalism, something Markandey Katju can train his guns on: quotes -- inflammatory ones, at that -- attributed to anonymous sources that only the journalist is privy to. Do we have any way to distinguish genuine quotes from those that are simply pulled out of journalists' asses, journalists serving interests other than that of the public? We don't, so just stop using such quotes. We may lose the insights that genuine quotes provide, but this is a small price to pay to ensure the integrity of the press. On a side note, the incendiary nature of the quote makes it all the more likely that revealing it to the public is meant to elicit reckless action, either from the government or from jingoistic elements outside.

The CBI inquiry scandal throws up an interesting thought: were the raids/investigations initiated by somebody against the UPA? Maybe somebody with leanings towards the BJP? What better way to make the Congress tie itself into knots, trying simultaneously to condemn the action (and protect its erstwhile allies) and to show that it doesn't pull the CBI's strings? Our politicians' actions are a conspiracy theorist's delight, aren't they?

Monday, March 18, 2013

March 18, 2013

The Cyprus bailout fiasco is being described as " the single most inexplicably irresponsible decision in banking supervision in the advanced world since the 1930s.":
[EU officials who engineered this weekend's Cyprus bank bailout] have weakened – perhaps catastrophically – the principal pillar supporting modern banking. This pillar is deposit insurance. Ordinary savers who had received a solemn assurance that deposits up to 100,000 euros were safe are now being asked to take a haircut. This raises questions about deposit insurance throughout the EU and invites runs on banks not only in the most “financially-challenged” nations such as Greece and Spain but even in Italy and France.
Methinks life will go on. They said the same thing about the sanctity of contracts and the credit markets when holders of Greek bonds were made to take haircuts; the haircuts were 'voluntary' to avoid triggering credit default swap payments.

Welcome to Flight Club, where the only rule is "We make up the rules as we go".

Wednesday, March 13, 2013

March 13, 2013

Leaving aside the emotions, jingoism and nationalism on both sides, what could be a possible solution to the Italian Job controversy? Well, here's a part-pragmatic, part-diplomatic and part-mafioso proposal that our MEA boys can reach out to the Italian government with:
  1. Send the two marines back to India (no, hear us out, seriously).

  2. We will pull strings here to make sure that they will return to Italy for good, within two months. You can trust us on this -- after all, we're talking about a sovereign country here, an upstanding member of the international community that honours its commitments... oh wait, never mind. On to the next point, anyway.

  3. As escrow/guarantee, we will depute one of our respected diplomats -- maybe even the head honcho himself -- to spend the two months in Rome, all expenses paid by us, of course. He/She will return to India only when the marines make it back to Italy. Heck, the same flight can do both legs of the journey, with the personnel exchange being witnessed on the tarmac by a designated and disinterested third party. We know we're preaching to the choir, but still: if you have any clarifications, please refer to The Godfather for modalities and variations on the theme.

  4. Coming to how we will pull off #2 above, the case against the two marines is not watertight, anyway. If there's still any uncertainty, leave it to us; we have handled such things before.

  5. To sweeten the deal, and to pacify the natives, please deposit a sum of Rs 20 crores as compensation to the victims' families. The Rs 6 crore bank guarantee can be adjusted against this amount, of course.

  6. If you would like to discuss this further, or propose changes, discuss logistics, etc., please don't hesitate to either call us at our toll-free number 1-800-WE-MAKE-DEALS or email us at mea@top-secret.gov.in. Thank you.

Tuesday, February 12, 2013

February 12, 2013

When we think of our government, what comes to mind is the avuncular and benign face of Manmohan Singh, who means well but is way out of his depth; Sonia Gandhi, who has experienced personal tragedies because of her family's involvement in politics, and who still perseveres in serving the country; venal politicians and bureaucrats, who engage in petty machinations in their quest for power and pelf.

But once in a while, something happens that changes our perspective; we see the government for what it actually is (whether this happens consciously or is, for want of better words, an epiphenomenon, or more accurately, an example of swarm 'intelligence'): a scheming sociopath. A government that keeps the rejection of a mercy petition secret and sets a date for the execution. A government that sends the intimation to the death row prisoner's family by Speed Post one day before the planned execution when it knows that Speed Post only guarantees that articles will be delivered anywhere in India in four to six days. A government that is so paranoid about its survival prospects that it is willing to end a person's life just to send a message to the voters that it is as good as the opposition in some nebulous metric like "Strong/Firm on terror". A government that pretends to be afraid of the backlash that would supposedly arise if news of the planned execution was released, but is strong enough and brave enough to face the backlash -- through curfews, preventive/house arrests and tear gas and lathi charges -- when the execution has been carried out. A government that is engulfed in white-hot rage because somebody dared to attack it in its own den, its seat of power.

Irrespective of how one feels about Afzal Guru's guilt and whether capital punishment should be abolished or not, one thing we don't want our government to be is a relentless, vengeful, all-powerful serial killer who also keeps stealing stuff, while occasionally shooting himself in the foot accidentally.

On a side note, Praveen Swami's demolishing of Arundathi Roy's melodramatic piece on the execution is a must-read, if only to avoid being misled by her half-truths and general BS (I know, I've said nice things about her in the past, so bite me).

Friday, January 18, 2013

January 18, 2012

Well, it looks like beheadings by both sides are pretty common:
Despicable as the alleged beheading of Indian soldiers by the Pak­i­s­t­anis was that led to the present military crisis, the fact is that both armies are or have been in it to­g­e­ther. India’s ace TV anchor Barkha Dutt will do the country and the community of journalists a great service by speaking up at this time. She gave the following eyewitness account of the Kargil War to more or less affirm a tradition of beheading the enemy that unfortunately seems to exist on both sides and pe­r­haps straddles other countries too. And I quote from writer-acti­vi­st Shuddhabrata Sengupta’s web­po­st for the piece Barkha Dutt published in Himal magazine in June 2001. 
“I had to look three times to make sure I was seeing right. Bal­a­nced on one knee, in a tiny alley behind the Army’s administrative offices, I was peering through a hole in a corrugated tin sheet. At first glance, all I could see were some leaves. I looked harder and amidst all the green, there was a hint of black — it looked like a moustache. ‘Look again,’ said the Army Colonel, in a tone that betrayed suppressed excitement. This time, I finally saw. It was a head, the disembodied face of a slain soldier nailed on to a tree. ‘The boys got it as a gift for the brigade,’ said the Colonel, softly, but proudly.”

Friday, January 11, 2013

January 11, 2013

If you gaze into the abyss, does the abyss also gaze into you even if you are an Indian? Is my country always right? If you are a 70-year-old grandmother sneaking into PoK, and nobody knows that you've sneaked in, are you an Azad Kashmiri, and is the ceasefire broken? Does it matter if Reshma Bi ran across the Line of Control 16 months ago or six weeks ago? Can we extradite her to India and request her to give a series of expert lectures on guerrilla warfare to our OTA cadets? Is constructing watchtowers a violation of the ceasefire? Even if the watchtowers are facing inwards? Is intimation through a public address system the only way to let somebody know that they're violating the ceasefire? Who pays the bill for the hot line between the GOCs? Is beheading enemy soldiers so common as to warrant something like "...both sides have engaged in cross border raids, which have on occasion included beheadings", almost as if one were referring to an exchange of sweets on Independence Day ("You must try these rasgollas... Oh, almost forgot..." <chop>)? What is a controlled retaliation? Does Praveen Swami have an inside track with respect to the Indian military establishment? Speaking of the establishment, what are the covert actions that B Raman is referring to as retaliation for the Pakistani action? Who are our prospective allies in Pakistan? Does Sarabjit Singh know what these covert actions are? If he does, what does he think of them? What does Afzal Guru think of all this? What about Rabbani Khar? Ban Ki Moon?

(Apologies to Crispin Glover)

Thursday, December 20, 2012

December 20, 2012

Shame on you, Saina:
Cocking a snook at the Badminton Association of India, a defiant Saina Nehwal chose to withdraw when holding two match-points against Russian Ksenia Polikarpova in the first round of the $120,000 Syed Modi Grand Prix Gold badminton championship here.
The World No. 3 cited a knee-injury that had troubled her from this year’s Denmark Open as the reason for her decision to withdraw when leading 21-17, 20-18 against a rival ranked 165th.
“With many important tournaments lined up next month, I decided not to aggravate the injury,” said a smiling Saina after she waved to the disappointed crowd for cheering her all the way in the 29-minute encounter.
and
“Throughout the year, the BAI does everything that Saina wants. Government allows Saina economy class (airfare) but BAI helps her travel First Class by paying the difference in fare. In return, BAI wants her to play in a couple of events in the country. But that is not happening,” said a senior BAI official on condition of anonymity.
and
By the end of the day, a ‘chastened’ BAI must have realised that it is better to accept a firm ‘no’ than a reluctant ‘yes’ from Saina. As one of the BAI official put it, “Sadly, the truth is, the Indian badminton needs Saina Nehwal more than Saina needing Indian badminton.” 
Methinks somebody's shoes are getting too small for them. To be fair, it could be advice from questionable sources that is causing this kind of behaviour.

Thursday, December 13, 2012

December 13, 2012

It may be possible to test whether we're living in a simulation.

An earlier article that says there may be a 20% chance that we do.

Via Rigorous Intuition, a mind-blowing argument.

Let's see:
  1. This explains the Big Bang. Things started when the simulator program was kicked off.
  2. Things are discrete in the quantum world because the simulation is, by nature, discrete -- whether it's event-driven or time-stepped.
  3. Non-local connections are explained as well -- the 'master controller' is the CPU running the simulation, and it has access to (and is able to maintain) all the simulation objects and their dependencies, irrespective of where they are in the simulated world.
  4. The usual paradoxes like wave-particle duality, the uncertainty principle, and so on are explained by the analogy of mathematical formulas and 'lazy initialization'.
  5. Karma and synchronicity? Global state/memory/logic in the simulator program.
  6. God is the entity running the simulation.
Of course, this still doesn't explain things like ultimate cause (is our God also a simulated entity? How many levels does this go?).

Related: good stuff from Reddit.

Tuesday, December 11, 2012

December 11, 2012

fool  

/fo͞ol/
Noun
A person who acts unwisely or imprudently; a silly person: "what a fool I was to do this".

id·i·ot  

/ˈidēət/
Noun
  1. A stupid person.
  2. A mentally handicapped person.
Effing idiots. Or are they fools? Now I'm confused.
Context: this and this.

Tuesday, December 04, 2012

December 4, 2012

Awfully decent of the Chinese, preferring to pay for stuff rather than pillaging and plundering the to-be-annexed Indian territory:
In 1962, for example, Deak warned the CIA that China was planning to invade India after his company’s Hong Kong branch was swamped with Chinese orders for Indian rupees intended for advance soldiers.

Wednesday, November 28, 2012

November 28, 2012

Sachin Tendulkar:
When I feel it is time, I will take a call. It is going to be a tough call nevertheless. It is going to be tough because this is what I have been doing all my life. It is going to be difficult to suddenly hang up my boots one day.
I have the highest regard for Tendulkar, but somebody please give the man a copy of Who Moved My Cheese?

Reason #1876 why I'm glad I didn't take the civil services exam -- questions like this:
Domestic resource mobilisation, though central to the process of Indian economic growth, is characterized by several constraints. Explain in ten words.
I made up the "ten words" bit, but I think I would have shown myself the door because my ten words would have been roughly divided as below:
  • Babus
  • Netas
  • Corruption
  • Nexus
  • Six words unprintable in a family blog