Introduction to Programming Languages and Core Concepts, CS101 – Study Notes
offline

Difficulty: Beginner | Prerequisites: None


Big Picture

This topic is the foundation for everything else in CS101. Before you write a single line of code, you need to understand what programming languages are, how they differ from one another, and the core building blocks that nearly all of them share: variables, control flow, functions, and objects. If you are coming into this cold, this is the right place to start. Every later topic in the course builds on these ideas.


TL;DR

Programming languages are formal languages that tell computers what to do. They range from low-level (close to hardware) to high-level (closer to human language). The fundamental concepts you will use in any language are variables, data types, control structures, functions, and objects.


Key Terms

Programming language

A formal language with a defined set of rules, used to communicate instructions to a computer. Think of it as a shared vocabulary between you and the machine.

Machine code

The binary instructions a computer's processor can execute directly. Every program you write, regardless of language, is eventually translated into machine code.

High-level language

A programming language that abstracts away hardware details, making it easier for humans to read and write. In simple terms, this means you write something closer to English than to ones and zeroes. Examples: Python, Java, JavaScript.

Low-level language

A programming language that provides little abstraction from the hardware. You get more direct control over the processor and memory, but the code is harder to read and write. Assembly language is the classic example.

Scripting language

A language that is interpreted (executed line by line at runtime) rather than compiled in advance. In simple terms, this means you can write a script and run it immediately without a separate build step. Often used for quick prototyping and automation. Examples: Python, JavaScript, Bash.

Compiled language

A language whose source code is translated entirely into machine code by a compiler before it runs. The resulting executable tends to be faster, but you must compile before you can test.

Interpreted language

A language whose source code is read and executed line by line by an interpreter at runtime, with no separate compilation step.

Syntax

The rules that define how valid statements are constructed in a programming language. Think of it as grammar for code: where the semicolons go, how you declare a variable, what brackets mean.

Semantics

The meaning of syntactically valid statements. A program can follow all the grammar rules and still do the wrong thing, which is a semantic error.

Variable

A named storage location in memory that holds data. Think of it as a labelled box you can put a value into, read from, or change.

Data type

A classification that tells the language what kind of value a variable holds and what operations are valid on it. Common types: integers, floating-point numbers, strings, and booleans.

Integer

A whole number (positive, negative, or zero) with no decimal point.

Floating-point number

A number with a decimal point, used to represent fractions and real numbers. In simple terms, this is how computers handle numbers like 3.14 or -0.5.

String

A sequence of characters, typically used to represent text. In most languages, strings are enclosed in quotation marks.

Boolean

A data type with only two possible values: true or false. Used heavily in conditions and control flow.

Control structure

A statement or block that controls the order in which instructions execute. Without control structures, code runs top to bottom with no branching or repetition.

If-else statement

A control structure that executes one block of code if a condition is true and a different block if it is false.

Loop

A control structure that repeats a block of code as long as a condition is met. Common types: for loops, while loops.

Switch statement

A control structure that selects one of many code blocks to execute, based on the value of a variable. An alternative to long chains of if-else.

Function

A named, reusable block of code that takes input (parameters), performs a task, and returns a value. Think of it as a mini-program within your program.

Procedure

Like a function, but it does not return a value. It performs an action (printing to screen, writing to a file) without handing a result back.

Object-oriented programming (OOP)

A programming paradigm that organises code around objects, each of which bundles data (properties) and behaviour (methods) together. In simple terms, this means you model real-world things as self-contained units in your code.

Object

An instance of a class that holds its own data (properties) and can perform actions (methods). Objects can interact with other objects.

Property (attribute/field)

A piece of data stored inside an object.

Method

A function that belongs to an object and operates on that object's data.


Core Content

Types of Programming Languages – High-Level vs. Low-Level vs. Scripting

  • High-level languages abstract away memory management and hardware details, letting you focus on logic. Most of the code you write in CS101 will be in a high-level language.

  • Low-level languages give you direct control over the CPU and memory. Assembly language is the primary example. You trade readability for performance and hardware access.

  • Scripting languages are interpreted at runtime. They skip the compile step, which makes them fast to iterate with. Python, JavaScript, and Bash are common scripting languages.

  • The boundary between these categories is not rigid. Python is both high-level and a scripting language. C is high-level relative to assembly but low-level relative to Python.

Syntax vs. Semantics – the Difference That Trips People Up

  • Syntax is about form: does the code follow the language's grammar rules?

  • Semantics is about meaning: does the code do what you intended?

  • A syntax error stops the program from running at all (missing semicolons, mismatched brackets). A semantic error lets the program run but produces the wrong result. Semantic errors are harder to find because the computer will not flag them for you.

Variables and Data Types – Storing and Classifying Data

  • A variable is a named location in memory. You assign it a value, and you can read or change that value later.

  • Every variable has a type. The type determines what the variable can hold and what operations make sense on it.

  • The four types you will see most often:

    • Integers – whole numbers (e.g. 0, 42, -7)

    • Floating-point numbers – decimals (e.g. 3.14, -0.001)

    • Strings – text (e.g. "hello", "CS101")

    • Booleans – true or false

