Write code for humans first, computers second

When first learning to develop software, it’s natural to focus on getting your code to work as your first priority. As development is an incremental process, between multiple changes and attempts to get your code working, it’s natural that your first working version of your code is probably, to put it bluntly, a mess.

As you progress in your career, you realize the importance of developing code that is easy to read and understand, because at the end of the day, any software developed or maintained by a team has to be read and understood by other developers, not just the original developer. If no-one else on your team and understand your code then it’s unmaintainable and that poses a long term risk; if it breaks who is going to be able to fix it?

I commonly see posts online by new developers who are first starting out questioning the point and importance of spending time to refactor code, ensuring code is clear and readable, in essence, all attributes of maintainable code. The first time you come across code that you struggle to understand and you’re faced with making updates or fixing an issue, you’ll quickly realize the importance of developing code that is easy for other humans to understand.

This is not a new concept, it’s summarized clearly by the famous quote from Donald Knuth:

“Programs are meant to be read by humans and only incidentally for computers to execute.”

Creating a static website with GitHub Pages

I have a bunch of note as html files and want to easily host them somewhere. I’m looking into using GitHub Pages. GitHub pages provide themes, but for html files you need to add a header to the start of each file in markup format using Jekyll Front Matter.

---
layout: default
---

Add a sample test page with a couple of headers and you end up with a page rendered with your selected theme:

Access your site with the url: https://[your-github-user-id].github.io/[repo-name]

Using sed to filter a file, outputting matching patterns only

I’m parsing a dictionary file from Princeton University’s WordNet, but the only part I’m interested in extracting from the file is the word itself. grep won’t work for this since you can only output a matching line, but not a single matching word or pattern from a file.

The file structure looks like:

{ Bigfoot, Sasquatch, legendary_creature,@i (large hairy humanoid creature said to live in wilderness areas of the United States and Canada) }
{ Demogorgon, deity,@i noun.group:Greek_mythology,;c ((Greek mythology) a mysterious and terrifying deity of the underworld) }
{ doppelganger, legendary_creature,@ (a ghostly double of a living person that haunts its living counterpart) }
{ Loch_Ness_monster, Nessie, legendary_creature,@i noun.object:Loch_Ness,#p (a large aquatic animal supposed to resemble a serpent or plesiosaur of Loch Ness in Scotland) }
{ sea_serpent, legendary_creature,@ (huge creature of the sea resembling a snake or dragon) }

The second word in the file is what I’m looking for, so the output should be:

Bigfoot
Demogorgon
Loch_Ness_monster
sea_serpent

Let’s start with a simpler example first. Given a string “apple potato tomato”, let’s filter to print only words starting with “po”

$ echo "apple potato tomato" | sed -E -n "s/.*(po[[:alpha:]]+).*/\1/p"
potato

Breaking it down:

-E : used extended regex
-n : surpress outputting each line of the input
.*(po[[:alpha:]]+).*
- match any characters, then as a capture group () starting with po then 1 or more other alpha characters, followed by any other characters
\1 - replace match with capture group 1
/p - print only matches

Now that’s use the same approach to match just the first word on each of the dictionary file lines:

sed -E -n "s/{[[:space:]]([[:alpha:]]+\_*[[:alpha:]]*).*/\1/p" ./dict/dbfiles/noun.person >> noun.person.parsed.txt

ArcaOS install on VirtualBox

My first job out of college was with IBM as a contractor, working in the IBM Software Center, Basingstoke, providing technical support for OS/2 and Communications Manager/2. I ran OS/2 on my own PC at home for a few years after this, before moving to Windows 95.

In the past few years I’ve installed various versions of OS/2 in virtual machines for nostalgic reasons. I’ve also kept an eye on Arca Noae’s ArcaOS as a current day commercial offering of OS/2 complete with updated drivers and hardware support for current day hardware. For a personal install though I’ve been reluctant to pay the $120 for a personal license, but recently decided to bite the bullet and buy a copy.

I like collecting screenshots of OSes during the install process, and this post is one of those 🙂

After the typical ‘white square’ top right and ‘OS/2’ text, we get to the first installer screen:

After accepting the license agreements, the next page is interesting, it prompts you to select a ‘personality’, a pre-configured set of features depending on how you intend to use this installation. I’ll select the default/first option for now. I don’t remember seeing options like this during a typical OS/2 install, maybe Warp 4 provided options like this (I’ll go check later):

I have a blank 2GB virtual disk on VirtualBox for this install, so I’ll select the option to format it. Later when I do a bare metal install I’ll be doing the same on a blank partition on a new SATA SSD:

Prompted to reboot:

The familiar shutdown compete dialog!

After rebooting, you’re back at the first page of the install again. Stepping through the same options we’re now prompted to select the install volume:

There’s no volumes in the dropdown yet, so press the Manage Volumes button:

I clicked on the Volume menu option, then ‘Create new’, then the ‘Standard/bootable’ option:

I kept the default C and named the volume:

I’m using all the free space on this volume, so kept the defaults:

Volume manager now looks like this:

Closing this dialog I’m prompted to save and now the volume is selected:

Next up, location settings. Huh, remember code pages? I set my timezone, DST, and internet time sync:

This next one is interesting and allows you to configure your hardware options. This is obviously where ArcaOS shines in it’s ability to support hardware of the time as well as updated support for current hardware:

Also interesting that support for VirtualBox is selected by default as the installer recognizes we’re installing on VirtualBox:

I kept all options as default for now. When I do a bare metal install next I’ll check out what the Display options are.

Network driver install next and prompted for machine name, workgroup, and username:

Ready to install – let’s go!

Off we go. Noticeably absent and the messages telling you about the various features that you get during a Warp install:

Time to reboot:

During the install there’s a couple reboots we are automatic if you leave the checkbox selected.

Done! Up and runnning!