β Define what a programming language is and its purpose.
β Differentiate between low-level and high-level programming languages.
β Understand the role of a compiler and an interpreter in executing code.
What is a Programming Language?
A programming language is a formal language with a set of instructions used to create software programs and implement algorithms.
Think of it as a special vocabulary and set of grammar rules to communicate with a computer.
Analogy: A programming language is like a recipe. The ingredients and steps (the code) must be written in a language the chef (the computer) understands to produce a final dish (the output).
Activity: The Recipe Analogy
Match each recipe component to its programming equivalent. Select from the dropdown and press Check.
Recipe Component
Your Answer
The recipe book β the rules and vocabulary
The written recipe β your specific instructions
The chef β who reads and executes the recipe
The final dish β what comes out at the end
The Language Spectrum
Programming languages exist on a spectrum, from the computer's native tongue to languages that resemble human speech.
Low-Level
Closer to Hardware βοΈ
Less abstraction
Faster, but harder to use
High-Level
Closer to Human π§βπ»
More abstraction
Slower, but easier to use
Activity: Sort the Languages
Click each item to place it in the correct category. Is it Low-Level or High-Level?
High-level source code must be translated into low-level machine code before the CPU can execute it.
Compilers vs. Interpreters π
The translation is handled by two types of programs: Compilers and Interpreters.
Compiler
Translates the entire program at once.
Creates a separate executable file (e.g., .exe).
Execution is generally faster.
Errors are reported after the whole program is checked.
Examples: C, C++, Java
Interpreter
Translates the program line by line.
No separate executable file is created.
Execution is generally slower.
Errors are reported as soon as they are found.
Examples: Python, JavaScript, Ruby
How a Compiler Works βοΈ
Source Code
my_program.cpp
β‘οΈ
Compiler
Translates all at once
β‘οΈ
Executable File
my_program.exe
Key Idea: Compile once, run anytime. The translation and execution are two separate steps.
How an Interpreter Works β‘
Source Code
my_script.py
β‘οΈ
Interpreter
Translates & Executes Line by Line
β‘οΈ
Immediate Output
Program runs directly
Key Idea: Translation and execution happen at the same time, every time you run the script.
Application in Nepal π³π΅
The choice of language impacts many local tech solutions.
Which language for which job?
Building a Digital Wallet (e.g., eSewa, Khalti): Performance and security are critical. Compiled languages like Java or Kotlin (for Android) are a strong choice.
Developing a News Portal (e.g., OnlineKhabar): Rapid updates and content management are key. Interpreted languages like PHP or JavaScript (with frameworks) allow for fast development cycles.
Data Analysis for Trekking Tourism: Scripting and quick analysis are needed. Python is ideal due to its powerful data science libraries and ease of use.
Key Takeaways
Programming languages are the tools we use to give instructions to computers, ranging from low-level to high-level.
Low-level languages (Machine, Assembly) are close to the hardware, offering speed but complexity.
High-level languages (Python, Java) are close to human language, offering simplicity and portability.
Compilers translate an entire program at once into an executable file.
Interpreters translate and execute a program line by line, at the same time.