Programming

Lets stop the abstraction!

There is an old saying - "Give a programmer 5 hours to write a particular program, and they will spend 4 hours writing another program that can write the original program in one hour!".

Increasingly these days, it is hitting me just how true that old adage is.  I have been cutting code for over 30 years now, and more than ever I am of the opinion that the world of programming is just drowning in a sea of constantly evolving tools.

It is no longer enough to just pick a language and become proficient in that, and just plain write code using that language.  Nowadays, it is a constant dance of selecting frameworks, database layers, deployment layers, and even additional languages that simplify the writing of the base language of your choice!

We all know that at the core, all computers just function on a series of 1's and 0's - the turning on and off of electrical impulses.  The closest we can get to that is to write in assembler code - manipulating the registers and directly accessing blocks of memory in the hardware.  But that, as we know, is fraught with danger.

So we rely on higher level languages, which are then compiled or interpreted down to machine language so we can run our apps using code that is easier for us to understand as humans.  For years, we simply picked a high level language, then let the compiler or interpreter get on with converting that language into machine language.

But lets look at an ubiquitous language of today - Javascript.  Now Javascript in itself is a fairly simple language, bearing close resemblance to C and other languages, so that programmers can usually pick up the nuances and write decent code in short order.  It is also an interpreted language, usually being converted into machine instructions at run time within a browser.  Not the most efficient language, but still serviceable and functional.

But somewhere along the line, someone decided that Javascript was still a little too hard, so they invented a simplified version called CoffeeScript.  Lets paint the picture here - we now have a specialised language which is then converted into another language which is then interpreted within an environment written in another language which then converts everything into machine language.

But it didn't just stop there.  CoffeeScript itself became bastardised over time, and now exists in about a dozen different flavours.  As of writing this post, there are around 40 different languages that 'compile' down to Javascript.  This is not counting the hundreds or so other extensions that generate javascript code based on a whole other language.

It is no longer enough to say that you know CoffeeScript.  You have to now define the flavour of CoffeeScript that you are familiar with.  You have to remember a whole new syntax to compensate for the fact that you could not remember another syntax in the first place.

I just can't wait to see the next iteration of languages that compile down to CoffeeScript, which then compiles down to Javascript, which then compiles down to.....  You get the picture.

I am theorising here that there is a glut of excess programmers out there who are not actively engaged in solving real world problems, so they take out their energy and time by writing yet another interpreter/compiler for a perfectly valid working language.

To put it in a more primal context, the village is thirsty, but rather than locating water or digging a well, the villagers are busy improving each other's shovels.  We will all be dehydrated soon, but man will we have some great shovels...

 

 

 

Cloud Overload

About 5 years ago, my PC desktop screen was starting to look a lot like the image here on the left.  Cluttered with a myriad of windows, it was getting so that I couldn't even bring a background window to the foreground because (a) I couldn't identify it any longer and (b) no matter where I clicked on a background window, it was a 'hot spot' that caused something to happen when I didn't want it to.  I just wanted to bring the window to the front but ended up executing a macro or changing the view etc because modern applications have pretty much < 1% of the active window that is not a clickable area for executing something !

So in 2012, we successfully converted ALL of our usual desktop apps over to cloud, or web based services.  This was wonderful.  It gave me bragging rights at parties and a feeling of smug accomplishment.

But just today, I realised that I have created a monster in another form.  You see, I just realised that my normal working day now requires me to open up at least 25 tabs on my browser.  Just to get my day to day work done.  For some specialist tasks, I am looking at around 40 browser windows.

This is NOT counting the other tabs I will need to open up for research or fact finding.

I am beginning to loath it when Chrome crashes, and when I click 'Restore Tabs', I have to wait about 10 minutes whilst it reloads content in 50+ tabs.

I used to get upset when the number of tabs negated the titles of the web sites, so I began to rely on the little favicons to identify which tabs did what.  Now even the favicons are being obscured by a veritable tsunami of grey tabs, and it is common for me to accidentally hit the 'x' close button instead of the actual tab when switching with a mouse.  Alas I lack the pin point mouse accuracy of an SAS sniper.

I need to consider shutting down some of our web based services.  Either that, or get a browser that is more command driven.  I have been intrigued by the Vivaldi browser project, started by the guys who made Opera, but that is still in early days.

How ironic.  Though I am developing apps for modern web and touch based devices, I seem to be craving my tools be command driven, just like when I started on DOS based terminals back in 1985...

 

 

 

On Code Comments

Actual source code from Microsoft Word 1.0 for DOS

Actual source code from Microsoft Word 1.0 for DOS

This post is basically a bookmark for me to come back to and remind (berate?) myself regularly about my comments that I write in my code.

Not that I should do more. I actually put in a heck of a lot of comments in my code, because I know my memory is poor.  Especially so when I have done several late night programming sessions in a row.  I once even completely forgot that I had written an entire application after a month of sleep deprivation.

What prompted this post is the fact that I often find myself coming across lines or blocks of code that are commented out.  Without explanation.

Just today, I had to go back into some 2 year old code, because a client had reported a possible bug that wasn't bringing pricing across properly from their legacy system.

It took me a while to re-understand my code, and that was helped by the copious comments I had left, knowing my own mental fallibility.  However, when I finally got to the section of code that did the pricing import and looked at it, I immediately knew what I needed to do in order to effect a fix.  BUT then... I noticed that there was already two lines of code EXACTLY like the ones I was about to put in.  Only they had been commented out by me previously.

Why?? What made me comment out those two lines in the first place?  Did they introduce yet ANOTHER serious bug in the system?  There was no notation as to when the lines were commented out, nor any indication of WHY I had done so.

The 'when' is an easy fix.  I just need to go back through my version control system to work that out, but the 'why' is an altogether more puzzling conundrum.

I'll be sure to leave some comments in this section of code reiterating my journey to write, then comment out, then uncomment the alleged lines.  Perhaps in another year or so, I will come back to it and have to unravel this veritable Gordian knot of commentary.

App #3 - Spotto

Ok, just submitted app number three to the app stores yesterday.  This time, a gaming app called Spotto.  This app is basically a rehash of the old kids game we used to play when we spotted something that was pre-designated during an outing or a road trip, and the first person to call 'Spotto!' won a point.

Well, with this app, any player can create a game, which can be for spotting ANYTHING at all - whether it is a brand of car, colour of show, breed of cat, style of architecture - whatever.  Other players can join the game, and then post pictures of the said items.  All players in the team can approve or dispute entries, and points are awarded for approved entries.

The game is open ended, and self regulated.  It was an especially challenging one for me to write, as this was the first time I was using a NOSQL database (Firebase, from Google).  After years of SQL programming, getting my head around NOSQL structures and capabilities was a real challenge, but I think I got there in the end.

The other thing was that this app was designed to be fully real time - i.e. as soon as an entry was entered on one player's mobile device, the other devices all updated at the same time.  This was also quite challenging, however the Firebase API helped a lot with this.

In the same vein, I had to get my head around push notifications, and also use Facebook login authentication for the first time.  All fun, but it all came together fine in the end.

Spotto should be available in both stores by the end of the month.  In the meantime, feel free to visit the Spotto website for more information.