The Great Programming Language Continuum; or why C++ is dying
The long term trends of TIOBE's programming language index tell a sad story for C++; it is on the decline. Once comparable to C in popularity, it has lost market share to a new breed of higher level languages. During the same period C's market share remained has retained its popularity. Why has such an old fashioned language thrived whilst C++, its more modern object oriented cousin, has begun to fade?
This is best explained by imagining that all programming languages live somewhere on a continuum between the lowest level language of all - Assembler - and what would be the highest level language of all if anyone could write an interpreter for it - Human speech. A small subset of the this Great Programming Language continuum ordered from low level to high level is
- Assembler
- C
- C++
- Objective-C, Go
- Java, C#
- Python, Perl, Php, Ruby
- Lisp
- ?
- Human Speech: Chinese, Spanish, English, . . .
Many languages are missing from this list, but it paints the correct picture. As you descend the list, direct commands to the processor are replaced by conceptual abstractions and the source code will reflect the problem being solved more than it will the instructions the computer must execute to solve the problem. Code written in a higher level language tends to be easier to read, shorter and quicker to write than code in a lower level language, but the resulting program almost invariably runs more slowly. When choosing a language for a problem a programmer must balance the performance of the resulting software against the time it will take to write that code.
Law of lazy Coders: Programmers will always code in the highest level language possible
The higher level the language you write your software in, the fewer lines of source code you will write, and in most cases, the faster and cheaper it will be to build that program. For these reasons, real world time and cost constraints force the majority of programmers to choose the highest level language possible when starting a project.
The highest level language possible is usually determined by the hardware. In the early nineties performance considerations mandated that desktop applications like spreadsheets and word processors could only be written in C. As CPUs sped up during the nineties, C++ and then Java became good alternatives for this class of application. With today's lightning fast batch of processors and high performance JIT compilers, even a dynamic language such as Javascript is an option.
C++ was popular for writing desktop software in the nineties, because the answer to the question what is the highest level language I can write a good spreadsheet in? was C++. During the noughties, advances in processor technology changed that answer to C# or Java, and programmers quickly migrated to friendlier, garbage collected languages with large standard libraries.
C has retained its popularity because the answer to the question what is the lowest level language I can code in without using assembly has always been C, and it is unlikely to change. For those who cannot afford any latency in their code, whatever the cost to the programmer, or who need to plug into the lowest levels of the operating system then C is, and will remain, their language of choice.
Haskell is interesting to me because it is tough to definitively place it on the continuum. Its native compilation and static typing make it low level when compared to its distant functional cousin, LISP. However, lazy evaluation, Algebraic data types are characteristics of a much higher level language. This is the magic of Haskell. Idiomatic Haskell knits together high level and low level aspects with Monads.
Take, for example, Parsec, a Haskell library for building parsers. Parsec itself handles low level string manipulation and wraps this in the high level Parsec monad to define a Domain Specific Language perfect for parsing. With this DSL defined, writing an actual parser is criminally easy. Take the following example of an if statement in BASIC. You can see how the ifstatement parser is constructed naturally out of parsers for smaller elements of text.
ifstatement = do
wspaces
string "IF"
wspaces
cond <- condition
wspaces
string "THEN"
wspaces
eol
blk <- block
wspaces
string "ENDIF"
wspaces
eol
return (EIf cond blk)
C++'s decline will continue. Hardware advances will continue to make its efficiency redundant and Domain Specific Languages are nudging the principles of functional programming into the mainstream. Like world peace and lower taxes, we have learnt to distrust the promise that functional programming is about to spring into the software industry's cube farms. Nevertheless, even conservative programmers have come to trust Linq, a dataset DSL for C#.
Posted on 20 Jan 2013

