No history yet

Introduction to Programming

What Is Programming?

At its heart, programming is simply giving a computer a set of instructions to follow. Think of it like a recipe. A recipe gives you a list of ingredients and a sequence of steps to turn them into a meal. A computer program does the same thing, but the ingredients are data and the steps are actions the computer takes.

Computers are incredibly fast and powerful, but they are not smart on their own. They can't guess what you want them to do. You have to spell out every single step, from adding two numbers to displaying a picture on the screen. Programming is the art of writing these incredibly precise, step-by-step instructions.

A program is a detailed plan that a computer can follow to achieve a specific goal.

Speaking the Computer's Language

We can't write instructions for a computer in English or Spanish. We need a special language that is structured and unambiguous, something a machine can understand without confusion. These are called programming languages.

Lesson image

Just like human languages, programming languages have their own vocabulary and grammar rules, which we call syntax. If you break these rules, the computer won't understand your instructions. For example, you might need to end a command with a semicolon, just like you end a sentence with a period.

Ultimately, a computer’s processor only understands one thing: machine code, which is a stream of ones and zeros. Programming languages are a bridge, allowing us to write instructions in a way that’s closer to human language, which can then be translated into the binary that the hardware understands.

Translating Our Instructions

So how does our human-readable code get turned into machine code? Through a special program called a translator. There are two main kinds: compilers and interpreters.

A compiler is like a book translator. It reads your entire program (the source code) all at once. It checks for any syntax errors, and if everything is correct, it translates the whole thing into a separate, executable file written in machine code. You then run that new file to see your program in action. Languages like C++ and Java use compilers.

An interpreter, on the other hand, is like a live translator at a meeting. It reads your source code one line at a time, translates that line, and immediately runs it. If it finds an error, it stops right there. There's no separate file created; the interpreter executes the code directly. Python and JavaScript are popular languages that use interpreters.

Here's a quick summary of the differences:

FeatureCompilerInterpreter
When it TranslatesTranslates the entire program before running.Translates and runs the program line by line.
OutputCreates a separate executable file.No separate file; executes code directly.
Error CheckingReports all errors at once after checking the whole program.Stops at the first error it finds.
Execution SpeedGenerally faster, because translation is already done.Generally slower, because it translates as it runs.

The basic structure of any program, whether it's compiled or interpreted, involves taking some input, processing it according to the instructions you've written, and producing some output. It could be as simple as taking two numbers (input), adding them (processing), and displaying the result (output).

Quiz Questions 1/5

What is the primary purpose of programming?

Quiz Questions 2/5

The set of rules, vocabulary, and grammar that dictate how to write instructions in a programming language is called its ______.

Understanding these core concepts—what programming is, why we use languages, and how they get translated—is the first step on your journey. From here, you can start to explore the specific syntax and features of your first language.