No history yet

Introduction to Programming

What is Programming?

At its heart, programming is simply the act of giving a computer a set of instructions to perform a task. Think of it like writing a recipe for a very literal-minded chef. You need to list every single step, in the correct order, with no room for ambiguity. If you forget to say "preheat the oven," the oven will stay cold. If you just list "flour, sugar, eggs," the computer won't know what to do with them.

Computers are powerful, but they aren't smart in the human sense. They can't guess what you mean or fill in the blanks. They execute instructions precisely as they are given. Programming is the skill of breaking down a large task into these small, precise steps and communicating them clearly.

Speaking the Computer's Language

We can't write our instructions in plain English or Spanish. We need a special language that both humans can write and computers can understand. These are called programming languages.

Programming Language

noun

A formal language comprising a set of instructions that produce various kinds of output. Programming languages are used in computer programming to implement algorithms.

A programming language acts as a translator. At their most basic level, computers only understand binary code—a stream of ones and zeros. Writing directly in binary would be incredibly tedious and difficult for humans. So, we write in a language like Python or JavaScript, and a special program called a compiler or interpreter translates our code into the binary instructions the computer's processor can execute.

The Rules of the Game

Every language, whether human or computer, has rules. In programming, these rules are broken down into two key concepts: syntax and semantics.

Syntax

noun

The set of rules that defines the combinations of symbols that are considered to be correctly structured statements or expressions in a language.

Syntax is like grammar. It dictates how you must arrange words and symbols for the sentence to be understood. For example, in English, we say "The cat sat on the mat." The sentence "Sat the on cat mat the" has all the right words, but it's jumbled. It has incorrect syntax, and it's meaningless. Programming languages are even stricter about syntax. A misplaced comma or a forgotten parenthesis can stop a program from running at all.

Semantics

noun

The meaning of a legally formed string of symbols. It's about what the instructions actually tell the computer to do.

Semantics is the logic or meaning behind a correctly formed statement. Consider the English sentences, "The dog chased the cat" and "The cat chased the dog." Both have perfect syntax. But their meanings—their semantics—are completely different. In programming, you can write code with perfect syntax that doesn't do what you intended. The computer will happily execute your instructions, but the result will be wrong because the logic—the semantics—was flawed.

Syntax is the grammar. Semantics is the meaning. A program needs both to be correct.

Getting a feel for these concepts is the first step on your programming journey. Next, let's put them into practice.

Quiz Questions 1/5

What is the fundamental act of programming?

Quiz Questions 2/5

A programmer writes code to calculate the area of a rectangle (length * width), but accidentally writes length + width. The program runs without crashing but produces the wrong result. This is an error in the code's ____.