Monday, August 14, 2017

August 15, 2017

Something fishy with the purportedly fake message sent out by Unocoin:



If the email about the ICO was not sent by the Unocoin team, what gives with the security details reported by Gmail?

Friday, August 11, 2017

August 11, 2017

I don't know whether to laugh or cry at this:
"This week the L.A. Times described a 17-year-old from Virginia who'd spent several hours a day perfecting his technique in Microsoft Excel, "one of 150 students from 50 countries competing in the Microsoft Office Specialist World Championship" at the Disneyland Hotel in Anaheim. "At stake: cash, prizes and the clout that comes with being the best in the world at Excel, PowerPoint or Word. 'I'm going to do my best to bring it home for the United States,' John said as he prepared for the competition." Microsoft's VP of Worldwide Education said the event helps students "to become more employable to companies that build their businesses around the Microsoft suite." For example, the article points out, "Past winners have gone on to attend Ivy League colleges and even work at, yes, Microsoft... Delaware resident Anirudh Narayanan, 17, prepared all summer to compete in the Excel 2013 category, 'looking up obscure facts just in case I might need to know it during the test.' He's hoping the skills he honed will help him at Carnegie Mellon University, where he will begin studying economics in the fall. 'I make sure I do a minimum of five hours a week in Excel,' Anirudh said. 'Then for a while I'll be on YouTube watching videos about Excel.'" John eventually won the first-place prize in the Excel category -- which was $7,000 and an Xbox.
In related news that will definitely make you smile rub your hands with anticipation, the next pLisp tutorial is ready -- I walk through the development of a basic unit testing framework using pLisp.

Tuesday, July 11, 2017

July 11, 2017

Nice publicity stunt (how else would the world get to know of the existence of companies like Culture Machine and Gozoop?):
Culture Machine in Mumbai recently launched a video wherein they surprised their female employees with the good news. The video that seemed like an impromptu gift began with them asking what it's like to have periods. 
You can totally see floods of joy gushing on their faces when they are told that they can take a paid day off. The video states a classic example of bliss, and I am sure is driving loads of applauses from women around the country. 
Another company in the same league is Gozoop, a digital marketing organisation. All the female employees working for this organisation will also get a paid leave on the first day of their period. 
Wonder what the reaction would be if it was also announced that this would be accompanied by a commensurate reduction in their pay cheques since, well, equal-pay-for-equal-work and all that nonsense.

In news from the never-underestimate-the-basesness-of-humans section, umbrella-sharing startup loses nearly all of its 300,000 umbrellas in a matter of weeks.

Reason #12376 a majority of Chennai auto drivers are scum:  Globetrotting couple lose dog in Chennai.

To end with some uplifting news in an otherwise depressing news day, here is a tutorial I put together on how to develop a Bitcoin client in pLisp. You're welcome.

Monday, June 12, 2017

June 12, 2017

...
else if(item == "SanitaryPad")
taxRate = 0.12;
...
                      - Poor unsung tax software dev

Yeah I know, they will be using item category codes, which will most probably be numeric, but my point still stands: why is the GST code dealing at this level of detail? As new items enter the market, spare a thought for the above developer who needs to maintain this code (his employer will be laughing all the way to the bank, though -- "New version! Incorporates latest tax changes! Upgrade for a one-time discount of...").

Wednesday, May 31, 2017

May 31, 2017

(Disclosure: IITM is my alma mater)

The beef fest at IITM and the ensuing tensions leave one shaking one's head. The IITs have already lost their sheen, what with the indiscriminate opening of campuses in every -- what, district? -- and unjustified affirmative action, do they really need to turn into another JNU? Why not try focussing on world-class research? What about, say, pushing the frontier on quantum computing? Nah, we'll focus on cattle slaughter and transportation, that's more fun.

More crocodile tears for the customers. Quick question: if the burden is on the customers, why don't we see them protesting on the streets, just like they did during the whole jallikattu thing?

Monday, April 17, 2017

April 17, 2017

[Warning: Game of Thrones spoiler ahead]

Remember S4E08 of GoT? The Mountain and the Viper? It would be fair to say no other scene on TV or the big screen had as much of an impact on me as the one where Oberyn lets himself be brought down after doing everything perfectly (well, almost everything, if you ignore the way he loses his first spear). I couldn't bring myself to rewatch the scene for quite some time. Might even have been a bit of PTSD there.

The reason I bring this up is because of this:


That's me playing White against the computer, having just moved my rook suicidally to b2, with the Black knight's upcoming fork to c4 the equivalent of Gregor Clegane tripping Oberyn.

It may look like just another blunder in a chess game, but to me it was the closest I had come to winning (unaided by the use of a chess engine) against the computer in Adept mode (that's the highest level at which I have discovered that I can stay in the ring and give as good as I get). I had managed to build an impressive material advantage, and a careful exchange of pieces would have left me with a hopefully easy-to-win end game.

I guess I could have continued the game with the still-present (albeit diminished) material advantage, but knowing the bastard that is the computer, it would have worn me down into committing another blunder shortly. That's the problem with playing against an emotionless automaton.

Wednesday, March 29, 2017

March 29, 2017

I wrote up pLisp into a paper and submitted it to ELS17, but the paper didn't make it. However, I got a lot of valuable feedback, chief among them being "Why the f&*k are you rolling out your own GC, with no benefits in terms of latency, efficiency, etc.?"

Well, the autodidact that I am, I didn't realize at the time of working on the GC bits that things like the Boehm Garbage Collector exist (I was stupidly happy, waxing eloquent about the wonders of posix_memalign() then -- God, how naive were we), and that migrating to the Boehm GC just entails replacing all malloc() and realloc() calls with GC_MALLOC() and GC_REALLOC(), and removing the free() statements. It was just a matter of a half a day's work, and now the code is free of all the inefficient mucking around with hashtables and Red-Black trees.


Tuesday, February 21, 2017

February 21, 2017

pLisp has been ported to OS X. This was surprisingly straightforward, for a couple of reasons: a) OS X, once the necessary bits are set up (mainly HomeBrew and jhbuild), is sufficiently close to Linux--at least for me--to make the porting a breeze and b) all the earlier hard work of migrating pLisp to autotools finally paid for itself.

