Being a professional computer nerd is not, in some ways, unlike being a doctor.  It’s one of those professions where people want you to do things for you once they find out it’s what you do.  If you’re a doctor and somebody finds out on a personal level, they might tell you about an ache or a pain they’re experiencing.  As a nerd, they want you to fix their computer.

It goes beyond that, though.  Nobody ever asks a doctor how to operate, but we computer nerds sometimes get asked how to program.  We go through a lot of education–self-education or school-taught–to learn how to do what we do, but people want to skip all that and have us teach them (often in a very short time frame) all there is to know about writing computer programs.  I guess most folks don’t realize the above-mentioned educational process required to learn how to write good software.  It’s well-known, after all, that doctors invest a lot of time in education.  Most, by my understanding, spend close to a decade in college learning their profession.

With this in mind, I am going to present an introduction to programming.  To start this discussion, I will answer a very basic question:  What exactly is a computer program?  Essentially, it’s a list of instructions a computer can interpret and act upon.  In fact, for some computer programs, the thing running the software is called an interpreter.  Computer languages which use an interpreter are often called scripting languages.  For example, Javascript, with the word script right there in the name, is an interpreted programming language.  The interpreter for it is built into internet browsers like Internet Explorer and Firefox.

Javascript is an interesting example of a scripting language as it shows a little bit how languages evolve.  The earliest versions of Javascript were purely scripts.  Anytime you saw Javascript code, it was in its final form.  Nowadays there are compilers for it, although these compilers don’t create what is called executable code.

Let me take a step back and explain that.  Regular computer languages are typically compiled into what’s called executable code.  The code is written like scripting languages using keywords and variables and such (I’ll explain that later), but by itself nothing can be done with the code.  Instead, a process is run which turns the code into something a computer more directly understands.  That something is a file whose name ends in .exe or .dll, for example.  The .exe files, called executables, are something Windows can natively handle.  Actually, on a very low level, interpretation is still happening, but it’s Windows (or whatever operating system you’re using) does instead of some application Windows is running.  An executable file has very little in it a human will recognize and be able to understand.

So what use is a compiled Javascript program if it’s not executable like a .exe?  This is actually a security concept somebody came up with a few years ago.  As mentioned above, compiling code turns it into something humans cannot understand.  So if somebody downloads a compiled javascript file, they cannot see what it’s doing just by looking at it.  Uncompiled Javascript code is easily readable.  As an added bonus, a compiler will find errors in the code.  In fact, a compiler will not produce a compiled file if it finds errors in the coding.

Okay, so now we know a little about what a program is.  How does one write a program, then?  Well, it’s a creative process, like writing a story.  Perhaps that’s why I enjoy writing computer programs, or maybe why I like writing stories or both.  I am a creative person and the process for writing a story or a program is, after a fashion, very similar.  There is an opening to a story or program, things which take place in the middle, and finally a conclusion.  Unlike a story, a computer program may jump around a little bit.  This is because some pieces of code may get reused and are thus separated into subroutines.  True, some stories will repeat parts already told sometimes, but you don’t see a book passage which says, for example, “Re-read pages 50 to 55 and come back here.”  (Yes, I know about the do-it-yourself adventure stories which do this kind of thing, but normal stories don’t do that.)

Beyond that…well, beyond that it gets a little more complicated.  Modern computer languages often have a few things in common, but like written languages they still have many differences between them.  So I will stop here today.  Hopefully you have at least a little better understanding of programming and what it means to write software.  If not, well…ask a nerd.  See you tomorrow.