«

»

Feb 21

Programming 101: Part 1

So I’ve been on a programming kick the last week or so, and so I decided I’d write a how-to on the basics of how it works.

Why the hell would I want to learn to program?

Well Mr. Negativity, I’ll tell you.

Just like anything else you learn (so long as it’s something that’s actually true), it’ll give you greater insight into how the world works. In the case of programming, you’ll have greater insights into how computer work (or don’t work). Being that computers are everywhere this isn’t a bad thing to understand by any means.

copied from http://ih0.redbubble.net/image.4503155.8968/fc,300x300,white.jpgAfter all anything that’s far enough above your current level of understanding is magic. In my current line of work, most people I deal with probably still think computers are magic I could probably tell most of them that their computer needs an exorcism when they get an error and they’d run out and find the nearest priest.

So let’s get down to business.

How are computers programmed?

At their most basic level, computers are nothing more than a giant back of switches. Some switches are turned off and some are turned on (in extremely rapid succession) and you viola you get what you’re reading now.

But rather than thinking a bout things in terms of on and off, binary was developed (this was of course after a base 10 system was tried, but it was incredibly inaccurate and unwieldy). The word implies two states, on and off or 1 and 0 respectively. It’s an incredibly simple system that brings with it an immense amount of power (not the least of which is being able to count to 31 on 1 hand!).

The most basic unit in binary is called a bit  it’s a single 1 or 0. The next common unit is a byte it’s a group of 8 bits.

I’m not going to into this any farther than I already have (really it’s because I don’t know much more) but if you’re really interested wikipedia has an article on Binary here: http://en.wikipedia.org/wiki/Binary_numeral_system

Now binary is really cool and all (think counting to 31 on one hand), but it’s really difficult keep track of things at such a low-level. So this is where languages come in.

The next level up from binary is called Assembly it’s still a very low-level. I don’t have much experience with assembly (I pretty much know what it is, but that’s it). But basically it works at the hardware level, specifically the components inside the processor.

Many games used to use assembly in their high-performance graphics routines. They may still use this technique to speed up critical areas, but last I paid attention to this area compiler optimization was generating code that was almost as fast as pure assembly.

Assembly is difficult to use because you have to keep track of where in the processor information is and where it needs to go (you can’t just add or subtract things, you have to move the data to the appropriate portion of hardware).

If you want to learn more about assembly checkout wikipedia http://en.wikipedia.org/wiki/Assembly_language.

Higher level languages

So once you move beyond assembly you start getting into higher level languages.

There are probably just about as many languages out there as there are programmers (seriously). All of them are designed to excel in different areas.

I break down high level languages into the following:

  • Compiled
  • Interpreted

A compiled language is a language that is written out and then broken down into a lower level construct (byte-code). From there some languages are taken down even farther into machine code.

An interpreted language can be compiled into byte-code but is generally just pumped into another program that takes it into byte-code “on the fly.”

Both compiled code and interpreted code have their uses, compiled code what most applications you run directly from your computer are written in (e.g. your web browser, music player, etc.). Interpreted code is what website’s are at least partially written in.

Compiled languages have a huge speed advantage over compiled languages as the computer has to do less processing to understand what they’re trying to do. Code that’s been taken to machine code is even faster than compiled because it’s in a language the hardware understand directly.

While compiled languages are great for speed, they’re generally limited in their application as the closer to hardware code gets, the fewer platforms it will run on.

Interpreted languages however will run on any system that has an interpreter for the language. But as I said before that comes with a price in speed.

Getting started

So what do you need to actually get moving in this grand pursuit?

Well first you’ll need to decide on a language to program in, from here on out I’m going to be favoring PHP simply because it’s so damned useful and easy to learn.

The downside to learning PHP is that you’ll need access to an environment that supports it. Every web host I can think of has support for PHP (if yours doesn’t I would seriously consider switching, that also includes if they’re still using PHP 4 or earlier).

Notice

I ran a quick check for “free web hosting” and found http://www.000webhost.com/ I don’t endorse these people by any means (I haven’t used them or heard of them before now) but it’s an option.

On the upside (this is one of the reasons I love PHP) you can get the binaries and set it up in conjunction with Apache on your local computer. For information on doing that please see: http://www.wikihow.com/Install-WAMP or for Linux: http://www.lamphowto.com/ and if you’re on a Mac figure out how to be different on your own (yes, my hatred of Macs is alive and well).

Aside from the environment to run the code, you’ll need a code editor. You can use a base text editor such as Notepad, but I’ve found Notepad++ to be a great utility. It has syntax highlighting among other useful features. You can download it here http://notepad-plus-plus.org/

We’ll start to delve into the black art that is programming in the next part.

- Stay Tuned!

Related posts:

  1. Programming 101: Part 2
  2. Mac Myths: Part 1 – Viruses

1 ping

  1. Programming 101: Part 2 » All Tech - No Logic

    [...] « Programming 101: Part 1 [...]

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge