(Guardian (UK) Via Acquire Media NewsEdge) In 1843, Britain's minister for education announced that every schoolchild in the country would henceforth be given obligatory lessons in the design and maintenance of locomotive engines. "Railways are the future," he said. "Trains are critical to our economic growth. If our children grow up ignorant of how to build and operate trains, they will be left behind in the global race."
Some commentators observed mildly that division of labour and expertise was a more efficient way to run a modern society. Everyone could get around on trains, but that didn't mean everyone needed to know how they worked. Yet the government was adamant. Children had to learn mechanical thinking, it insisted. The new world would be built on the philosophy of pistons.

Soon, unfortunately, the minister for education had to resign, after it was revealed that he had received enormous bribes from locomotive-engine manufacturers. Those companies, naturally, had been eager to get thousands of new workers trained for their own purposes at public expense. In the wake of this scandal, mandatory train-based classes rolled to a sad halt.

I just made all this up, of course, and the analogy with our modern mantra that all children must be taught how to program computers should not be interpreted too closely. In particular, I certainly do not mean to suggest that the current government is in any kind of corrupt relationship with Google, Facebook, Amazon, Apple or any of the other giant corporations who will profit handsomely from future generations of workers having been educated to their own specifications out of the public purse. Clearly no such corrupt relationship exists.

But then what are we to make of the fashionable view that writing "code" is a crucial skill not just for those who will work as software engineers but for everyone? As presented by the cheerleaders for Britain's "Year of Code" - among whose number one does not fail to find "software entrepreneurs" - the claim is that "computational thinking" is a novel style of intellection that will prove invaluable to future plumbers, painters, pugilists, prosecutors and podiatrists, as well as to developers of infuriating smartphone games featuring cute goggle-eyed birds.

Yet computational thinking is not new, and it is grounded in more fundamental disciplines such as mathematics, philosophy and linguistics. This, indeed, is one of the messages of Vikram Chandra's fascinating and often beautiful new book, a kind of techno-artistic memoir that is informed by his unusual double ability as both novelist and coder. (He supported himself through graduate school in America by programming.) One can imagine an impressionable educationalist reading it and suddenly deciding that modern programming courses are old hat and instead all children must now study Sanskrit.

Why Sanskrit? As Chandra relates, a 2,500-year-old text by the grammarian Panini on the rules of generating Sanskrit words is "the first known instance of the application of algorithmic thinking to a domain outside of logic and mathematics". This Sanskrit "machine" influenced Ferdinand de Saussure and others, and "modern linguistic theory, in its turn, became the seedbed for high-level computer languages". Indeed, "programmers who know Sanskrit sometimes claim that it would make the perfect programming language" itself. Thus, all small Britons should be forced to learn Sanskrit. QED.

That would at least be more humane than teaching them a coding language called "brainfuck", which from the example Chandra provides seems to do what it says on the tin, or another even more terrifying-looking mashup of recondite symbols known as Malbolge, "designed solely to be the most outrageously difficult language to program in". From Chandra's amusing explanation of one taxonomy of programming styles I identified myself as a low-level "Mort". Having taught myself BASIC as a child, I can now write HTML and CSS, and hack around in PHP a bit until my websites work the way I want, which means I am someone whose "primary job is to frobnicate widgets". (I love the verb "frobnicate", which is one of those coinages that needs no explanation.)
Chandra is brilliant at technical exegesis - explaining logic gates, or evoking the appeal of "object-oriented programming" - but he also casts a sceptical eye on modern coding culture, especially its generalised misogyny. (As he points out, the world's first computer programmers were all women, working on the US army's ENIAC machine in the second world war.) He does not directly address the question of whether everyone should learn to code, but does anatomise a parallel stream of modern pro-coding rhetoric - that software is art and that programmers should be respected as artists. No, Chandra insists. Art is art and code is code. Code has to function correctly, but when Chandra is writing fiction he seeks to "find perfection and then discover the perfect way to mar that perfection".

He might have added that, though some code in action can constitute art (eg certain videogames), the millions of lines of symbolic instructions themselves are not poetry. Perhaps the real reason frobnicators of social-media startups or enterprise applications seek artistic recognition, another writer mischievously suggests, is that "Great paintings . . . get you laid in a way that great computer programs never do." As it happens, Geek Sublime itself really made me want to read Chandra's novels, especially the one with the monkey. It is only unfortunate that no one involved in the book's production seems to have been aware that computer chips are not made of "silicone".

The conclusion here is that art and code are, as Stephen Jay Gould said of science and religion, non-overlapping magisteria. "Programmers need to claim the extraordinary nature of what they do," Chandra enthuses. "Code is uniquely kinetic. It acts and interacts with itself, with the world. In code, the mental and the material are one. Code moves. It changes the world." Yes it does - and so did trains. So too, even in this day and age, does literature, at least sometimes and a bit.

To order Geek Sublime for pounds 11.99 with free UK p&p call Guardian book service on 0330 333 6846 or go to guardianbookshop.co.uk.