We do a lot of work now using GO (golang.org), a newer programming language developed primarily at Google.  GO is higher level than C but more nimble than Java, we like it a lot so far.  However, we also do a lot of work with traditional SQL databases and there are some features I would like to see added to the GO database/sql package, such as ability to handle stored procedures with multiple result sets and more intuitive handling of NULL.

NULL is an important concept in programming, it means “nothing”, such as in systems programming when you try to address a non-existing memory location. In SQL databases NULL values are used frequently when you have to differentiate between non-existing and zero. For example, a zero degree outside temperature is a perfectly valid value, different from NULL which would indicate the user hasn’t entered an outside temperature yet.

In GO the variable type for time or date (time.Time) doesn’t accept NULL values so we wrote our own NullTime type, a variable that accepts either a valid date/time or NULL if the user hasn’t entered the date/time yet. Our code is essentially a copy of the NullTime type from the excellent lib/pg database driver, with added JSON input and output.

This whole NullTime effort had me thinking about Father Time a bit. I like to live in the moment but I’m also fascinated by the passing of time. We know 2 amazing Peruvian women who are in their 90s now and have fascinating stories of years gone by:

Mama Vicky

Patricia’s grandmother, affectionately known as Mama Vicky, is about 90 or 92 years old now, depending on who you ask. She lived most of her life in the small town of Accha and I don’t suppose in the 1920s civil register recordkeeping in small town Peru was very good. I believe her eldest son once told me Mama Vicky was born in 1925. Unfortunately her health hasn’t been the best for the past year or so but until Mama Vicky was well into her 80s, she’d never been admitted to a hospital. She gave birth to 12 kids – all at home – of whom only 8 lived.

Nowadays you can drive from Cusco to Accha in 3 to 4 hours and from the center of Cusco it takes nearly an hour just to get out of the “metropolitan” Cusco area. But it wasn’t always like that.

Recently Mama Vicky’s back started to bother her quite badly. We were at her house in the Ttio neighborhood of Cusco a few weeks ago when she told us that she believes her back pain stems from a horse accident years ago. Mama Vicky’s family were land owners before the Peruvian land reforms of the 1950s and 1960s. Her grandmother’s house was a colonial style house in downtown Cusco where the prestigious collegio Sta. Rosa is now located. In those days Cusco was many times smaller than it is now, all the surrounding areas which now make up the big city were nothing but farmland and villages. As a teenager Mama Vicky would watch every weekend as the men came from the countryside and each of the men would pick up or deliver hay for the horses, supplies for the land, and so on. Mama Vicky remembered every detail, from how many men would come to what they would each pick up or deliver, who worked the stables, the warehouse, etc.

When all was ready for the men who came to the house, Mama Vicky would get ready for her trip to Accha by horse. The trip from Cusco to Accha by horse would take 4 days, she told us exactly where they would stop every day to overnight, where they fed the horses, where the horses drank, etc. During one of the trips, in rainseason, there was an accident with one of the horses and Mama Vicky hurt her back, which is what she believes is causing her back pain today.

Mama Vicky hasn’t left the house in a few months, her health doesn’t allow much anymore. Last time she left the house we took her out to eat in Lucre – the best places to eat in Cusco aren’t in Cusco, they’re the quintas campestres in the towns around Cusco. Mama Vicky remembered who some of the houses belonged to 70 years ago, I think the horses stopped in Lucre on the way to Accha, I look at the town differently now.

Doña Laeti

Doña Laeti is one of Patricia’s best friends back in the US. In Cusquenian Spanish you rarely use Don or Doña, it shows a great deal of respect when you refer to someone as Don or Doña.

Doña Laeti was born in Trujillo, in the province of La Libertad in the North of Peru. She’s of mixed Peruvian and Chinese heritage, there is a lot of Asian influence in Peru. Doña Laeti is from a well to do family, pre World War II she would travel with her family from Peru to Hong Kong by steamship. She said the trip took about 4-6 weeks, with stops in places like San Francisco and Honolulu. They traveled well and she enjoyed the trip, I’m not sure but I believe her father was a diplomat.