The main gotcha for me was adding missing function declarations (this is probably an artifact of using a higher version of gcc in the Mac system, and not because of some inherently OS X thing). After spending a significant part of the porting effort for this, the key takeaway for me is to not ignore compiler warnings. This will save you  a buttload of trouble, trying to wade your way through seemingly unrelated runtime errors (while it's easy to preach, I'm still guilty of this sin, as a compile of the pLisp code base will readily demonstrate).

Tuesday, January 10, 2017

January 10, 2017

While the "Elderly Catholic woman has mistakenly been praying every day to Elrond from 'Lord of the Rings"' story manages to sound more hilarious each time I come across it in my news feed, there is a deeper truth behind this, from a magic/occult perspective.

Though I have been interested in mysticism and all things occult for a long time (it all probably stated with The Tao of Physics), it took my discovering John Michael Greer's writings--in particular, his Well of Galabes blog--to acknowledge to myself that there is something over and beyond what can be explained by science and sensed by us through our, well, senses.

I can't really point to any single extraordinary incident that tipped me over to the other side, so to speak, it's more of a retrospective 'audit' of the things that happened over the last week, month, year, and so on, an audit that reveals interesting patterns, a balancing or settling of accounts if you will. Karma and cause and effect and all that.

Anyway, at the risk of sounding woo and cryptic, let me just say that the phrase 'Change in consciousness according to will' seems to be a good place to start.

Oh, and I have my own banishing ritual now, based on the pantheon of our deities.

To take the original thought that kicked off this post to its conclusion: the elderly catholic woman, in all probability, reaped the same benefits that she would have reaped had she been praying to a statue of the actually-intended saint. And no, I don't mean this in a facetious sense.

P.S. Reddit has an occult sub. Don't forget to check out the Illustrated Beginners Guide to Chaos Magic.


Friday, December 30, 2016

December 30, 2016

In the brave new post-demonetization world of cashless transactions and the RBI's clueless/tone-deaf exhortation to citizens to use digital payments to "enhance the experience of living in the digital world", it was ironic that plastic money worked mid-air during travel to/from Andaman, but not on the ground at any of the islands' hotels and restaurants. Guess they are yet to get the memo. Things were so (for want of a better word) cash-and-carryish at one of the places that there is no record (financial or otherwise) that we had even set foot in the premises; everything is settled on the spot that there is nothing to do at checkout time except to wave goodbye to the folks at the hotel reception.

Staying on the subject of Andaman and Nicobar: an excellent holiday destination, a big contrast from the eyesore that is Chennai (apart from the cleanliness, what strikes you is the near-total absence of any political symbols; no party flags, no posters, no mugshots of the local goons adorning cheap flex banners everywhere you turn).

Wednesday, November 09, 2016

November 9, 2016

I am not one to toot my own horn, but what the hell. I predicted exactly this a year ago:



I'll be over there in my corner, smoking my pipe in my armchair. Those with offerings and other goodies, please queue up and be orderly, everybody will get their turn.

Sunday, October 16, 2016

The BS Economy

Yesterday I got my aging tablet's screen protector changed. What should have been a simple and quick visit to a mobile phone outlet turned out to be not so simple after all; I had to visit four such places before I could get this done. At each of the first three outlets, the response was that such services were not done there.

All of these outlets are located in a mall, one of the so-called trendier and happening ones in the city. You know how things are with malls: a lot of people strolling about, crowds at places like food courts and theatres, and most of the empty shops filled with bored salespeople with nothing to do but entertain themselves with fantasies of how they would like to push the strolling folks over the walkway rails.

The key word here is 'salespeople'; people who are trained to sell the stuff (I'm being quite generous with the word 'training' here), and nothing else.

There is a lot of talk about value-creation, moving up the value chain and so on, but this doesn't seem to translate very well into practice. We still have college graduates being churned out in their thousands every year, with degrees that are worth less than the paper they're printed on, with no real skills (and no, 'I have excellent communication skills and am a team player' is not a skill, even allowing for the invariable resume embellishment). The three or four years--don't get me started on engineering degrees--spent on getting a degree would have been much better spent in acquiring real skills like learning how to fix a car, cook a mean baingan bharta, or build a cabinet for a home entertainment system.

Or change the screen protector for a tablet.

Friday, September 09, 2016

September 9, 2016

Yeah, that about describes him perfectly:
If there was a fortune to be made at the bottom of a sack of shit, Blair would dive in head first (having been given a helpful push by his wife).
I have written about this before, but it's time to remind folks that there is another side to the story, in light of all the clueless people at the letters to the editor section at The Hindu who insist on rhapsodising about her sainthood:
What the hell, might as well throw this and this in as well.
***
Here's a pro-tip for the web developers working on the payment gateway module of our venerated public sector utilities (BSNL, if I'm not mistaken): when your message to the payment gateway is acknowledged to have been processed successfully, your response should be a matter-of-fact 'Yup, got it'. You should not display a 'Congratulations! Your payment has been processed successfully!' message to the user, conveying the impression that everyone at the backend were keeping their fingers crossed, and let out a collective sigh of relief that things worked out well after all. Doesn't inspire much confidence, folks.

Wednesday, August 31, 2016

August 31, 2016

Quick pLisp update: pLisp is now much more liberal with respect to symbol names: almost any character is acceptable, except for ten or so 'special' ones like backquote, comma, double quotes, and so on. This has resulted in the added benefit of doing away with things like LET1 and CALL-CC and going with the more standard LET* and CALL/CC.  Also, built-in functions like + and CAR can now be used wherever user-defined functions can be used, e. g., as arguments to APPLY and FUNCALL. This was achieved by creating user-defined wrapper functions for the built-ins; profiling indicates that there isn't much of a performance hit because of this additional indirection.

Monday, July 18, 2016

July 18, 2016

Well, the Turkey coup has fizzled out. I was initially rooting for it to succeed, but the ramifications would have been worse if it had, at least globally, and Erdogan's recent peace overtures to Russia would have been undone. But spare a thought for the poor soldiers: you are ordered to take your tanks to the streets, probably being told it's just a drill, you encounter protesters on the streets who, well, protest, and you hold your fire in spite of the provocations; realizing the true situation, you surrender to the civilians, and end up suffering indignities such as getting beaten up, or, even worse, lynched. And, if you haven't been lynched, probably facing a death sentence anyway.

Pop quiz: how do you put together, in a span of 24 hours, a list of 2700 or so judges who were involved in the coup attempt? Answer: You don't, you simply pull out the list of dissidents you had put together in the preceding weeks and months and use the Allah-given opportunity to get rid of them.

The Hindu chimes is as usual with its hemming and hawing. My late father--and others of his generation--had a colourful Tamil phrase, vazha vazha kozha koza (wishy washy), to describe The Hindu. The paper is still living up to this deserved reputation.

Speaking of The Hindu's opinions, I've always been at a loss as to how best to characterize this, notwithstanding the above apt phrase. Then it hit me: Grand Maester Pycelle in The Game of Thrones. Picture Pycelle speaking the words from The Hindu's editorials in his querulous and quavering voice, with liberal usage of "On the one hand..." and "On the other hand...", and you'll see what I mean.
***

It was bound to happen, and it did. The lemmings are at it again, this time it's Pokemon Go. The craze in the west is understandable, sort of: kids who grew up with Pokemon in the 90s are now young adults with disposable incomes, and Pokemon Go is a way for them to reconnect with the past. What's the lemmings' excuse?

Friday, July 01, 2016

July 1, 2016

Must-watch interview of Mark Blyth. You know we as a species are fscked when a video like this has only 12,534 views while Gangnam Style exposes overflow problems in the hits counter variable. The money shot (even better to hear it from the man himself, with his charming--Scottish?--accent):
...It's not going to sustain itself. So, you know the Germans have this thing that we don't want it to become a transfer union. What do you think you're in? Right? At the end of the day, you're transferring labour, skills, responsibilities, it goes with the gig. And you did an undervalued exchange rate by having your super-efficient economy buried in all these less-efficient economies so that you can sell more BMWs to the Chinese.
And this has relevance to what I mentioned yesterday about allowing malls to be open 24 hours a day (as in, this is the argument you should be using, and not the dishonest and cynical stuff):
Here's the problem: What do you mean by reforms? Some abstract notion that you should get into the pharmacy monopoly. Let's fuck pharmacists. I can now buy my meds over the counter in a supermarket which got deregulated hours so it's cheaper so we can all buy drugs at ten o'clock at night. Please tell me how that invigorates an economy that has lost 30% of its GDP. This is a fantasy.

Thursday, June 30, 2016

June 30, 2016

(Warning: Game of Thrones Season 6 spoilers)

Well, Season 6 of Game of Thrones is over. This is easily the best season so far for me, notwithstanding the WTFs involving Arya's Braavos escapades and Dany's crappy plot line. To be fair, I watched seasons 1 to 4 in more or less binge mode (bless you and RIP, Show Box), so I may be wrong. The post-premiere discussion megathreads at reddit are the place to be after watching the episode, where you get to experience the depth of emotions people exhibit for having R+L = J confirmed for them after waiting for 20 years and also some hilarious comments ("Lancel should have crawled zig zag" and "Tommen took the name 'Kings Landing' too literally").

Episodes like "Battle of the Bastards" and "Winds of Winter" are always better appreciated on the second viewing; half of the first time is spent in nervousness/dread, wondering what unexpectedly crappy thing is going to happen next. The second time you're more relaxed, knowing what's coming next, and are also on the lookout for the minor but important details you missed the first time (pointed out helpfully in the relevant reddit thread).

On a related note, I started watching The Walking Dead, and after two episodes I can't for the life of me figure out why it's held in such high regard; bad acting, bad editing, cliches all over the place, you name it. Maybe GoT has spoiled me, but things better start looking up in the next episode or two.

***
"Family life" my ass:
CAIT national president B.C.Bhartia and Praveen Khandelwal maintained that allowing shops and establishments freedom to operate on a 24/7 basis would have a detrimental impact on the traders. Their case is that it would have repercussions on law & order, environment, health, social and family issues.
Why not be upfront about the real reason, i.e., "Our business and profits will be at risk if this act is passed"?

*** 

pLisp has been ported to 64 bit. I thought I had already taken care of potential 64 bit issues, but boy was I wrong. The things that bite you in the ass are not the obvious gotchas like unsigned ints that were used to hold pointer values, but stupid effing stuff like missing function prototypes which screw you over in oh so unexpected ways. Nah, I'm not bitter at all, why do you ask?

Tuesday, May 10, 2016

May 10, 2016

In case you wanted any more proof of the way the markets are decoupled from fundamentals and are dependent (*ahem* coupled) on happenings elsewhere:
Sentiment was supported by lower-than-expected U.S. April non-farm payroll numbers, as it meant the Fed would take longer time [sic] to raise interest rates.
That's right, there's bad news on the economic front in the US, so their central bank is going to defer the rate hike, so it's good news for the Indian stock market because it's good news for the American stock market because of the continued maintenance of higher liquidity conditions there. Or, is it that the rate hike deferral means that emerging markets continue to be attractive to overseas investors? I don't know man, by now I don't know whether I'm coming or going.

Saturday, April 30, 2016

April 30, 2016

After a lot of false starts, I managed to port pLisp to Windows. Long story short, it took the MinGW GTK+ and GTKSourceview packages and the MinGW compiler--in Cygwin--to get things to work. The Windows version is shipped pre-compiled (for 32 bit right now); you just need to unzip the files to a directory of your choice (in addition to installing the aforementioned MinGW bundles).

Since we have all the bases covered (POSIX and Windows), pLisp has now been formally introduced to the rest of the world. Some very useful feedback and bug reports from the r/lisp community, thanks folks.

Monday, April 04, 2016

April 4, 2016

Excerpt from the Indian angle to the Panama Papers:
MF records list Indira as a shareholder in Stanbridge Company Ltd, which was incorporated in 1999 in the BVI. Records show that shares of the older couple were transferred to their daughters in 2011 and eventually, in October, 2011 Malika Srinivasan relinquished her shares “for personal reasons” to one Ved Prakash Ahuja. They also show that shares of another BVI entity, Auto Engineering Development and Research Limited, were transferred to Stanbridge. MF records show the company was struck off the records in September 2015.
Response: Mallika Srinivasan stated: “I wish to clarify that I did not set up any offshore company and have no connection with Stanbridge Company Limited. It belongs to Mr V P Ahuja, an NRI…”
- See more at: http://indianexpress.com/article/india/india-news-india/panama-papers-india-part-1-list-garware-shishir-k-bajoria-harish-salve/#sthash.sR7w21QE.dpuf
MF records list Indira as a shareholder in Stanbridge Company Ltd, which was incorporated in 1999 in the BVI. Records show that shares of the older couple were transferred to their daughters in 2011 and eventually, in October, 2011 Malika Srinivasan relinquished her shares “for personal reasons” to one Ved Prakash Ahuja. They also show that shares of another BVI entity, Auto Engineering Development and Research Limited, were transferred to Stanbridge. MF records show the company was struck off the records in September 2015.

Response: Mallika Srinivasan stated: “I wish to clarify that I did not set up any offshore company and have no connection with Stanbridge Company Limited. It belongs to Mr V P Ahuja, an NRI…”
MF records list Indira as a shareholder in Stanbridge Company Ltd, which was incorporated in 1999 in the BVI. Records show that shares of the older couple were transferred to their daughters in 2011 and eventually, in October, 2011 Malika Srinivasan relinquished her shares “for personal reasons” to one Ved Prakash Ahuja. They also show that shares of another BVI entity, Auto Engineering Development and Research Limited, were transferred to Stanbridge. MF records show the company was struck off the records in September 2015.
Response: Mallika Srinivasan stated: “I wish to clarify that I did not set up any offshore company and have no connection with Stanbridge Company Limited. It belongs to Mr V P Ahuja, an NRI…”
- See more at: http://indianexpress.com/article/india/india-news-india/panama-papers-india-part-1-list-garware-shishir-k-bajoria-harish-salve/#sthash.sR7w21QE.dpuf
You really have to hand it to the 1%, the response is a masterclass in staying on the right side of truth while projecting an air of innocence (assuming they're not brazening it out on the assumption that nothing will come of the whole thing). "...I did not set up any offshore company" (doesn't preclude a registered agent setting it up for her), "...have no connection with Stanbridge Company" (again doesn't preclude having had a connection) and "It belongs to Mr V P Ahuja" (conveniently doesn't say whom it had belonged to).

Related must-read article. Also this, from 2014.

Staying on the subject of leaks, this is sure to bury the Unaoil leak. By the way, did you know that L&T was a beneficiary of a rigged tender process, courtesy of a Unaoil insider?
MF records list Indira as a shareholder in Stanbridge Company Ltd, which was incorporated in 1999 in the BVI. Records show that shares of the older couple were transferred to their daughters in 2011 and eventually, in October, 2011 Malika Srinivasan relinquished her shares “for personal reasons” to one Ved Prakash Ahuja. They also show that shares of another BVI entity, Auto Engineering Development and Research Limited, were transferred to Stanbridge. MF records show the company was struck off the records in September 2015.
Response: Mallika Srinivasan stated: “I wish to clarify that I did not set up any offshore company and have no connection with Stanbridge Company Limited. It belongs to Mr V P Ahuja, an NRI…”
- See more at: http://indianexpress.com/article/india/india-news-india/panama-papers-india-part-1-list-garware-shishir-k-bajoria-harish-salve/#sthash.sR7w21QE.dpuf
MF records list Indira as a shareholder in Stanbridge Company Ltd, which was incorporated in 1999 in the BVI. Records show that shares of the older couple were transferred to their daughters in 2011 and eventually, in October, 2011 Malika Srinivasan relinquished her shares “for personal reasons” to one Ved Prakash Ahuja. They also show that shares of another BVI entity, Auto Engineering Development and Research Limited, were transferred to Stanbridge. MF records show the company was struck off the records in September 2015.
Response: Mallika Srinivasan stated: “I wish to clarify that I did not set up any offshore company and have no connection with Stanbridge Company Limited. It belongs to Mr V P Ahuja, an NRI…”
- See more at: http://indianexpress.com/article/india/india-news-india/panama-papers-india-part-1-list-garware-shishir-k-bajoria-harish-salve/#sthash.sR7w21QE.dpuf

Thursday, March 31, 2016

pLisp File Browser

pLisp now has a File Browser too, for those who are not so enamoured with image-based development:

It's pretty much bare-bones functional; you can open, edit and save files (it's multi-tabbed, so simultaneous handling of multiple files is supported). The programming-specific features are the bells and whistles that are carried over from the Workspace: evaluating expressions, syntax highlighting, autocomplete, parens-matching, and context-sensitive help both via the F1 key and displaying function signatures in the status bar.

Friday, February 12, 2016

February 12, 2015

I think the government must be really desperate regarding the prospects of our economy to propose something like this. Use the money set aside for a rainy day (provident /prɒvɪd(ə)nt/ adjective - making or indicative of timely preparation for the future) and use it to, I don't know, buy a smartphone just so that demand picks up and the stock market starts rising again and the the folks with disposable incomes which go into SIPs can continue to breathe easy that their futures are secure (note that such folks will know better than to forgo their provident fund contributions and spend the money on useless junk instead).
*** 
 What's happening @Twitter? We wouldn't be talking about this or arguing about Facebook's Free Basics if the same efforts towards coming up with vendor-agnostic standards like HTTP, FTP, etc. could have been devoted to social media and Web 2.0 (rinses mouth out with Listerine). Imagine a world where you can use any protocol-compliant software (or even the browser itself) to do all the sundry things people do (follow/like/poke/stalk) on Facebook and Twitter, without being beholden to evil companies?
***
Before taking Headley's statements too seriously, people need to remember that he's completely owned by the Americans, and he will say whatever it takes to fulfill their foreign policy objectives (stoke up more conflict between India and Pakistan, bail out the Indian/Gujarat governments in the Ishrat Jahan case, and so on). Not to mention the annoying thing called 'hearsay'.
 

Thursday, February 04, 2016

February 4, 2016

Weather forecast for Chennai in The Hindu from a couple of days ago (italics mine):
Light winds are expected. A partly cloudy sky over the district. A cheerful morning. A delightful afternoon. An easy night.
In this time of 'Make in India' and the focus on local employment generation, it is highly condemnable that The Hindu have outsourced their weather forecast production to crumpet-eating, tea-drinking, monocled gents enjoying the pleasant English summer at Blandings Castle. Harrumph.

Sunday, January 31, 2016

January 31, 2015

Well, the bulk of the pLisp development work is done, except for maybe pushing GC to its own thread. Guess I'll start writing about the full monty compiler bits. By the way, I had mentioned earlier that pLisp ought to work on Cygwin, but it looks like the Tiny C Compiler is yet to be successfully ported to Cygwin, so running pLisp under Windows is a non-starter for the time being.

Monday, December 21, 2015

pLisp Migrated to Autotools Framework

I take back the bad things I've said about autotools. My second shot at making pLisp portable was successful; if not fully in the portability aspects, at least in making it conform to the whole configure/make/make install paradigm (ironic really, since my main objective was to port pLisp to Windows, which has not been achieved yet. Well, it should work for Cygwin anyway).

There is a lot of material out there on autotools, but most of them are outdated or handle only trivial Hello World programs. As with life in general, you need to do your homework to separate the wheat from the chaff and to dig out information that's really relevant to you. David A Wheeler's Howto was the most useful one for me.

At the risk of this post turning into yet another autotools tutorial that adds to the noise, here are some general guidelines and tricks while using autotools (I'll be using pLisp as a case study):

First off, you need to handcraft two files: configure.ac and Makefile.am. The first file tells autotools various things about your project like the package name, version number, which tools (GCC, flex, bison, etc.) it uses, what package dependencies does it have, and so on. You will not spend much time with this file once you put in all this information (actually, there's one gotcha: when mentioning package dependencies, I had to do them for each package separately [a la PKG_CHECK_MODULES([gtk], [gtk+-3.0 >= 3.4.2])]; for some reason, using DEPS_CFLAGS and DEPS_LIBS didn't work for me, and I had to build AM_CFLAGS and AM_LIBS from the individual variables as below:

AM_CFLAGS = ${gtk_CFLAGS} ${gtksourceview_CFLAGS} ${libffi_CFLAGS}
AM_LIBS = ${gtk_LIBS} ${gtksourceview_LIBS} ${libffi_LIBS} ${LEXLIB}


)

In contrast to the short amount of time you devoted to configure.ac, be prepared to really duke it out with Makefile.am. The final version of Makefile.am for pLisp is only about 40 lines long, but each of those lines has its own story of blood, sweat and tears.

The rest of this post will be in the form of inline comments interspersed with Makefile.am lines.

AM_YFLAGS = -d
This line tells autotools that we want to include the -d flag in the call to bison. Needed because we want bison to generate a header file containing all the useful symbols like yyin, yyparse, and so on.

all:    ${bin_PROGRAMS} ${lib_LTLIBRARIES} help.html
This sets up the targets that need to be built: pLisp needs a binary as well as a library (.so) to be built, and also a language reference HTML, which is generated automatically from a JSON data file.

bin_PROGRAMS = plisp
plisp_SOURCES = ...

Here we list the binaries to be built, and for each binary specify the sources. Note that we simply list all the sources--including header files--and let autotools automatically take care of the dependencies. Extremely nifty feature.

noinst_PROGRAMS = docgen
docgen_SOURCES = tools/docgen.c src/util.c src/util.h src/json.h src/jsonlib.c src/json.l src/json_parser.y
The prefix 'noinst' indicates that these targets need to be built but not deployed. docgen is one such internal program; it generates the above-mentioned language reference HTML file, and it's work is done. Forever. The next line lists the sources needed to build docgen.

Since we're talking about source files, this is as good a place as any to say this: do not name your flex source files with a '.lex' extension; autotools will barf on them, i.e. refuse to invoke flex on them. The extension has to be '.l'.

AM_CFLAGS = -DDATADIR=\"$(pkgdatadir)\" ${gtk_CFLAGS} ${gtksourceview_CFLAGS} ${libffi_CFLAGS}
AM_LIBS = ${gtk_LIBS} ${gtksourceview_LIBS} ${libffi_LIBS} ${LEXLIB}

These two lines set the preprocessor and linker flags at the global level. You can also set them at a per-target level, like plisp_CFLAGS = ...

ACLOCAL_AMFLAGS = -I m4 --install
I really don't know much about this line, except that it is required to make use of the m4 directory (courtesy the Wheeler tutorial referred above).

plisp_LDADD = ${AM_LIBS} -ltcc
This line sets the libraries needed for the plisp binary; in addition to the global libraries, we also specify the Tiny C Compiler library. Required because tcc doesn't follow the pkg-config framework.

lib_LTLIBRARIES = libplisp.la
libplisp_la_SOURCES = src/plisp_utils_ffi.c
libplisp_la_LDFLAGS = -version-info 0:0:0

These three lines build the 'libplisp.so' shared library. That's the extent of my knowledge of the matter, my lord.

pkgdata_DATA = data/plisp.lang data/help.json lib/plisp_full_monty_compiler.lisp
dist_doc_DATA = doc/help.html doc/pLisp_User_Manual.pdf
iconsdir = $(pkgdatadir)/icons
icons_DATA  = icons/abort.png ...

Now this is where the power of autotools really shines through: pLisp, like any application worth its salt, has a bunch of resources that are needed for correct operation. These resources range from the plisp.lang file needed by GtkSourceView to do syntax colouring to the PGN files needed for the icons in the application toolbars. These four lines take care of generating the makefile commands that copy these resources from their respective locations in the source directory hierarchy to the user-specified directory (when she runs './configure') without us or the source code being aware of any of these shenanigans. Truly magical. Hyperbole aside, how this is accomplished is much more mundane: if you look at the AM_CFLAGS definition above, you'll notice the -DDATADIR flag; this flag is set to the package data directory (typically /usr/local/share/plisp), and is used in the source code [e.g. gtk_image_new_from_file(DATADIR "/icons/load_file.png")] to abstract away the location of the resource file.

src/json.c:    src/json.l
    $(LEX) --prefix=json -o src/json.c src/json.l
src/json_parser.c:    src/json_parser.y
    $(YACC) -d -v --name-prefix=json src/json_parser.y -o src/json_parser.c

And that brings us to the primary reason for all the blood, sweat and tears alluded to above: the inability to handle multiple lexers/parsers within the same program. pLisp uses flex/bison for two things: a) to parse the Lisp source code entered by the user (or fed from a file) and b) to parse the JSON strings used for representing both pLisp images and the online help content. When I was using a handcrafted makefile, I could keep the flex/bison symbols (yyin, yylval,  yyparse) separate by using different name prefixes in the individual makefile rules. The only way to get the same behaviour in autotools seems to be to specify the same rules manually. Goes against the philosophy, but there doesn't seem to be any other way to do this.

help.html:    docgen
    ./docgen

This use of a manual rule is justified, since this is an application-specific thing to generate the online help file.

And we're done with Makefile.am.

Some odds and ends:

1. You will need to create a bunch of dummy files at the project root: AUTHORS, NEWS, COPYING, ChangeLog, etc. Also create a directory called 'm4' with a dummy file in it (e.g. NOTES, as suggested in the Wheeler tutorial).

2. Create a script called autogen.sh with just a single line 'autoreconf --install || exit 1' in the project root as well, and run this script to process any changes you've made to configure.ac and/or Makefile.am

3. You need to store configure.ac, Makefile.am, and the files mentioned in #1 and #2 above in your version control system.

Tuesday, December 15, 2015

December 15, 2015

Random thoughts on the recent Chennai rains:
  1. Let's get the unpleasant stuff out of the way first: notwithstanding all the talk about Singara Chennai, there is a reason (well, reasons, to be more accurate) that the phrase 'third-world shithole' keeps getting thrown around when it comes to Chennai in particular and India in general. Overcrowding, lack of public hygiene and civic sense, corruption, unregulated and illegal growth, you name it. All this is business as usual, but when something like a once-in-a-hundred-years flood occurs, the rottenness of the system is there for all to see. There are folks who still harbour love for the city in their hearts, of course, but there are two aspects to this: one is the affection and familiarity one feels towards their favourite childhood haunts, the neighbourhood they grew up in, and so on, while the other pertains to the truly beautiful things the city is known for. The first is operative mainly because of the strong sense of nostalgia that glosses over all the squalid bits, while we're fast running out of things in the second category (if you are a regular reader of S. Muthiah's column in The Hindu, you can't help but notice that said beautiful things were all the creation of people who left us at least thirty to fifty years ago).

  2. People will be people. In particular, good people who feel sympathy for others' suffering will help them, while not-so-good people will try to take advantage of others' misery. You therefore have folks wading through waist-deep water, risking their own safety to reach out to people who need help, and also those who take this opportunity to loot homes abandoned because of the flooding, and who jack up their auto fares to take advantage of people's predicament (on a related note, the most apt icon/mascot for Singara Chennai would be a snarling autorickshaw driver). While the outpouring of goodwill during the crisis was indeed admirable, expect good old reversion-to-the-mean to kick in shortly, if it hasn't already. By the way, there are Facebook stories doing the rounds in which one hears that motorists' driving behaviour has become more patient and courteous; these are either made-up crap like the Chickenshit for the Soul stories, or are one-off anecdotes.

  3. At long last I found some use for social media. Nothing like Twitter to bring to you instantaneous pictures of the flooding around your locality and thereby saving you from an injudicious route choice. Newspapers were practically worthless (if you manage to get hold of them, that is), with their lagging-by-eight-to-twelve-hour coverage. Even their Twitter feeds were not as useful as citizen-journalists', probably because of their need to curate what they put out.

  4. If I were made dictator, one of my first acts would be to can the entire meteorological department and replace it with two things: a) a subscription to the high-fidelity Accuweather satellite data and b) a Python script that does ARIMA. Enough said. Oh, by the way, that Ramanan guy is definitely trolling everybody (vittu vittu mazai peyyum, sila idangalil mazai peyyum).

  5. Some practical advice for what to do if you're caught in such a situation in the future (notwithstanding the tendency to attribute all such extreme weather conditions to global climate change, I think it's unlikely that this will recur in the next five years):
    1. Always keep at least Rs 5000 in cash with you in the house. Cash is king in such times. Also, rotate the money every six months. You never know when the government will get serious about black money and declare that all old currency notes--especially 500 rupee notes--are no longer legal tender.
    2. Wean yourself from milk. Unless you're a baby, of course. People complaining about no milk during these times makes me shake my head. You can always stock milk powder.
    3. Potatoes and onions don't need refrigeration. In general, keep a stock of provisions to last you at least a week. And don't forget batteries. Lots of them.
    4. This is a bit of an overkill, but battery-operated amateur radio is a great way to communicate when the cell towers give out.
    5. When you still have your wits/senses about you, make a list of important stuff to take with you when you need to evacuate. Otherwise you will end up carrying out worthless stuff like, I don't know, dosai maavu, while leaving behind a pile of black money for the looters to find when they come calling (true story).
    6.  Make a hard copy of all the important phone numbers in your address book and keep it in your wallet. You never know when you might need to call somebody from another person's phone because yours ran out of juice.
    7. And last but not the least, learn swimming.

Monday, November 30, 2015

November 30, 2015

A quick update about pLisp: the full monty compiler is done, I'm in the process of updating the documentation (online help [i.e. within pLisp instead of taking the user to the language reference HTML] and autocomplete). I am also tempted to add a 'references' feature which will show the list of all the code that refers to a particular top-level symbol; this is not to difficult to implement, though there may be some false positives because of lexical variables with the same name).

Thursday, October 22, 2015

October 22, 2015

From John Michael Greer's latest Retropia installment (italics mine):
It was an interesting ride, in an odd way. I travel a lot, like most people in my line of work, and I’ve ridden top-of-the-line automated light rail systems in New Beijing and Brasilia. I could tell at a glance that the streetcar I was on cost a small fraction of the money that went into those high-end systems, but the ride was just as comfortable and nearly as fast. There were two employees of the streetcar system on board, a driver and a conductor, and I wondered how much of the labor cost was offset by the lower price of the hardware.
Leaving aside the argument of whether automation and technological advances are going to lead to large-scale unemployment, I'm going to focus on more practical things -- namely, traffic signals. There is a signal at an intersection on my daily commute that's not been working for, I don't know, at least a couple of years (its work is being done by its smaller sibling that is barely visible among the various obstructions that the Chennai road landscape is known for, but that's another story). The most likely reason for this organizational apathy and, possibly, lack of funds. Now things are only going to become worse from here on, with the global economy marching firmly down the deflationary path, and purse strings are unlikely to be loosened locally either, once we too are caught up in the downward spiral.

Well, what was my point? Lost sight of it there for a moment. My point is that technological solutions, automation, and in general the whole smart/intelligent movement will not solve our problems, especially in a country like India where the environment is harsh and hostile to equipment like traffic signals and other electrical equipment open to the elements (leave alone sophisticated things like automatic urinal flushes that detect that you're done with your tinkling and flush away the output of said tinkling [I've always been wary of these things; what if, due to a bit flip caused by a speck of dust in the wrong place, it decides to reverse the flow and dump on me the aggregated output from the previous four users of the system?]). In such an environment, it makes more sense to put warm bodies to work; in the case of traffic signals, this means having policemen direct the traffic manually (and intelligently to boot, using their own grey matter; I know that algorithms have shown how effective they are at achieving, ahem, globally optimal outcomes, but it's not an all-or-nothing thing; nothing precludes an intelligent program running in the protected environs of a climate-controlled data center from passing on advice to the policeman on the ground using, I don't know, a smartphone app. Note to self: fix appointment with $CLUELESS_GREEDY_VC to pitch idea for hot new traffic management startup).

