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.

Advertisements

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.

New Chief

An excerpt from the fictional tales of The Bytekings.

Tell me, are you familiar with the concept of air supremacy?
Yeah, it has something to do with controlling the skies in battle.
Those who control the sky, determine who will die. I assume you’ve heard of the rockets my company produces?
Yes of course, they can even land themselves.
That’s right. And you’ve probably also noticed that my company makes semi-autonomous automobiles as well?
And I’ve seen the solar work you’ve been doing, it’s all quite fascinating.
Decentralized electrical power is decentralized political power.
There seems to be an underlying theme to all this.
Indeed there is. The way in which humankind is currently organized is outdated. I am going to fix that.
And those currently on top will allow you to do this?
How easy would it be for me to weaponize my rockets? How quickly could I weaponize autonomous vehicles? And I need no electrical grid to produce my power.
Just what are you saying?
Relax, I’m simply telling you what I could do, not what I will do. Tell me, are you familiar with the Simulation Hypothesis?
Yeah, the idea that our world is only a virtual reality.
Exactly, and I’ve been well aware of this condition for some time, hence my recurrent success. I lack the the fear and doubt that plague those that believe themselves living in an organic world.
Then what are you going to do?
I am an engineer by nature, a creator of systems, I am designing the foundation of the next era. I have my hands in banking, robotics, energy production, as well as transportation: terrestrial and beyond. Think of how early industrialists made their money, I have seeds in all those fields and soon my crop will establish itself.
But then what?
Then power goes to the people.

New Year’s Tech

When I was a little boy, a mother’s lap was the only car-seat a kid needed. Dictionaries were large books with finger tabs for quick access by letter. Encyclopedias were purchased at the supermarket, one book per week. We often browsed catalogs and filled-out order-forms that were mailed-in with personal checks — we received our packages at some indeterminate time in the future.

Fancy TVs had real wood cases surrounding the picture tube, they were thick and heavy. To change the channel we got up and turned a dial that clicked into place for each corresponding number, luckily there weren’t many channels to choose from. We watched TV shows at designated times. If we missed an episode we could catch it again in a rerun. With limited TVs, fighting or tantrums often controlled what was watched.

If we wanted to talk to a friend we called his house, asked his mom or dad if he was home, then talked until someone else needed the phone. A busy signal meant we kept calling over and over until whoever finally hung up. If events were cancelled, people would call around to let everyone know, some wouldn’t get the message and just show up, waiting for the party to begin.

If someone left the house, we typically wouldn’t hear from them until they got back home. Trends often traveled by cousins or clubs or camps. If we had questions about life we could ask a parent or sibling, our friends, or a teacher. If we needed a more extensive answer we could go to a library and browse through some books in the related category.

If we wanted to rant, we wrote cursive inside of notebooks that nobody read. If we were bored or lonely we had to make do. We had little to no contact with those outside of our immediate surroundings. Games typically required other participants. TV had limited programming and at times aired only reruns. Stores had limited hours and required transportation.

I appreciate the technological advances of today. When the Internet came into being it was like discovering a new world. Through the Internet I found companionship and purpose. I’ve spent about half my life within this virtual realm — exploring, observing, and interacting. It turns out that the next frontier wasn’t outer-space, but cyber-space — the world-wide interconnected consciousness of mankind. And through communication, we find unity. So it is with this thought that I welcome in the new year.

Technological Hubris

That those of old knew less is ridiculous.
What do you know, modern man?
You know how to press buttons.

Your survival relies on what you misunderstand.
As trust in technology grows, so does frailty.
A break in the chain and it crumbles away.

At least those of old knew life was beyond control,
and knowing, gave thanks for things received.
Yet you modern man, not knowing, thank yourself.

Imagining someone somewhere knows something,
depending on the surety of answers for solace,
believing in the fantasy of factuality.

A machine may function as expected,
but the underlying why is never known.
In your understanding, it might as well be magic.

So what do you know, modern man?
Living within a world beyond comprehension,
speaking spells into the ether.

Dirty Hands

The more a civilization relies on advanced technology to sustain itself, the more its foundation is built on what it does not understand. If something breaks, the civilization may crash, and primitive methods may be insufficient or forgotten.

Therefore, a goal of any civilization should be locally sustainable farming and manufacturing. While advanced technology is a worthy endeavor, it must be a layer on top of society, not its foundation. This, coupled with the human need for fulfilling activity, means humanity should seek direct experience with its surroundings.

In other words, what should the bulk of society be doing with its time? Should people play an active part in their own maintenance, harmonizing with their environment — or should they receive food pellets, becoming sheltered from nature while transported to jobs with outcomes too frivolous to appreciate?

Multitudes languish in roles without meaning, no sense of purpose or fulfillment — so why not seek the authentic life? Hands dirty, shaping their surroundings, communities growing and building what they consume. Or alternatively, continue on the path to isolation, eyes fixed upon screens, consuming an artificial experience created within remote factories.