1.4. Source Code

Now let's take the definition of a computer program you saw earlier and add a few more words to make it more adequate.

A computer program is a list of instructions that we write using a programming language the computer understands.

This is a more useful way to think about everything but this sentence is not entirely true. I will explain what I mean by that in the next section. If we want to get started writing this list of instructions to the computer, there are many different programming languages we could use:

We'll talk about why there are so many, but as I said earlier, we're not going to focus on any one of these languages. We're going to see a lot of them.

So, I'll show you some older languages like C from 1972, some new ones like Swift released in 2014, some that are really popular right now like Ruby and Python and some other languages that were once popular but aren't any longer, like ALGOL. You'll notice a few things.

Some programming languages like COBOL seem to be all uppercase, others all lowercases.

Image

Fig 1.4.1: A program written in COBOL

Some languages use a lot of symbols, curly braces and semi-colons everywhere. Others don't. But yeah, you don't have to worry about memorizing any of those details. Right now, that's not necessary. That's not important because we're not using this course to find out what's true about one specific language; we want to know what's true about all of those languages.

Here’s the first truth:

To begin writing a computer program, writing instructions in any of these programming languages is simpler than many people realize.

We don't need to first go and download and install a whole bunch of special new applications onto our computer before we begin because when we write these instructions, we use plain text to do it. That means you could use the simplest, most basic text editor provided on your computer, like notepad on a windows PC or text edit on a Mac.

Programmers don't need a word processor like Word or Pages because we don't want any formatting here. Nothing is in bold or italics. Programming languages don't care about that and they don't care what font or font size you use. They just want plain text.

Well, regardless of programming language, there is another term you'll use for programming language instruction written in plain text. We just call this source code.

When a programmer tells you they spend all day coding or all-day writing code, they mean writing source code.

Image

Fig 1.4.2: Sample source codes

You might wonder why this is called source code. Is there any other kind of code? Well, yes there is. We'll get to that shortly. Let me be clear about something: I said you don't need any special software to write this source code and that's true, but you often want them. There are applications you can install on your computer that will make your life easier.

Most programmers don't just use notepad or text at it. We have specialized editors designed for programmers that add things like color coding and can help correct simple mistakes in programming the same way that a word processor can help with spelling and capitalization. See some examples of popular text editors in Fig 2.3 and Fig 2.4.

Now there are many of these editors available. There are different ones for different languages and different operating systems. Here’s a list of some of them:

And so much more.

Image

Fig 1.4.3: Sublime Text editor

Image

Fig 1.4.4: Atom text editor

We'll dive deeper into text editors later on in the course.