Learning to Program – Part 1

Introduction

Everyone learns in different ways.  And learning to program is one of those things that is unique to the individual.  I learned by reading books and researching online, then applying that in sample programs.  One of the first things you need to decide is the programming language you want to become proficient in.

There is a lot of debate in the software world about what language is best for each application, but I still feel that some languages are better for learning than others.  For example, C# is a great language because it is so forgiving and errors are much more clear and concise.  C++ is a powerful language, but it tends to have more obscure errors and allows a much lower level access to system resources.  With that said, the language is mostly irrelevant as most high level languages have similar constructs (loops, variables, functions) and once you learn one language, it is very easy to pick up other languages.

For this series, I’ll be using C# and what we refer to in the software world as pseudocode.  Pseudocode is basically a way to write the logic of the program in a way that is not language specific.

One final note before we get started.  At first, I won’t be digging into code, and this may feel frustrating.  However, I feel it’s important to understand the concepts before we try to make something actually run.

What is a program?

Let’s begin by answering the question of: “What is a program?”  A computer program as defined on Wikipedia is “a sequence of instructions written to perform a specified task with a computer.”  Simply put, it is an ordered list of things to do.  If I had to write a program for my son to make a peanut butter and jelly sandwich I may write a pseudocode program that looks something like this:

   1: breadOne = GetBread()

   2: breadTwo = GetBread()

   3:  

   4: jelly = GetJelly()

   5: peanutButter = GetPeanutButter()

   6: plate = GetPlate()

   7: knife = GetKnife()

   8:  

   9: while ( NotCovered(breadOne) )

  10:     Spread(jelly, breadOne, knife)

  11: while ( NotCovered(breadTwo) )

  12:     Spread(peanutButter, breadTwo, knife)

  13:  

  14: PutOn(plate, breadOne)

  15: PutOn(plate, breadTwo)

This is obviously a simple example designed to help you understand the basic concept of programming and reading pseudocode.  Lines 1 and 2 are two get our two slices of bread. Lines 4-7 give us all the other supplies we need.  Lines 9 and 10 are to spread jelly on the first slice of bread.  Lines 11 and 12 spread peanut butter on the other slice.  Finally 14 and 15 put those slices on the plate.  This could be far more complex, but I kept it simple to ensure you can follow the basic flow.

Now, back to the definition.  We have a sequence of instructions written to perform a specified task, but this is in a format that a human can read.  So the last part of the programming process is to compile this code into something a computer can read.  The compiler will take these instructions and turn them into a very low level machine code that isn’t readable by a human, but it is very efficient for the computer to process.

In short, that is all there is to programming! In the next part we’ll start talking about tools of the trade.  There are a multitude of tools out there and deciding what to use for any given task can be overwhelming.

If there is a particular topic you would like to see discussed, please don’t hesitate to ask and I’ll try to answer it in comments or as it’s own post if the response demands the space.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment