Attic › Computer science › Programming paradigm

A programming paradigm is a fundamental style of writing computer code

A programming paradigm is a fundamental style of writing a computer program. Just as architects use different styles to design buildings, software developers use different paradigms to structure code and solve problems. These styles also help us classify programming languages by their features.

You can write the same program in many ways. A paradigm gives a programmer a specific set of concepts to organize their thoughts and instructions. Some languages are built to support only one paradigm, while others let you use several.

Most paradigms fall into one of two main groups:

1. Imperative programming tells the computer how to do a task. The programmer writes an exact sequence of commands, and the computer follows these steps in order to change the data it holds. It works like a cooking recipe: heat the pan, add oil, and fry the egg for three minutes.

2. Declarative programming tells the computer what result is wanted, without giving the step-by-step instructions to get there. The programmer describes the properties of the desired outcome, and the language's underlying software figures out how to produce it. This is like ordering food at a restaurant: you ask for a fried egg, and the kitchen decides how to make it.

Programmers choose a paradigm based on the job they need to do. A style that makes it easy to build a video game might be clumsy for searching a large database, so computer scientists have developed different paradigms to handle different kinds of work.

Fact-checked against Programming paradigm on Wikipedia

Part of the Computer science syllabus: Programming Paradigms and Abstraction

See it on the timeline of Computer science