Check Out Dave's New game for iPhone and iPod Touch: Smiled Out!

Basic Programming Principles

Welcome to my programming tutorial series, Learn To Program Using Python! This series is intended to seed your mind with the basics of computer programming with the Python programming language. I hope you enjoy the series, and more importantly I hope that you come away equipped with the primary knowledge required to begin your journey as a computer programmer.

Part 1 – Basic Programming Principles

What Is A Programming Language?

In the beginning, there were only the bits. The bits were without form, and void. Over time, many intelligent and talented people have shaped those rudimentary ones and zeros into readable text. It is this text that we call the “programming langugage.” Rather than having to sit at a computer and type in 0101 0111 0101 1111 as our forefathers have done, we lucky ones have the luxury of typing meaningful text such as “a = b + 1″ and “print a”.

A programming language allows the programmer to easily translate their thoughts and intended processes into a “script” which the computer can then read and turn into the machine code which it understands.

Think of yourself as a screenwriter who is writing a movie. You write down what you want to happen in the movie, and then the producers and director will take your intentions and combine them with talent and other resources in order to produce a finished product. This finished product can then be watched over and over again for your enjoyment.

In the example above, the script is the “program” that you will be writing. The prose used to create the script is the “language.” The language can change, as the same movie with the same scenes could be written in English or French, or even German. However the emotions and actions that are portrayed in the resulting movie will be exactly the same.

The language that we will be using is called Python, and it was originally developed by Guido van Rossum. Python is a great language for beginners because it has an amzing synergy of power, readability, and industry acceptance. It is simple enough that the fundamentals of programming can be taught at the most basic levels yet complex and robust enough that real-world tasks can be accomplished with it.

When learning to program, it is a good idea to first think about how the world around you works. If you have ever been in a science class in school then you know that everything that takes place in the universe has a cause, and that every change comes about following a set of rules. We call those rules physics. The earth rotates around the sun because it is in just the correct position that the sun’s gravity pulls on it with the same force that inertial energy would cause it to careen wildly out into space. A plant grows because energy from light is harnessed and photosynthesized into sugars to provide chemical energy.

The point is that everything that occurs in the universe follows some sort of process which is governed by rules. What happens inside a computer is no different. The video game that you play, the word processor that you operate, all follow a set of rules which have been laid out by their respective designers. A computer simply applies a set of rules to a given input in sequence to produce an output. In nature, those rules are the laws of physics. In a computer, these rules are defined in code by the programming language.

The purpose of programming is to provide the correct set of rules, in the correct sequence, to achieve a desired result. These rules will be executed by the computer on a set of data which will then be interpreted in the output.

Pages: 1 2 3 4 5