Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Part 5.1Types of programming languages

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:

JavaScript
var x = 10;
var y = 20;
console.log(x * y);
PHP
$x = 10;
$y = 20;
echo $x * $y;
Java
int x = 10;
int y = 20;
System.out.println(x * y);
YASS
$x = 10;
$y = 20;
print ($x * $y)
VB.NET
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.
  1. Change the values of x and y in each language. What happens?
  2. Modify the program to calculate the area of a rectangle given width × height (still just x * y).
  3. Add a third variable z and print x * 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:

JavaScript
var x = parseFloat(prompt("Enter x"));
var y = parseFloat(prompt("Enter y"));
console.log(x * y);
    
PHP
$x = (float) trim(fgets(STDIN));
$y = (float) trim(fgets(STDIN));
echo $x * $y;
    
YASS
$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.

Feedback 👍
Comments are sent via email to me.