When World War II broke out Doña Laeti and her family got caught up in the China – Japan conflict and she was interned along with some of her family in a Japanese concentration camp in China. Doña Laeti was only 19 and she worked in the camp as a nurse. Nowadays Doña Laeti and her sister laugh about the poor Chinese guy who died one night in the concentration camp because “grandma slept on top of him” – but you can still see the pain in their eyes all these years later.

Doña Laeti has letters from the Hong Kong government (before Hong Kong formally re-joined China) commending her for her efforts during the war. During the war Doña Laeti’s father got separated from the family – I believe he served in Italy – and when he found their house in China bombed to rubble after the war, her father started a new family only to be reunited years later.

In later years Doña Laeti traveled much of the world with her husband who was a diplomat and then became a writer, I believe he was a writer for the Washington Post, which in those days was known in intelligence circles as the newspaper of the US Army. Doña Laeti had 4 kids in 3 different countries, such is the life of a diplomat’s wife. I’m not sure that she’ll travel again but into her late 80s Doña Laeti would travel regularly from her home in the US to her family in Trujillo, where we’d typically go visit.

* * *

These tales seem so other worldly but they were merely a lifetime ago. It’s easy to get caught up in the hustle and bustle of everyday life, you get lulled into thinking the world has always been the way it is today. Doña Laeti and Mama Vicky know better.

But I wanted to make a point not about steamship voyages or treks on horseback but rather about people. The median age in Peru is quite young and the streets are full of young people. Whenever you see an occasional elderly person among the mob of young kids you can tell by the looks on the young kids’ faces:

They are convinced that old person has been old for their entire life.

In their youthful ignorance these young kids just know that people like Mama Vicky and Doña Laeti have been old ladies for all of their 90+ years in this world. Look at any young kid in the presence of an elderly person and tell me it ain’t so.

But if you listen to their stories, Mama Vicky still sounds like that teenage girl watching intently how the men came to pick up supplies for the land and the horses. Doña Laeti still sounds like the young kid who traveled the world by steamship. While they’re wondering how this dynamic young girl got stuck in the body of an old lady, young kids in the street walk by knowing that this will never happen to them, convinced they’ll be forever young.

* * *

With Doña Laeti and family in Huanchaco

With Doña Laeti and family in Huanchaco

Mama Vicky with family a few birthdays ago.

Mama Vicky with family a few birthdays ago.

* * *

Our golang NullTime type. We’re launching our first golang API server next month, I’ll let you know how it goes.

package utilities

