Crafting Code

Computer programming is the art of organizing instructions. To practice this art, a programmer arranges and tidies code while fixing whatever’s broken. At its start, every program is essentially broken — it doesn’t function properly — in fact it doesn’t do anything at all because there aren’t any instructions yet. So the programmer adds instruction after instruction until the program behaves as expected.

Because a program is a giant list of instructions, the code itself must be organized in an easy-to-understand way. A programmer can get lost in a mishmash of jumbled code and never find a way out. To deal with this inherent complexity, many different styles, languages, libraries, and frameworks exist. Each programmer must find his or her preferred way of organizing instructions, discovering a method that makes the most sense.

What drives a programmer is the need to repair something that doesn’t work correctly. Whether it’s hours or days, the programmer researches and experiments until a particular problem is resolved. As the programmer grows in experience, a catalog of techniques and solutions accumulate but that doesn’t mean programming gets easier. A programmer simply gravitates toward harder projects and the challenge continues.

Plus, programs are never really complete. Aspects of functionality can be overlooked, tiny mistakes can accumulate over time, larger mistakes can remain hidden until revealed by obscure conditions, or the platform on which the program runs can change and cause errors. And thus programming remains an art whose output only approximates something concrete. What appears as a window is in reality tiny dots dancing across a screen.

Path of the Programmer

A couple months ago, I purchased a laptop computer so I could get back into computer programming. Prior to that, I had been using an iPad Pro to fulfill my computing needs. Because I was mostly dedicated to writing this blog, I didn’t require much in the way of computational power.

Since receiving the laptop, I researched a bunch of programming paradigms and installed a few development environments. After the dust settled, I picked Javascript as my language of choice. As for tools, I’ve been using Visual Studio Code and the Chrome web-browser. Oh, and the developer docs over at Mozilla.org have been extremely helpful. And shout-out to all the various websites and YouTube videos that provided insightful tidbits as well.

My programming portfolio at WellCraftedSoftware.com is filling-out nicely I think. In just a month of programming with Javascript, I’ve got quite a few samples up there. Simple stuff on the surface, but it takes effort to write code that isn’t overly complex. My goal is to write the cleanest, most uncomplicated code possible.

I have no other objective at the moment but to continue adding to my portfolio — and in the process, practicing and honing my craft. I’m having more fun this time around — just programming for programming’s sake, there’s no rush to get anywhere in particular. Why do I want to climb the mountain? “Because it’s there.” And so I continue my quest, following the path of the programmer….

Space Game

I’m still knee-deep in computer-programming activities. My latest experiment/release is an Astroids-like Space Game. It’s using Javascript to draw on a Canvas element by utilizing a bunch of trigonometry. Because I like using vanilla Javascript and a raw Canvas element, I had roll my own collision-detection mechanism.

I’ve also been watching Star Trek: The Next Generation on Netflix (I’m currently up to the middle of season 3). That particular series is chock-full of competency by the way. If you want to bathe yourself in the concept of people performing their jobs exceptionally, that’s the one to watch. Picard is professionalism personified — and of course the entire crew steps up whenever duty calls.

I think the show has been keeping me from getting road-blocked by problems that spring-up along the way. In the past, I’d often quit when the going got too tough. But now, if something isn’t functioning properly, it means I need more research or perhaps a different approach. With enough perseverance, there’s always a solution. Quitting is not an option: there is only the performance of one’s duty till the end.

It’s dedication to the craft. In Star Trek, that craft was an actual craft, the starship Enterprise. In my case, the craft is the art of programming. It’s authoring and organizing sets of complex instructions. It’s coercing pixels to dance across the screen in predictable as well as unpredictable paths. It’s seeking out new ways and unique solutions, boldly coding where no developer has gone before.

More Programming

I’ve spent the last few weeks reacquainting myself with programming. First it was Codea on the iPad, then Godot on the PC, and then Javascript on the web. It’s been interesting to see what’s changed and what hasn’t in the near-decade that’s passed since I stopped programming. It seems like Javascript became a big deal for instance.

I even re-established my old domain-name (which I couldn’t get rid of for sentimental reasons): https://WellCraftedSoftware.com. It now points to an Ubuntu instance on AWS — I always wanted my own Virtual Private Server. It hosts some of my recent experiments with Javascript, including a simple Node.js server demonstration.

I’ve been using Visual Studio Code to whip-up some quick little programs that utilize Javascript to manipulate Canvas elements within the browser. I’ve also familiarized myself with the CSS Grid spec and found it a decent way to do layout. When I left programming many years ago, Javascript and CSS were an absolute mess — now they seem downright pleasant (if done right).

I did look into a few other programming areas, but I wasn’t that pleased with what I found. I still dislike Xcode, but I’m excited to see if SwiftUI can turn things around. I also looked into Android Studio and saw that they switched from Java to Kotlin — very interesting. But overall, the development environment is too big and heavy — I prefer a leaner/meaner setup.

For the time being, I think I’ll concentrate on browser-related stuff. The HTML Canvas element is pretty primitive, but it’s kinda fun for now. I haven’t touched NoSQL databases yet, but they look promising: just throw them some JSON? Cool. Oh and honorable mention to https://developer.mozilla.org, their documentation for Javascript and other web-related stuff has been phenomenal.

Fundamentals of Programming

A programmer compiles a set of instructions into a program. So at its essence, a program is simply a bunch of instructions that perform a given task. Those instructions use branching and repetition to form a kind of narrative.

For instance, imagine you need to go shopping for groceries. First, add items to the shopping-list. While scanning kitchen, if milk is less than half full, add to shopping-list; if container of popcorn is empty, add to shopping-list. Now goto the store. While not at store, drive – if impeded, press brake, else press accelerator. Now enter the store. For each item on shopping-list, add to cart.

function scanKitchen():
  if(milk < milk.contents / 2)
    list.add(milk)
  if(popcorn == empty)
    list.add(popcorn)
  return list    

function drive():
  while(!atStore)
    if(isBlocked)
      pressBrake()
    else
      pressAccelerator()        

function shop(list):
  for each item in list
    cart.add(item)
    
//call these three functions in the appropriate order:   
list = scanKitchen()
drive()
shop(list)

if statements take the program on different paths depending on whether a condition is true or false. Whereas while / for statements create loops that keep certain commands repeating.

Putting objects in groups, such as the shopping-list, is another fundamental concept. An array of items is easier to keep track of as a whole, and such a list can be quickly scanned and processed.

To tell the story, you’re going to need some action commands. For instance scanKitchen is a function you call upon to look through the pantry and fridge. You simply invoke it, and it returns a list of needed items. You can then print those items onto paper — or order them online — the list is yours to do as you wish.

Different programming platforms provide various built-in commands to play with. Some programming environments offer minimal pre-made functions and some offer extensive libraries of functionality to call upon. The work that goes into a program comes from assembling the provided building-blocks. This includes finding the appropriate commands and properly invoking them, as well as placing those instructions in the right order — and of course you can adjust this order by using conditions and repetition.

An Old Friend

I’m nearing the end of the official Python programming-language tutorial. My interest in programming was recently rekindled and Python seemed a decent re-entry point — especially because there’s a fully operational scripting environment, known as Pythonista, that runs on the iPad.

I suppose you could say I used to develop software professionally — until I stopped a few years ago. It feels kinda good to get back into programming. I don’t have any professional aspirations, it’s just a hobby like when I first started many years ago. At that time, coding seemed like such an impossible feat, then it clicked and off I went.

My first experience with programming was Microsoft’s Visual Basic, almost 20 years ago. I was excited to install and begin coding — yet I couldn’t decipher the code, it just didn’t make sense, like trying to read a foreign language in an unfamiliar alphabet. Then I read an intro-to-programming book, one used in college classes — it used the C language and some included libraries to teach. After finishing the book, I went back to the Visual Basic development environment and surprisingly it made sense. The process of working-through the book seemed to unlock an ability to program.

But I still struggled with programming in the sense that doing anything interesting was complicated. Sure you could effortlessly place a button and update a text-box, but things got complex real fast when going beyond the basics. I was stuck with too-simple or too-hard so I stopped programming for a bit. Then a new way to write for Microsoft Windows came out, called the .NET Framework. I really liked C-Sharp and the large library of functionality that came with it.

But unfortunately, it still had its limitations. Just like before, writing long lines of complicated C/C++ code was the only way to do the most interesting activities. Yet .NET was decent enough at developing moderately interesting applications. I had also tried web-programming, like PHP and such, but found that a bit cumbersome compared to desktop-app programming. I liked visually-oriented programming rather than slinging and storing data into databases.

Yet when it came time for finding a professional outlet, PHP and ASP.NET were the easiest positions to find so I did that, learning as I went. I was pretty good though, very meticulous. I didn’t much care for the business side and eventually burnt out. Not too long afterwards I tried my hand at developing Apple Mac Apps in Objective-C but found the language too unwieldy and old-fashioned especially coming from C#. I did sell a few apps in the Mac App Store but nothing significant.

I do appreciate Apple’s new Swift language. I really like their Swift Playgrounds app for teaching kids about programming. Although I think anyone using it might need access to an experienced programmer because it seems a bit too challenging otherwise. X-Code on the other-hand, Apples’s full-featured development environment needs a serious paradigm shift in my opinion. I was not pleased with what I recently saw in an official tutorial — linking up code to the graphical parts of the program seems cumbersome. It makes me miss the ease of C# and .NET from over a decade ago.

In a sense, I think of programming as a means of expression. Like a painter expresses with brush on canvas, a programmer expresses with code in compilers — or a writer expresses with words on paper. I often try my hand at art/drawing apps but eventually abandon them because I fail to enjoyably express myself — I typically can’t create something I admire. Whereas in writing, I’ve written a lot of things that amuse or impress myself. I can’t say that I’ve made anything impressive with programming, but I often find the process fun because of the learning and problem-solving involved.

But that’s been my underlying issue with programming, an inability to create things I’m impressed with — thus I can’t completely express myself. Instead, I regularly come up against insurmountable limits that stop me on my path. Oftentimes the complexity rises to a point that shuts down the fun. Although, perhaps my impatience is to blame. Many of the programs we use daily are like living breathing entities that have their creator’s souls poured into them. Maybe I wasn’t willing to put that much effort into an individual project.

Yet I suppose that was another issue I had with programming: finding a worthwhile project in which I could pour my essence. Which is why I’m writing words nowadays instead of code. I enjoy writing words and I can express myself to a great degree. But similarly, I don’t like large writing projects, I’d rather just transcribe some snippets of thought on a regular basis. Writing, programming — really, they’re just a means to entertain my mind, giving my thoughts something to do, a purpose.

I have no point in my late-night rambling beyond an acknowledgment to an old friend that’s come back to visit. Will he stay? Who knows. But it’s good to see him while he’s here. I’ve missed you buddy. How many late nights did we spend together? All alone in a world of our own. How many guises have you worn? C, C++, Visual Basic, Java, PHP, Javascript, C#, Python, Ruby, Objective-C? You old son of a bitch, stumping me whenever you could. But I got my licks in here and there.

Well goodnight old friend. May your loops never be infinite and your memory always well-managed.