Strings, Numbers, and Booleans

Variables hold values, but values are not all the same kind of thing. The number 42, the text "42", and the truth value true are three different species, and every language treats them differently. This lesson covers the three types you will meet constantly: numbers, strings, and booleans.

Think of types as shapes of container. Numbers are for counting and arithmetic. Strings are for anything humans read: names, messages, labels. Booleans hold exactly one of two values, true or false, and exist to answer yes/no questions. You cannot multiply a sentence, and you cannot ask a number whether it is true, because the shapes do not fit.

A type is the set of operations a value supports. Numbers support arithmetic and comparison. Strings support concatenation, length, and search. Booleans support and, or, not, and driving an if. Type errors are what happens when code asks a value for an operation outside its set, and languages differ mainly in when they catch that: before the program runs, or in the middle of running it.

Numbers: the machine's native tongue

Numbers are what the hardware actually computes with. Whole numbers and decimals behave slightly differently under the hood (a distinction Go and Java make you spell out, and scripting languages mostly hide), but the operations are universal: add, subtract, multiply, divide, compare. Comparisons deserve a highlight: an expression like score >= 80 is not a number. It produces a boolean, and that little fact is the hinge that connects arithmetic to decision making in the next lesson.

Strings: where the meaning lives

A string is a sequence of characters: a name, an error message, a URL, a secret key someone should not have shipped. Programs can measure strings, glue them together, and drop values into them. But their real significance in this course is different: strings are the only part of a compiled or obfuscated program that still speaks human. Long after every variable name is gone, the literal text "invalid license key" survives, because the program needs it at runtime to show the user.

That is why the very first thing an attacker does with an unfamiliar file is search its strings, and why string protection is a pillar of every serious obfuscator. You will meet both halves of that fight in Levels 4 and 5.

Booleans: the smallest type that runs the world

A boolean is true or false, nothing else. Every if statement, every loop condition, every access check ultimately boils down to one boolean read at one moment in time. Booleans combine with and, or, and not, so complex conditions are just small boolean circuits built in code.

One idea, seven spellings

The switcher below shows the three types in each course language, including how each language reports a value's type. The deeper split to notice: Java and Go declare types up front and refuse to even start a program with a type mistake in it, while Lua, JavaScript, Python, Ruby, and PHP discover type errors while running.

Feel the types in your hands

The playground below runs the course's sealed teaching language, which has exactly these three types. Run it, then try the experiments in the comments. The error messages are part of the lesson: this is a language telling you a shape did not fit.

Languages that convert types silently create a special class of bug. JavaScript famously answers "2" + 2 with "22" but "2" - 2 with 0, because + means concatenate when a string is present and - never does. PHP historically compared "abc" == 0 as true. These coercion rules matter to reverse engineers too: deobfuscation tools must replicate them exactly, or the "cleaned" program quietly behaves differently from the original. Any transformation of a program, hostile or friendly, has to be semantics-exact, and coercion is where careless tools slip.

Numbers compute, strings carry human meaning, booleans decide. Comparisons turn numbers into booleans, which is how arithmetic becomes decisions. And because strings still speak human after every other readable thing is stripped, they are the first target on both sides of the code protection fight.

Frequently asked questions

Are there more types than these three?

Yes. Real languages add an empty value (nil, null, None), collections like arrays and maps (two lessons ahead), and functions as values. But numbers, strings, and booleans are the atoms nearly everything else is built from, and the teaching playground keeps to exactly those three so the machinery stays visible.

Why do obfuscators care so much about strings specifically?

Because strings are the only content in shipped code that remains directly human-readable with zero effort. Names can be stripped and structure can be mangled, but a literal like an API endpoint or an error message has to exist at runtime. String encoding hides it from a static reader; the honest limit is that a running program must eventually decode it, which Level 5 demonstrates.

Keep learning

  • Variables and Assignment
  • Conditionals: Making Decisions
  • String Obfuscation: Hiding the Text Attackers Search First
  • Strings: The First Thing Attackers Read
  • JavaScript Obfuscator
  • Python Obfuscator
  • Java & JAR Obfuscator

All lessons