DEV Community

Tyclone81
Tyclone81

Posted on

Science v Syntax: The Rude Awakening.

Passing the selection pool at Zone01 Kisumu was just the gate. Four weeks into my official journey to software development and I have been hit by a rude awakening! The case sensitivity of Go has already signaled me not to shade my laboratory skin off yet. The attention to detail shall come in handy. Miss a comma, brace, or even an exclamation mark and the program throws in syntax errors.
My introduction to this reality was go-reloaded, a command-line text parsing tool. The assignment sounded simple: take a raw text file, manipulate the strings, fix punctuation spacing, and convert the binary or hexadecimal strings to numbers.
The chemist in me figured I would logic my way through it in an hour. Instead, I immediately hit a wall trying to format punctuation marks (., ,, !). They need to close up to the word before them, but maintain a space after them. My clueless loops resulted in constant runtime crashes;
panic: runtime error: index out of range.

With assistance from a few of my peers(I had to sample ideas from a few to establish my base), I was able to break the execution into two phases. First I split the text string into a slice of individual words and characters. I then used Go's built in standard package, strconv , to look ahead and convert specific flags (like hex _and _bin to decimal), while cleaning up the slice indexes.

The feeling of being able to run my first program albeit with enormous help from my peers was so much fulfilling. Much like the feeling I used to get when I got a breakthrough on a particular research, never gets old really.
The biggest lesson I learned wasn't actually about Go syntax. It was learning that error messages are not a sign of personal failure. In science, an unexpected result is just data. In coding, a red error screen is exactly the same thing, it is just an input telling you exactly where your logic diverged from reality. Each day is a learning day.

Beginners #Golang #Zone01Kisumu

Top comments (0)