What Is Programming?

1.BUG-142: Group Discount Not Applied

A

In this chapter

We'll learn what programming really is, what a programming language is, and the difference between syntax and semantics — using Anna's very first bug ticket.

10–12 min

The Problem in Real Life

Week seven. For the first time, Anna's name is on a real ticket in the team's task board:

BUG-142 — Group discount not applied for 5 tickets: a college bought exactly 5 tickets for the comedy night and paid full price. The website says "Groups of 5 or more get 10% off." The college wants its money back, and Samantha wants to know why it happened.

Anna opens the pricing code. She can read some of it — words like if, return, price — but she's never changed real code that real customers pay through. Her hands hover over the keyboard.

A

One wrong change here and people pay the wrong price. Where do I even start?

Anna

"Writing Code" vs. Giving Exact Instructions

Computers do exactly what you say

Not what you meant — exactly what you wrote. That's both the power and the danger.

Two kinds of mistakes

Code can break the language's rules, or follow the rules perfectly and still do the wrong thing.

What Is Programming?

John pulls up a chair. "Before you change anything, let's be clear about what code actually is."

Programming is writing instructions that tell a computer exactly what to do, step by step. A program is like a very detailed recipe for a cook who follows every word literally and never guesses. If the recipe says "add salt" but not how much, a human cook guesses. A computer can't — it needs everything spelled out.

A programming language is a language made for writing those instructions. It's much smaller and stricter than English: a few dozen keywords, and exact rules for how to combine them. JavaScript, Python, Java, C# and Go are all programming languages. In Act 04 we saw how the computer translates them into machine code; here we learn to write them.

Every programming language has two sides:

  • Syntax: the grammar rules — which words, brackets and symbols are allowed, and in what order. A missing bracket or a misspelled keyword is a syntax error. The computer refuses to run the code at all and tells you roughly where the problem is. Syntax errors are annoying but easy, because the computer finds them for you.
  • Semantics: the meaning — what the code actually does when it runs. Code can have perfect syntax and still do the wrong thing. This is a logic error (also called a bug in the meaning), and the computer can't warn you about it, because it has no idea what you meant.
Table — Syntax error vs. logic error
FeatureSyntax errorLogic error (bug)
What's wrongThe code breaks the language's grammarThe code means the wrong thing
Does it run?NoYes — it runs happily
Who finds it?The computer, right awayYou, by testing or a user's complaint
Exampleif (count >= 5 { (missing bracket)if (count > 5) when you meant 5 or more

Open any web page, press F12, click Console, and type these lines one at a time.

Your first JavaScript, in the browser console
console.log("Hello from BlueTicket"); // prints a message
2 + 3 // 5
"Anna".length // 4 — how many letters

console.log is how a program prints text so you can see it. Everything after // is a comment for people.

John points at the ticket. "BUG-142 isn't a syntax error. The code runs every day without complaining. Thousands of tickets are priced through it. It's a semantics problem: the code does exactly what it says — it just says the wrong thing."

That's the most important mindset in programming: when the code is wrong, the computer is never confused. It is doing precisely what the code tells it. Your job is to find where what the code says differs from what you meant.

About the examples in this Act: they're in JavaScript, the language BlueTicket uses. You can try any of them yourself: open your browser, press F12, choose the Console tab, and type. Variables, conditions, loops and functions work the same way in almost every language — only the exact spelling changes.

Key Takeaway

Programming is writing exact, step-by-step instructions in a programming language. Syntax is the language's grammar — break it and the code won't run. Semantics is what the code means — get it wrong and the code runs perfectly while doing the wrong thing.

Why This Matters

Every bug Anna will ever fix is one of these two kinds. Syntax errors are found in seconds; logic errors are what real debugging is about. Knowing which kind you're facing tells you where to look — and BUG-142 is her first real logic error.

Anna knows what kind of problem she has. To find it, she needs to read the pricing code properly — starting with the values it stores and works with.

Next