import (

// Type NullTime.

type NullTime struct {
Time time.Time
Valid bool // Valid is true if Time is not NULL

// JSON output.
// MarshalJSON implements the Marshaler interface.

func (nt NullTime) MarshalJSON() ([]byte, error) {

if nt.Valid {
return nt.Time.MarshalJSON()

return []byte(`null`), nil

// JSON input.
// UnmarshalJSON implements the Unmarshaler interface.

func (nt *NullTime) UnmarshalJSON(b []byte) error {

var myTime time.Time

err := myTime.UnmarshalJSON(b)

if err == nil {
nt.Time, nt.Valid = myTime, true
} else {
nt.Time, nt.Valid = *new(time.Time), false

return nil

// Download from SQL database.
// Scan implements the Scanner interface.

func (nt *NullTime) Scan(value interface{}) error {

nt.Time, nt.Valid = value.(time.Time)

return nil

// Insert in SQL database.
// A golang “zero date” is equivalent to dbase NULL.
// Value implements the driver Valuer interface.

func (nt NullTime) Value() (driver.Value, error) {

if !nt.Valid {
return nil, nil

if nt.Time.IsZero() {
return nil, nil

return nt.Time, nil

The Accidental Coder: How I became a (mostly) self-taught programmer

A while ago Twitter pal @glessermansazo asked me about learning how to write code, if I could recommend any good books. This got me pondering, my oldest daughter is changing schools this coming March – her first “real” school – and inevitably all the kids will have to tell their teacher “what kind of work does your daddy do?” Once upon a time those answers were simple, when the world was full of farmers, bakers, welders and carpenters but that was then. My daughter won’t have an easy answer, she’ll tell her new teacher and classmates a much glorified version of the following story.

First the short answer: I have a full-time job developing web applications. I work remotely for a US corporation, using mostly PHP, mySQL and JavaScript but I also dabble in other languages like GO. I have a side-job as a ferry-pilot, delivering small airplanes around the world.

That’s the SHORT answer! How I got here is another story.

Once upon a time when rock was pop, my father brought home a Commodore 64 computer. He was one of the first people in our area to buy a computer, most people didn’t really know anything about them back then. I learned how to write a few small programs in Bill Gates’ beloved BASIC and I wrote my first real program for a school project when I was in 5th grade. I didn’t really grasp the low level stuff – I still don’t – but I remember if you could hit the correct key combination you could escape the BASIC shell on the Commodore 64 and get into the assembly language. As a 12 year old boy I could make characters on the screen in assembly language and I vaguely felt mankind had gotten too big for its britches.

When my older brother started university he had to take some programming classes in Pascal but the professors told their students that this was mostly for learning purposes, to teach programming concepts. In the real world, everyone was using C – as we still do today. However, the university didn’t teach C because it was too powerful and easy to get in trouble.

So you wanna guess which book I picked up? Of course I decided to learn C. Why bother learning the concepts in university if you can learn the good stuff from a book? I was only 15 or so and by that time Pink Floyd had told me I didn’t need no university anyway. C is a wonderful programming language, the entire computer industry as we know it is built on top of it. Anyone who wants to program computers should learn the basics of C – just don’t put more elements in an array than you’re supposed to and stay away from pointer arithmetic unless you really know what you’re doing (I didn’t).

And then I quit programming. I’d had a love affair with aviation since I was about 5 years old and when I finished high school I enrolled in flight school. There’s a long story there too but suffice to say I spent 15 years flying airplanes, working as a flight instructor and building jet engines. I enjoyed aviation but it has its ups and downs. Somewhere along the way I was working 8 hours during the day and going to college at night, graduating when I was 33. I was working in a Fortune 500 company at the time which had outsourced most of it’s programming so I decided to pursue a degree in information systems, not computer science, but I did take a few programming classes in college. While I was in aviation I wrote some programs for aircraft weight and balance and I also did a short stint with an internet start-up during the internet boom in the 1990s.

Then I left my job at GE and came to Peru with the intention of working in aerospace, I had a contract with an aerospace company lined up when I arrived. The contract fell through and I found myself on top of a mountain in Peru with no job. I started looking for anything and everything. I was teaching ESL part time and looking for contract programming work online. I found a small 6 week programming job which turned into 6+ years of full time / independent / remote employment. I have no boss, no set working hours, it’s a very nice gig. I miss flying sometimes but programming is great because even someone like me who has no artistic talent gets to be creative, design things.

Coming back to the question @glessermansazo asked, what would I recommend if someone wanted to learn a bit about coding:

  • Take a few programming classes. I launched into everything head first, see if I could make something work without understanding the concepts. All that experimenting is great but when I took some programming classes years later I found it helped me a lot to think about the academic concepts.
  • Tinker with C at least a little bit, just remember the thingy about arrays and pointer arithmetic. Also, learn at least the basics of Linux – Linux is to operating systems what C is to programming languages.
  • Don’t fall for hype. Software like anything else is a business and people want to sell. Some things that were all the hype 5-8 years ago like SOAP and XML are now practically obsolete. On the other hand you can never go wrong with broadly accepted technologies like C/C++, Java, and PHP.
  • There are many new-ish languages and technologies now like node.js (which I’m tinkering with a little bit), Erlang, Scala, noSQL and untold frameworks, some claiming to be the best thing since sliced bread. You don’t have to learn them all, some are better for creative/expressive work, others are more suited for analytical work, etc. Find something you like and do it to the best of your abilities.
  • Don’t worry too much about this vs that. Ruby vs PHP, Python vs GO, mySQL vs Postgres, Ford vs. Chevy. Some languages are better suited for certain types of work (for example, C is better for systems programming and PHP is better for web development) but in my opinion a heated debate over things like PHP vs ASP often indicates you’re missing the most important part of software development: you are programming for real people in the real world. Designing the best solution starts with understanding the real world requirement, then you design the application around the real world requirement – not around your choice of language or technology.

Web developer is a popular job for expats in Peru