Control Structures – Directing the Flow of a Program

  • Without control structures, code executes sequentially from top to bottom with no decisions and no repetition.

  • If-else lets you branch: "if this condition holds, do A; otherwise, do B."

  • Loops let you repeat: "while this condition holds, keep doing A." For loops and while loops are the two main forms.

  • Switch statements let you select from multiple options based on a single variable's value. Cleaner than a long if-else chain when you are comparing against many fixed values.

  • Control structures are how you implement algorithms. Sorting, searching, validation, and nearly every non-trivial program depends on them.

Functions and Procedures – Reusable Blocks of Code

  • A function is a named block of code you can call by name from anywhere in your program. It takes inputs (parameters), does something, and returns a result.

  • A procedure is the same idea, but it does not return a value. It performs an action and finishes.

  • Functions and procedures let you break a large problem into smaller, manageable pieces. This is called modularisation.

  • Reusability is the key benefit. Write the logic once, call it wherever you need it.

Object-Oriented Programming – Bundling Data and Behaviour

  • OOP organises code around objects rather than a sequence of instructions.

  • An object bundles together properties (the data it holds) and methods (the things it can do).

  • Objects can interact with other objects by calling each other's methods.

  • Java, Python, and C++ are the most commonly cited OOP languages. CS101 will likely use one of these.

  • OOP makes it easier to model real-world entities: a "Student" object might have properties like name and GPA, and methods like enrol() and graduate().


Real-World Applications

Programming languages are behind every piece of software you use. High-level languages like Python power data analysis, web applications, and machine learning. Low-level languages like C and assembly are used in operating systems, embedded systems (your car's engine control unit, for instance), and performance-critical applications like video game engines. Scripting languages automate repetitive tasks, from renaming thousands of files to deploying web servers.


Common Misconceptions

  • "Syntax errors and semantic errors are the same thing." They are not. A syntax error means the code cannot even run. A semantic error means the code runs but produces incorrect results. The second is more dangerous because the compiler or interpreter will not catch it for you.

  • "Scripting languages are not real programming languages." This is a common but incorrect belief. Scripting languages are fully capable programming languages. The difference is in how they are executed (interpreted vs. compiled), not in their power.

  • "Functions and procedures are the same thing." Close, but distinct. A function returns a value; a procedure does not. In practice many languages blur this line (Python uses def for both), but the conceptual distinction matters on exams.

  • "Object-oriented programming is the only paradigm." OOP is one of several paradigms. Procedural, functional, and logic programming are others. Many modern languages support multiple paradigms.


Why It Matters / Exam Flags

⚠️ Expect a question asking you to distinguish syntax errors from semantic errors, with an example of each.

⚠️ Know the difference between high-level and low-level languages, and be able to give examples of each.

⚠️ Be able to explain the difference between a function and a procedure.

⚠️ Understand what an object is in OOP: properties (data) + methods (behaviour), bundled together.

⚠️ Compiled vs. interpreted is a common short-answer or multiple-choice topic.


Quick Self-Test

True or false: A program with correct syntax cannot have errors.

A: False. It can still have semantic errors (correct grammar, wrong meaning).

Fill in the blank: A _______ is a named storage location in memory that holds data.

A: Variable.

True or false: A procedure returns a value.

A: False. A procedure performs an action but does not return a value. A function returns a value.

Fill in the blank: In OOP, an object bundles together _______ and _______.

A: Properties (data) and methods (functions/behaviour).

True or false: Scripting languages must be compiled before they can run.

A: False. Scripting languages are interpreted at runtime.


Practice Q&A

Q: What is the difference between syntax and semantics in a programming language?

A: Syntax is the set of rules for constructing valid statements (the grammar). Semantics is the meaning of those statements. A program can be syntactically correct but semantically wrong.

Q: Name three common data types and give an example value for each.

A: Integer (42), floating-point number (3.14), string ("hello"). Boolean (true) is also acceptable.

Q: What is the key difference between a function and a procedure?

A: A function returns a value. A procedure does not.

Q: What are the three main types of control structures discussed in this topic?

A: If-else statements, loops, and switch statements.

Q: In object-oriented programming, what two things does an object bundle together?

A: Properties (data) and methods (functions that operate on that data).

Q: Explain one advantage of using functions in a program.

A: Functions allow you to write a block of logic once and reuse it from multiple places in the program. This improves code reusability and makes the program easier to maintain.

Q: What distinguishes a high-level programming language from a low-level one?

A: A high-level language provides abstractions that make it easier for humans to read and write code. A low-level language provides more direct access to hardware but is harder to read and write.


Connections to Other Topics

This material connects to every subsequent topic in CS101. Variables and data types are prerequisites for understanding arrays and data structures. Control structures underpin algorithm design (sorting, searching). Functions and procedures lead directly into recursion. OOP is the foundation for later units on inheritance, polymorphism, and design patterns.


Related Terms / Search Tags

programming language, formal language, machine code, binary, high-level language, low-level language, scripting language, compiled language, interpreted language, syntax, semantics, syntax error, semantic error, variable, data type, integer, int, float, floating-point, string, boolean, bool, control structure, control flow, if-else, conditional, loop, for loop, while loop, switch statement, function, procedure, subroutine, method, modularisation, code reusability, object-oriented programming, OOP, object, class, property, attribute, field, method, Java, Python, C++, CS101, UCF, Computer Science I