Nightmare Before Easter: Getting Back to Programming

by about Go, API in Technology

Explain Like I’m a Manager

At home, after a discussion about hardware, password managers, and IDEs, we went to the topic of programming. For years, I’ve been convincing myself I should get back to coding to keep up-to-date on the newest developments. I don’t mean browsing some online sites, reading what’s going on, and then going back to Excel, e-mail, and writing strategy documents.

I mean real, raw, brutal, nightmare-inducing coding. For those of you who wonder what I’m talking about because coding is pleasant and puts you in the “zone” - no, no. Coding for me means utter frustration and being at the brink of giving up almost every minute. It also means lots of procrastination by reading about best practices and getting hung up on configuring editors and operating systems and terminals to be “just right”.

There is plenty of production code I wrote still out there. Getting into programming after years of not doing it is tough, though. It’s similar to knowing how to drive a car and then not driving it for years: some people will go straight back to doing it and some people will never touch the steering wheel again.

Character from the Worms game pointing a finger at Jazz Jackrabbit with a background screenshot showing code

So, eventually over the last days I’ve been setting things up and finished my initiation back into programming just today. Here’s what I did:

1. Spent 6 hours of setting things up (operating system, check whether Atom or gedit are still good for programming - hint: they never were, I just never used an IDE because $reasons).

Result: Procrastinating felt wildly successful. Everything is installed, tweaked, and tuned. I am even gasp using an IDE now.

2. My thought process, “Go. I remember using it. I best look up how to write it again, you know, in case things changed.” Turns out not enough has changed to waste another 6 hours on reading Effective Go, the Go Language Specification, and the Go Tour, which I had already read at least 3-4 times in my life before.

Result: Could’ve just as well played more Worms: Reloaded with my son.

3. “Cool, I’m ready to start. Let’s go. But we’re not just doing ‘Hello, world!’, are we? I could look up some open data sets and just throw them out.” Said and done. Wasted another 3 hours on thoroughly researching open data sets and whether anything has changed in how they’re used and what is out there compared to the last time I looked them up.

Result: I need to do more programming and come up with something useful to process that data.

4. Downloaded one simple data set that would qualify for data extraction and simply showing it on the standard output. Discovered some more interesting data sets (Proportion of time spent on unpaid domestic and care work, female [% of 24 hour day], the male version, more, and even more that would be fun to play with, but that’s for another time. Result: I have a data set. I’ll do the simplest thing I can do with it just to get my brain back into programming mode and out of pure people management mode.

Hint: Being in lockdown during a pandemic for over a month is good people management training.

5. Thirty-five minutes from start to end to have a functioning minimal Go program. Feels like betrayal, given the previous 15+ hours of investment. Here it is in all its non-error-checking, mostly hard-coded glory.

/*
Data via geonames.org at https://datahub.io/core/world-cities#readme.
*/

package main

import (
    "bufio"
    "encoding/json"
    "fmt"
    "os"
    "strings"
)


func main() {
    fmt.Println(
        "Hello, world! This is a very small program where you can put " +
        "in a country name and you'll get a list of cities with over " +
        "15,000 inhabitants in that country. As a bonus, you'll see " +
        "which countries have cities with the same name. This data set "
        "is from 2017. Enjoy!\n" +
        "Please type a country of your choice. Get the spelling right.")
        reader := bufio.NewReader(os.Stdin)
        text, _ := reader.ReadString('\n')
        readCity(text)
    }
    
    func readCity(text string) {
    file, _ := os.Open("worldcities.json")
    defer file.Close()
    
    dec := json.NewDecoder(file)
    dec.Token()
    
    data := map[string]string{}
    for dec.More() {
        dec.Decode(&data)
        if data["country"] == strings.TrimSpace(text) {
            fmt.Println(data["name"])
        }
    }
}

This program lets you put in a country of your choice and then it throws out all the cities in that country which have over 15,000 inhabitants. Simple, but it is enough success to keep going. How about an ELIM (Explain Like I’m a Manager) tech series about programming and all things DevOps on here? Happy procrastinating to you all - stay safe!