Slide to code blog is licensed under a Creative Commons Attribution 3.0 Unported License.
Based on a work at http://slidetocode.com/blog/.
Five days in Egypt in September
Saturday
My most indelible memory of Cairo airport is the tennis court sized poster of Obama that greeted us in arrivals. Alongside Obama's face was a quotation from him testifying that the Egyptians are America's friends in the middle east. This was the start of our five days in Egypt, but Cairo airport is neither more Egyptian than London Heathrow, nor less English. Our trip began for real when I opened the taxi door into the humidity, the noise, the lights and the chaos of Talaat Harb street at 11pm.
The taxi driver guided us through the food stands and the street sellers, past a jewellery shop into a tall courtyard off the street to where a bright "Bella Luna Hotel" sign pointed into a forbidding entrance hall. When built, the colonial era staircase in that entrance hall could have belonged to a palace, but today, with worn granite steps, no lights, few repairs and no paint or decoration other than a layer of dust this staircase could equally have led to hell. Fortunately it didn't, and five flights of steps later we arrived at the Bella Luna Hotel's bright reception hall, and our bed for the night.
Sunday
In the morning we left our hotelier to "make connections" regarding our travel to Luxor later that day and we set off for the pyramids. Two things stood out from this visit: the scarcity of tourists, and the intense hassle. Considering that the Great Pyramid of Giza has been on every traveller's must-see list since Herodotus immortalised it as one of his Seven Wonders I expected the Giza plateau to be awash with admirers, but it was empty. Empty, but not calm, for with few tourists the guides and hawkers were scrambling over those of us who were there.
I wish I could say that the pyramids had gained meaning for me as testament to the power of one of the world's greatest civilisations, or even as a monument to man's vanity, but on that day they were merely a big pile of rocks that provided shade as we swatted away panhandlers, "egyptologists" and even Egypt's tallest policeman. This crowd of hucksters is the only detail of the pyramids that cannot be seen from afar, and I would advise you not to approach closely enough that you ever experience it.
Tiring quickly of the hassle we returned to central Cairo to browse the Egyptian museum's vast collection of artefacts. The collection is so big that during three hours we walked past no more than a third of their displayed collection. The displayed artefacts are only small part of their full collection, most of which resides in the basement. When leaving I realised that whether I had spent another hour or even another week in the museum I would still have left having seen just a small fraction of their collection. In fact I am told that if one were to spend a minute on each piece on display it would take nine months to see them all, and one minute is not enough time in which to do justice to a five thousand year old, intricately hieroglyphed and highlighted sarcophagus.
Upsettingly, these artefacts are neither properly cared for nor curated. The few objects that are encased and marked carry peeling and browned labels that look as old as the artefacts they describe. Most objects, however, are unprotected from either the climate, light or the wandering hands of tourists. Undoubtedly the British Museum's possession of illegally expatriated artefacts is wrong, but so is such neglect of historical treasures. So much so, that after visiting the Cairo museum I was in doubt for the first time that it is best for western museums to return to Egypt the stolen historical treasures they contain.
That evening we returned to Giza to catch the sleeper train south to Luxor in order to see the lavish tombs in the famous Valley of the Kings. You can trade this ten hour train journey for a seventy minute hop in an airliner, but I have no idea why you would. You would miss the romance of being rocked to sleep in your cabin by the twists and turns of the Egypt Railways number 82 train as it charges through the night down the Nile valley. Sleeper trains provide a sense of adventure without the discomfort of a real adventure. Until someone builds a space rocket with a jacuzzi, an overnight train remains the classiest mode of travel, and this trip from Giza to Luxor is an unmissable experience if you ever find yourself in egypt.
Monday
Never was Egypt's problem with urban hassle more apparent than outside Luxor train station. We fought through a crowd of agressively helpful taxi drivers to leave the station and waved off at least one taxi driver a minute during the thirty minute walk to our hotel, the beautiful and peaceful Nur el Gurna.
Nur el Gurna's proprietor, Mahmoud, offered us tea and introduced us to his wife, daughter, sons, sons' wives, grandchildren, cats and ducks, all of whom live at Nur el Gurna and work variously as cook, cleaner, taxi driver and farmhands for the livestock he keeps. Life in Luxor, Mahmoud informed us, is not like life in Cairo. Families stay together in Luxor.
Mahmoud confirmed our suspicions about Egypt's tourist trade. Since 2011's Arab spring and the Egyptian revolution, tourists had stopped coming. When we visited there wasn't even a quarter the pre-revolution volume of tourists. Our pyramid guide had dropped from three tours a day to one tour at best, Mahmoud's luxurious rooms were empty, and many of the tombs we would visit in Luxor would have been empty if it weren't for our presence. Unfortunately with so few tourists, those dependant on the dollars they provide have to fight even harder. By the time we left Egypt we had a good idea what the rugby ball must feel like at the end of a match.
After an unforgettable lunch of tahina, kofta and spiced potatoes we set off to see some of the tombs that Luxor is famous for in the nearby Deir el Medina. Deir el Medina itself is not the resting place of the pharoahs, it translates to "worker's village" and it contains the tombs of the workers who constructed the Pharaoh's tombs. Having laboured fulltime on the Pharaoh's tomb, these workers would head to Deir el Medina on their rest day to construct their own. The tombs are minute in comparison to the Pharoah's palaces of death, but without the riches to attract grave robbers these tombs remained sealed until very recently and these were the best preserved tombs we saw, with murals as colourful as the day they were painted.
Archaeologically speaking, the worker's tombs in Deir el Medina, and the tombs of the Egyptian noblemen in the nearby Deir el Bahari, are of interest because the wall paintings show daily life in ancient Egypt rather than glorious battles inscribed upon the walls of the Pharaoh's tombs. Personally, I was fascinated to see how the ancient Egyptian obsession with death permeated the entire society.
Once we had explored sufficient tombs for the day, we started down the desert hillside towards the hotel. Almost immediately a heavily armed policeman appeared, welcomed us to Alaska, and walked down the hill with us. I'm not sure whether I should write "walked with us" or "escorted us", most likely the latter. Egypt's broader struggle between the progressive, Western elements of its society and the highly conservative Islamic elements is manifested in the tourist areas as a struggle between the small army of Tourist Police and fundamentalist terrorists. The Tourist Police are numerous, well armed and the occasional bullet hole in their shields and trucks shows that they are not for show. Thankfully, they are effective and there have been no serious attacks on tourists in the past few years.
Tuesday (September 11th)
The following day we caught a taxi to the world-famous Valley of the Kings - the preferred resting place for Egypt's great Pharaohs, most notably Tutankhamen and Rameses IX. Unlike the tombs of the nobles and the workers we had seen the day before, the Valley of the Kings is a mainstay of tourist trail. It is a professional operation set up to cater for 7000 tourists each day, with a visitor centre, an educational video and a fleet of road trains for ferrying visitors from the visitor centre up the valley to the tomb entrances.
The Pharoah's were buried with as much gold and jewellery as their tombs would contain. These treasures are tempting to graverobbers and most of the pharoah's tombs have been open for millenia, with the notable exception of Tutankhamen's tomb, which remained sealed until when 1922, giving Howard Carter a chance to rob it. Having been opened, the elements have stolen much of the richness and detail from the wallpaintings, but the cavernous hand-hewn chambers are spectacular monuments to their original occupants, and in many the massive, intricately carved granite sarcophagus has been left in place.
One tomb had a mirror set up on the floor to show the underside of the sarcophagus lid where the figure of a woman had been carved, presumably to ensure her husband was fully satisfied in his afterlife. Museums and books present history in such a dour and stuffy manner that one assumes the participants must have shared this formality. This five thousand year old dirty joke carved into the lid of a Pharoah's sarcophagus reminded me that the participants in history were not as humourless as the subject often makes them seem.
Soon our book of "Tomb tickets" was fully stamped and we hopped the empty roadtrain back to the visitor centre to meet Mahmoud's taxi driving son. The roadtrain and accompanying infrastructure lend the Valley of Kings the air of a well managed heritage site, but insufficient money and effort is directed at preservation of the tombs in the valley. These tombs, the pyramids, the temples and the objects in the Cairo Museum are gifts from the ancient Egyptian society to their modern descendants, and they are largely responsible for the 30% of the Egyptian economy based on tourism. Every time I saw a tourist brush his or her hand across a wall painting four millennia old, or a tomb attendant bump his hat against the painted ceiling, or witnessed the damage done by the rainwaters that are allowed to flood these tombs each winter I wondered how long this gift would last, and how healthy Egypt's economy will be if the tourist sector dries up.
Wednesday
After a second night in the return sleeper train we woke up wednesday morning in Cairo. By now we had seen enough of how the ancient Egyptians were buried, and we were keen to peek into the daily lives of their descendants. Leaving our hotel we turned south in the direction of the Islamic old town hoping to see the ancient Citadel.
The guidebook informed us that Cairenes treat the street as their living room. Cafes and shops spill out onto the pavement in any warm western city, but Cairo is the only city where I've had to duck a tray of croissants pulled from a hot oven left on the pavement by the baker. In Cairo machinists and bakers ply their trades on the pavement side by side with cafe owners, street sellers and passing pedestrians.
Amongst the combined smell of sweat, baked goods, spices and car grease on Cairo's streets, the insincere and avaricious friendliness of Egypt's tourist spots is replaced by genuine hospitality. We experienced this generosity firsthand when we stopped at a coffee shop to ask directions to the Citadel we were searching for. Almost immediately we were surrounded by a small crowd of men arguing amongst themselves as to how best we could get there, and inquiring about our backgrounds. They were friendly, engaging and interesting; a better advertisement for their country than the sea of hawkers surrounding the pyramids, even though we never made it to the Citadel.
Thursday
Our last day in Egypt was an early start and an uneventful ride to the airport. We were fortunate to leave when we did, for the Tuesday of our visit was the day when protests over the "Innocence of Muslims" film started and four Americans were killed in the US embassy in Benghazi. An Egyptian Coptic Christian was the source of the film and there were additional, peaceful, protests outside the US embassy in Cairo. The situation drew comments from Obama that he did not "consider them [The Egyptians] an ally...".
Having seen the scale of the Egyptian government's struggle with Islamic terrorism through the size and ubiquity of their Tourist Police I found this comment ill considered and crass. America's war on terror is neither an abstract, nor a distant, concept to the Egyptians. It is fought every day of their lives, all over their country, and as the bullet holes in the police shields show, it is not a bloodless conflict. If these people are not Obama's allies, I am forced to question what war the Americans are fighting in the Middle East?
Most recently Egypt has made the news due to protests over the emergency powers President Morsi awarded himself, a referendum over these powers, and then further protests over the suspicious referendum result that effectively installed Morsi as Egypt's dictator. It pains me that these news broadcasts are undoubtedly shrinking Egypt's tourist trade even further, undermining the moderate sectors of Egypt's society and probably closing Egypt's doors to tourists like ourselves in the future. I enjoyed my visit to this friendly nation, with its beautiful landscape, and its artefacts from its proud history. It is heartbreaking to think of Egypt developing into just one more hard line Islamic state.
Posted on 18 Dec 2012

