There are many different programming languages out there much like there are different spoken languages in the world. Modern programming languages are built on top of the older programming languages and have the benefit of becoming richer in syntax at the cost of performance (or taking longer to actually write) without making much difference to the outcome of the program. For instance, here are five implementations of the same program in different languages:
var x = 10; var y = 20; console.log(x * y);
$x = 10; $y = 20; echo $x * $y;
int x = 10; int y = 20; System.out.println(x * y);
$x = 10; $y = 20; print ($x * $y)
Dim x As Integer = 10 Dim y As Integer = 20 Console.Write(x * y)
What do these examples show?
All five programs do the same thing: multiply two numbers and display the result. Even though the syntax (how the code looks) varies, the underlying logic is identical. This is a key idea in programming: most languages share common building blocks—variables, operators, and output.
At a glance: syntax differences
| Language | Declare / assign | Output | Comment symbol |
|---|---|---|---|
| JavaScript | var x = 10; |
console.log(...) |
// |
| PHP | $x = 10; |
echo ... |
// or # |
| Java | int x = 10; |
System.out.println(...) |
// |
| YASS | $x = 10 |
print(...) |
// |
| VB.NET | Dim x As Integer = 10 |
Console.Write(...) |
' |
Key ideas
- Variables store values you can reuse (e.g.
x,y). - Operators (like
*) perform calculations. - Output sends results to the screen (e.g.
print,echo,Console.Write). - Syntax differs, but semantics (the meaning) is the same.
- Change the values of
xandyin each language. What happens? - Modify the program to calculate the area of a rectangle given width × height (still just
x * y). - Add a third variable
zand printx * y * z.
Rewrite the program so it asks the user for two numbers and then outputs the product. Here are example skeletons to guide you:
var x = parseFloat(prompt("Enter x")); var y = parseFloat(prompt("Enter y")); console.log(x * y);
$x = (float) trim(fgets(STDIN)); $y = (float) trim(fgets(STDIN)); echo $x * $y;
$x = to_number(input("Enter x: ")) $y = to_number(input("Enter y: ")) print($x * $y)
Types of programming languages
Programming languages can be grouped by the style of programming they support. Many modern languages actually combine more than one style, but here are the four main categories:
Declarative
Focuses on what you want the computer to do, not how it should do it. Examples: SQL (for databases), HTML (for web pages).
Imperative
Tells the computer how to perform a task, step by step, changing the program’s state as it executes. Examples: Assembly, C, Python (when used procedurally).
Procedural
A subtype of imperative programming. Breaks problems down into reusable procedures or functions. Examples: C, Pascal, BASIC.
Object-Oriented (OOP)
Organises code into objects that combine data (attributes) and actions (methods). Examples: Java, Python, C#, VB.NET, YASS.
Scripting
Designed for writing short programs (scripts) to automate tasks. Often interpreted rather than compiled. Examples: JavaScript, PHP, Python.
Together, these approaches demonstrate how languages are designed to address different problems — and why learning more than one can provide a broader perspective.
Language paradigms in practice
Here’s how some of the languages we’ve looked at (plus one extra example) fit into the main categories:
| Language | Paradigm(s) |
|---|---|
| JavaScript | Scripting, Imperative, Object-Oriented |
| PHP | Scripting, Procedural, Object-Oriented |
| Java | Object-Oriented, Imperative |
| YASS | Procedural, Imperative, Object-Oriented |
| VB.NET | Object-Oriented, Imperative |
| Prolog | Declarative |
This table shows that languages often belong to more than one category. For example, JavaScript can be used as a scripting language, but it also supports object-oriented and imperative programming styles. By contrast, Prolog is almost entirely declarative, describing what the solution should look like rather than how to compute it.