***
Pop quiz: what's wrong with the following paragraph?
Although India was secularized at the official level, religion remained a strong force at the popular level. After 1990 some political leaders tried to benefit from popular attachment to religion by espousing support for programs and policies that appealed to the religiously inclined. Such efforts were opposed by most of the state elite, who believed that secularism was an essential principle of Nehruvian Ideology. This disinclination to appreciate religious values and beliefs gradually led to a polarization of society. The polarization became especially evident in the 2010s as a new generation of educated but religiously motivated local leaders emerged to challenge the dominance of the secularized political elite.
Well nothing in and of itself, except that I created it from another paragraph (hat tip to Mish) by replacing exactly four words (two proper nouns and two numbers). As Redditors would say, mildly interesting.

Wednesday, September 30, 2015

September 30, 2015

The report Sergey Glazyev prepared for the Russian Security Council (it's leaked text and purportedly contains deliberate injections of falsehoods, so take it with a pinch of salt). Expands on the interview I had mentioned earlier. Serious brain food. I have a good mind to put together the tables in Appendix 5 for India.

A pity the content at The Saker has become more and more diluted, with original analysis by Saker in what, one out of every twenty posts. Makes one miss out on stuff like the 'War on Syria: Not According to Plan' series by Ghassan Kadi. Mandatory reading for anyone who wants to go beyond the usual lame analysis (he could have avoided the use of 'NWO'  to talk about the post-1991 period, and also gone easier on the pro-Assad bits, but good stuff nonetheless).

Monday, August 31, 2015

Full Monty Compiler for pLisp -- Part 1: Overview

Before diving into the different phases of the compiler, it would be helpful to set out our overall goals and the context which the compilation process fits in.

Our guiding principles are:
  1. Retain as much of the current code base as possible
  2. Use the same object model, core library, grammar and primitives as currently exist in pLisp
  3. All top-level forms are to be compiled to native code (i.e. even simple, ad hoc expressions like (+ 1 1))
  4. Our goal (at least for now) is correctness and completeness; some of the code transformations are not optimal, but we're willing to go with them in the interests of keeping things simple
 As the compilation process moves through the different phases, we end up with simpler and simpler dialects of Lisp:


Not every transformation results in a new dialect; for example, both the input and output of the renaming transformation are in the 'pLisp_IL' dialect.

Onto the grammars for these sundry pLisp dialects (I'm skipping pLisp in the interests of laziness, except to say that it's pLisp_k + macros):

1. pLisp_k

The 'k' stands for 'kernel', as in the core language we're left with once all the macros have been expanded/desugared.

exp ::= literal
    | var
    | (if exp exp exp?)
    | (primop exp+)
    | (lambda var* exp)
    | (error exp)
    | (call-cc exp)
    | (exp exp*)
    | (set var exp)
    | (let exp* exp)
    | (letrec exp* exp)

literal ::= integer | float | symbol | nil | t | character | string

variable ::= <check plisp.lex for the rule(s) defining variables>

primop ::= ' | atom | eq | cons | car | cdr | + | -

| * | / | progn| print | listp | symbol_value
| ` | > | gensym | setcar | setcdr | create-package
| in-pacakge | , | ,@ | expand-macro | apply
| string | make-array | array-get | array-set
| sub-array | array-length| print-string | create-image
| load-foreign-library | call-foreign-function | load-file
| consp | integerp | floatp | characterp | symbolp
| stringp| arrayp | closurep | macrop | continuationp
| format | clone | return| return-from | symbol
| symbol-name | unbind | newline | time | profile
| not | &lt; | &lt;= | >= | != | save-object | load-object
| export-package | env | eval 

2. pLisp_k_no_set

pLisp_k_no_set is identical to pLisp_k, except that there is no 'set' form:

exp ::= literal
    | var
    | (if exp exp exp?)
    | (primop exp+)
    | (lambda var* exp)
    | (error exp)
    | (call-cc exp)
    | (exp exp*)
    | (let exp* exp)
    | (letrec exp* exp)

 
(primops omitted from here on for clarity)

3. pLisp_IL

pLisp_IL ('IL' stands for Intermediate Language) differs from pLisp_k in two ways:
  1. There is no 'letrec' form
  2. A new construct 'let1' that desugars to 'let'. Functionally 'let1' is identical to Common Lisp's 'let*', but since our parser doesn't handle '*', we go with 'let1'.
exp ::= literal
    | var
    | (if exp exp exp?)
    | (primop exp+)
    | (lambda var* exp)
    | (error exp)
    | (call-cc exp)
    | (exp exp*)
    | (let exp* exp)

    | (let1 exp* exp)

4. pLisp_IL_CPS

pLisp_IL_CPS is the continuation-passing version of pLisp. I'll explain this in more detail when I talk about CPS conversion; for now, note two important constraints: a) 'let' forms will have only one binding and b) there are also restrictions on what can be 'lettable' expressions.

exp ::= (var val*)
    | (if val exp exp)
    | (let ((var le) exp))
    | (error exp)
    | (call-cc exp)

val ::= literal | var

le :: = literal | (lambda (var*) exp) | (primop val+)


5. pLisp_IL_Lift

pLisp_IL_Lift continues with the simplification further: the only forms permitted on the right hand sides of binding expressions in 'let' are variables, literals and primitive applications (also, the only permitted arguments to the primitive applications themselves are variables and literals).

exp ::= (var val*)
    | (if val exp exp)
    | (let ((var le) exp))
    | (error exp)
    | (call-cc exp)

val ::= literal | var

le :: = literal | (primop val+)


One form not included in these is 'define', used to create top-level forms. Strictly speaking, 'define' is handled outside the compilation process (though we need to call the compiler to compile and evaluate the expression whose computation should be mapped to the variable being defined).

Subsequent posts will talk in detail about the different phases.