Slide to code blog is licensed under a Creative Commons Attribution 3.0 Unported License.
Based on a work at http://slidetocode.com/blog/.
Best before 2015. Should software come with expiry date?
Buy a car and you would be lucky to have any original components other than the steering wheel and the stereo left after 200,000km, but software's digital nature lends it an air of immortality that leads many to believe it will last forever. Indeed there are BSD tools on my laptop that have been doing their job for 30 years. They will undoubtedly last another 30, but these tools are self contained, and unlike a great deal of modern software they don't interact with much less immortal third party APIs.
I considered this question when experimenting with cloud support for my iPad Clojure editor. Cloud evaluation of Clojure would improve the product, but I don't want to write and maintain the servers myself. Ideone offer superb, and free, cloud evaluation of Clojure. It would be the perfect solution right now. I could effortlessly add cloud evaluation to Lisping, but startups live fast and usually die young, so what happens if Ideone were to fail or to start charging? Customers would have paid me for an application with free cloud evaluation and they would no longer be getting it; I wouldn't be surprised if they demanded their money back.
Another example is Twitter's war with third party clients. Earlier this year, having built their service with the help of third party developers, they began to shut off access to their API. They have yet to use their nuclear option - an outright ban on third party clients - but it is not unlikely that they will do so one day. What then? Tweetbot and its competitors will no longer be fit for their advertised purpose. If a car failed like that you could get a new one.
In the case of a Twitter client you are paying for software to interact with Twitter's public API, so when that API ceases to exist, the developer cannot be held responsible, but it is a serious question with my Clojure editor. Ideone have a great service and they are doing well, but technology moves fast. It is almost inconceivable that any current 3rd party API will have survived in its current form in 10 years time, so if I were to base one of Lisping's core functionalities on a third party service then I am selling software with a built in expiry date.
There is plenty of precedent for "Best before" dates in the retail industry, but the difference between a cloud app that has lost its cloud and the mouldy block of Gouda in my fridge is that the Gouda came with a label clearly stating its expiry date. Software should come with the same guarantees. Please state how long you intend to support it for. Please state if you will update it when the
For me the solution was simple. I'm not a fan of the cloud, and I've always wanted to write an interpreter, so I've started writing an easily embeddable Clojure interpreter in C++. When it's mature I'll add it to Lisping. With a native interpreter, who knows, maybe Lisping will still be running on the 51st generation iPad. With luck I'll still be alive to add support for the lightsaber peripheral.
Posted on 10 Nov 2012

Slide to code blog is licensed under a Creative Commons Attribution 3.0 Unported License.
Based on a work at http://slidetocode.com/blog/.