--:-- --
↓ Scroll for more

Unit 4.4

An Introduction to Programming Languages

IT 231: IT and Application

Learning Objectives 🎯

By the end of this session, you will be able to:

  • ✅ 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).

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

🔍 Low-Level Languages

These languages provide little to no abstraction from a computer's hardware and are very close to machine code.

Machine Language

  • The "native" language of the CPU.
  • Consists of binary code (0s and 1s).
  • Not human-readable.
01001000 01100101 01101100 01101100 01101111

(This is "Hello" in binary)

Assembly Language

  • A step above machine code.
  • Uses mnemonics (short words) like MOV, ADD.
  • Requires an assembler to convert to machine code.
MOV AL, 61h

(Move the value 61 (hex) into register AL)

🚀 High-Level Languages

Designed to be easy for humans to read, write, and maintain, with strong abstraction from hardware details.

Characteristics

  • English-like syntax
  • Easier to learn and debug
  • Portable across different computer systems
  • Focus on logic, not hardware management

Popular Examples

  • 🐍 Python
  • ☕ Java
  • 🌐 JavaScript
  • #️⃣ C#
  • ++ C++

The Translation Problem

Computers only understand machine code, but we write in high-level languages. How do we bridge this gap?


🧑‍💻
High-Level Code
➡️ ➡️ ⚙️
Machine Code

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.

Thank You!

Any questions?


Next Up: Unit 5 - Introduction to Web Development

Back to IT 231 Course Home