Programming Languages
Every computer program communicates instructions to a machine, but computers don’t naturally understand human language. Programming languages form the bridge between what we want the computer to do and what the machine can actually execute. Understanding the spectrum—from raw machine code to high-level languages that read almost like English—gives you insight into how software works at different levels of abstraction.
Programming Languages and Natural Language
Think about how you communicate with another person. You use your native language—English, Nepali, Hindi—with grammar rules, vocabulary, and syntax that both parties understand. Programming languages work similarly. They have vocabularies (keywords and operators), grammar rules (syntax), and semantics that define what valid instructions look like.
The key difference is precision. In natural language, context helps communicate meaning even with imperfect grammar. A computer demands exact syntax. A misplaced semicolon renders your program invalid. This rigidity exists because computers execute instructions literally.
Classification of Programming Languages
Programming languages are primarily divided into low-level and high-level categories, reflecting how close the language sits to the actual hardware.
| Aspect | Low-Level Languages | High-Level Languages |
|---|---|---|
| Abstraction | Close to hardware | Far from hardware |
| Readability | Difficult for humans | Readable, English-like |
| Code Length | Longer for same task | Shorter, more concise |
| Examples | Machine, Assembly | C, Java, Python |
Low-Level Languages
Machine Language is the only language your processor truly understands. It consists entirely of binary digits—0s and 1s. Each instruction is a specific bit sequence the CPU decodes and executes directly. Writing programs in machine language is impractical because humans struggle to track meaning in binary sequences.
Assembly Language provides a thin abstraction above machine language. Instead of binary, assembly uses mnemonics and symbolic names. MOV A, B moves register B contents into register A—much more readable than binary. Assembly is specific to processor architectures; code for Intel x86 won’t run on ARM.
Machine Language: Pros and Cons
Machine language executes directly without translation, making it the fastest possible execution. It gives complete control over hardware. However, it’s extremely tedious to write, nearly impossible to debug, and completely non-portable between different processor types.
Assembly Language: Advantages and Limitations
Assembly is more readable than machine code while retaining fine-grained hardware control. It’s used for performance-critical code, device drivers, and embedded systems. Disadvantages include being processor-specific (non-portable), difficult to learn, and slow to develop in.
High-Level Languages
High-level languages use English-like syntax, mathematical notation, and abstract concepts that hide hardware details. Writing total = price * quantity in Python is immediately understandable.
Advantages: Readable and maintainable code, faster development time, portable across different hardware, large standard libraries, and automatic memory management in many languages.
Limitations: Slower execution than optimized low-level code, less control over hardware details, and higher memory consumption due to abstraction overhead.
Difference Between Low and High Level Languages
| Feature | Low-Level | High-Level |
|---|---|---|
| Speed | Very fast execution | Slightly slower |
| Portability | Machine-specific | Portable across platforms |
| Development Speed | Slow, tedious | Fast, productive |
| Debugging | Very difficult | Easier with tools |
| Memory Control | Manual, precise | Often automatic |
Program Language Translators
Since processors only understand machine language, high-level code must be translated. Three types of translators exist:
Assembler: Converts assembly language into machine code. Each assembly instruction maps to one (or a few) machine instructions.
Compiler: Translates an entire high-level program into machine code before execution. The output is an executable file. C, C++, and Go use compilers. Compilation takes time upfront but produces fast-running programs.
Interpreter: Translates and executes high-level code line by line during runtime. Python and JavaScript typically use interpreters. Programs start immediately but run slower because translation happens during every execution.
Compiler vs. Interpreter
| Aspect | Compiler | Interpreter |
|---|---|---|
| Translation | Whole program at once | Line by line |
| Output | Executable file | No separate file |
| Execution Speed | Fast (pre-translated) | Slower (translates each run) |
| Error Detection | All errors before running | Errors found during run |
Linker and Loader
After compilation, the linker combines separately compiled code modules and library functions into a single executable. A static linker copies library code into the executable. A dynamic linker references shared libraries loaded at runtime.
The loader places the executable into memory for execution. An absolute loader loads at a fixed address. A relocating loader adjusts addresses, allowing the program to run at any available memory location.
Generations of Programming Languages
First Generation (1GL): Machine language. Second Generation (2GL): Assembly language. Third Generation (3GL): High-level procedural languages like C, Pascal, FORTRAN. Fourth Generation (4GL): Domain-specific languages like SQL for databases, MATLAB for mathematics.
4GL Advantages over 3GL
4GLs require significantly less code. SQL can retrieve complex data with a single statement that would require dozens of lines in C. 4GLs are often non-procedural—you describe what you want rather than how to get it. They’re more accessible to non-programmers.
Object-Oriented Features
OOP organizes code around objects that combine data and behavior. Key concepts include encapsulation (bundling data with methods), inheritance (creating new classes from existing ones), and polymorphism (treating different objects through a common interface). Languages like Java, C++, and Python support OOP.
Machine Independence and Portability
Machine independence means a program runs on different hardware without modification. Java achieves this with its "write once, run anywhere" approach using the JVM. Portability is increasingly valued as software runs on diverse devices.
Important High-Level Languages
C (1972): General-purpose, used for operating systems. C++: Adds OOP to C, used for games and browsers. Java: Portable, used in enterprise and Android. Python: Readable, popular in data science and web development. JavaScript: Powers web interactivity. FORTRAN: Scientific computing. COBOL: Banking systems.