Why I Write Simple Code

As per Kernighan’s law: “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”

Brian Kernighan, the author of the above law, is among the most famous of all computer scientists. He, along with Dennis Ritchie, authored “The C Programming Language”, one of the most well known of all computer programming books. As such, Brian Kernighan’s ideas carry a lot of weight.

Kernighan’s law sounds simple, but it carries a profound truth – that clever code is bad code. When I was a younger programmer, I thought writing clever code was a great idea. I loved writing code that made me appear to be a wizard of coding. Of course, when you write complex code, you realize the first time you try to fix a bug that the code isn’t maintainable. Now, after 20 years of programming, I aim to write simple code – the simpler the better. I want any programmer – today or in a decade – to be able to look at my code and figure it out without any effort. Simple code is maintainable code.

Do you write simple code? Do you hire programmers that write simple code? More importantly, when you hire contractors do they write simple code? Contractors are notorious for writing ‘clever’ code so that you have to keep them onboard long-term to maintain the code they wrote.  For a business, this is a huge – and costly – mistake! Clever code will cost you far more than you think over the lifetime of an application!


Google Alerts

One of Google’s most under-utilitized tools is Google Alerts (google.com/alerts). This service allows you to receive emails with new results for particular search strings. While this may not seem useful, it is an excellent tool for being notified of information that may appear on the net about you or your business. With the rise of identity theft and the harm that can come from negative posts about you or your business online, it’s imperative to know what information is being posted out there about you. In Google Alerts, you simply enter the searches you want, and Google will notify you of new results. I encourage anyone who wants to keep an eye on their online-footprint to setup searches for all possible variants of their name and let Google do the rest!

Clean Drive

In the early 2000’s, I purchased several Sun Microsystems computers for putting together a home network of Unix machines. Nothing particularly exciting, I had an IPX, an LX, a Sparc5, and a few others. This was my testbed for tinkering around with Unix system administration. These computers were all purchased from eBay. The IPX and LX were both purchased from the same seller. Typically, when you buy computers on eBay you will find that they do not include hard drives. This is to protect any data that may be on those drives from prying eyes. However, the IPX and LX still had their drives in them. I had assumed they were wiped clean, but that was not the case. Both were fully ready production systems complete with the entire company directory and password file intact! Since I did not have the root password, I removed the drive and placed it in my Sparc5. Then, I updated the password file to use my root password. Finally, I removed the drive and put it back in the original machine. Now, I could run the machine with the new admin password. When it was booted back up, I found all kinds of company data – and this was a fortune 500 company too! This was the stuff that could have been sold on the black market for a substantial sum of money. I took the password file and ran it through Jack the Ripper – a common password cracking program – and before long knew the passwords for all the employees on this system. That same procedure was done on both the IPX and the LX. Lesson learned? Protect your hard drives. Absolutely destroy them before you get rid of them. The cost to company that originally owned these machines could have been enormous – they lucked because all I did was tinker with the machine as a curiosity and then wipe the hard drive clean. You may not fare so lucky when you dispose of your hard drive insecurely.

REST Tools

REST services are everywhere now. Long gone are the days of RPC and other horrible tools for running functions on a remote machine. This is great news for developers as older frameworks were very cumbersome and far less useful than REST services. What makes REST even more important is that they are used along with JSON to enable all kinds of slick functionality on the internet. Indeed, countless web applications and mobile applications now use JSON-based REST services. And just as there are numerous applications using JSON and REST, there are countless ways you can test REST services and create mockup services. But not all tools are created equal – particular for lightweight, simple testing. For example, a colleague recently said he was using Java and JAX-RS to mockup REST services. Certainly you can do that, but the amount of code you need to write and the frameworks required make it anything but simple. What tools do I use for REST testing? I like to use Python and Flask for mocking up REST services. For example, I can create a simple REST service in Python to return the sine of a number with the following snippet of code:

from flask import Flask
from flask import jsonify
import math

app = Flask(__name__)

def trig_sin(num):
  rad = float(num) * (math.pi / 180)
  sin = math.sin(rad)
  dict = {'input':num,'sin':str(sin)}
  return jsonify(dict);

if __name__ == '__main__':

This is a full service, not a mockup. A mockup would be even simpler – just create the route and return the JSON you want. Nothing could be simpler for mocking a service.

For testing services, I use Visual Studio Code and the REST plugin by Huachao Mao. To test the above service, I can enter the snippet below into a file with a .http extension, and the REST plugin will create a button for me to call the service.


I can create countless test calls as well as supply headers and JSON POST data. Even better, the .http document creates a documentation that is concise, clear to understand for anybody who develops REST services, and can be interacted with to see the output of the service. These two tools are my default choice for any type of REST testing.

Cryptocurrencies and Blockchain 

With the price of a bitcoin surpassing $10,000 and the recent craze around cryptocurrencies, developing an understanding of what the technology behind these cryptocurrencies actually does, as well as what can become of these technologies going forward seems worthwhile.  Before we can begin to truly understand what cryptocurrencies like Bitcoin and Ethereum are, we need to look at how blockchain technologies work and why these technologies hold immense value for people around the globe.

The technology behind the blockchain is fairly simple conceptually speaking, though incredibly innovative nonetheless.  The fundamental issue that prevented digital currency from taking off for so long was the ability for any person to make duplicate transactions.  For instance, when a person sends an email, they are never actually sending the original message but rather a copy, so if two people claimed to own the same digital currency, there would be no way to prove the actual owner without having a fine-tuned system in place.  A blockchain solves this problem by validating transactions through solving cryptographic riddles and maintaining a universal record of all transactions, an ongoing process carried out by a decentralized network of computers around the world.  These miners are rewarded for their work through miner fees and their ability to unlock and release new cryptocurrency into existence.

In the United States, we believe in the value of the dollar.  Millions of Americans work hard at their jobs inputting their time, energy, and resources on a regular basis.  This results in them earning a paycheck, often directly to their bank accounts.  With this money, people make transactions based on trust:  trust that their debit or credit cards will work, trust that they can access and spend their money, and trust that this money will not be tampered with at any point between sending and receiving payment.  But this trust-based service comes at a cost, around 3% of our transaction fees to be exact.  The blockchain reduces the need for a middle man and enables direct peer-to-peer transactions, minimizing the potential for tampering and corruption along the way at a lower cost, roughly 0.1% or so, which pays the miner fees and gives people an incentive to keep the decentralized network active and growing.

Looking specifically at a cryptocurrency, Bitcoin began back in 2009, and its blockchain has been recording and validating transactions ever since.  Unlike the US dollar, there is a finite supply of bitcoins that can ever be created, capping out around 21 million.  Currently, less than 17 million of these exist, and as time passes each bitcoin becomes more difficult to mine.  This element of scarcity is appealing from an investment standpoint, because as demand increases the price does as well.  Investing in cryptocurrency today does not come without considerable risk though, considering the market is very volatile.  In the grand scheme of things, these cryptocurrencies are still very young, meaning that people base much of the value on the integrity of the system, also considering what the future of these cryptocurrencies might hold.