designwithfocus

Programming basics

What Is a Programming Paradigm? Styles Code Is Written In

By Design With Focus Team 6 min read
Three code cards labeled steps, objects, and functions on a desk

Short answer

A programming paradigm is a style of structuring a program into steps, objects, or functions. Python's guide contrasts procedural instructions, objects with state, and functions that depend on their inputs. Java and MDN describe the object style. None of these pages says one style covers most code.

Last verified against the sources listed below.

Key takeaways

  • A paradigm here means a style of structuring a program, not a brand of editor.
  • Python's guide calls C, Pascal, and Unix shells procedural: lists of instructions.
  • Java describes an object as related state and behavior, and a class as a blueprint.
  • MDN says OOP encapsulates data in objects and operates on the object, not only its parts.
  • Functional style, in Python's HOWTO, decomposes a problem into functions and avoids hidden state.
  • Python, C++, and Lisp are described there as multi-paradigm languages.

What is a programming paradigm is a question about style, not about which app you type in. In this article, a paradigm means a style of structuring a program: the way you break the work into steps, into objects, or into functions. The definitions of the object-oriented style and the functional style below come from the language docs that were opened, not from a ranking of which style is most popular.

Python’s Functional Programming HOWTO is the page that lines the styles up. It says languages support several ways of decomposing a problem, and that some languages emphasize one way while others are multi-paradigm.

The pages below define the object style and the functional style. This introduction only names the umbrella: a way of structuring the program, not a popularity score.

Oracle’s lesson, MDN’s glossary, and Python’s class tutorial are the object-oriented sources used here. The functional HOWTO is the source for functions and for the procedural list of instructions. Swift’s documentation page is included only for the features it actually names.

None of those pages says that one style accounts for most programs. A paradigm, in the sense used here, is a choice about structure. You can read the Java lesson for objects, the Python HOWTO for functions, and still mix the two in one codebase, which is the multi-paradigm point Python makes about itself.

What does a procedural style look like?

A procedural style is a list of instructions that tell the computer what to do with the input. Python’s guide uses that term. People often say imperative for the same idea. The page itself does not.

The HOWTO names C, Pascal, and Unix shells as procedural languages. The program is a sequence: do this, then that, then use the result. You can hold the whole path in your head as steps. That is a good fit when the problem really is a procedure, such as a small script that reads a file and prints a result.

The same section contrasts a declarative style. You write a specification, and the implementation chooses the steps. SQL is the example: the query names the data, and the engine chooses the plan.

The HOWTO also says a large program may mix approaches, one part written one way and another part another way.

What is object-oriented programming?

Object-oriented programming organizes a program as objects that hold state and behavior, and it operates on those objects rather than only on loose values.

Oracle’s Java tutorial says an object bundles state and behavior. A class is the blueprint. Inheritance, interfaces, and packages organize that model. The lesson was written for JDK 8.

MDN’s OOP glossary says data is encapsulated in objects and you operate on the object. JavaScript is heavily object-oriented, with prototypes and a class syntax.

Python’s class tutorial says a class bundles data and functionality and creates a type. Instances hold state in attributes and change it with methods. Inheritance can use more than one base class.

How do the docs describe a functional style?

A functional style breaks a problem into functions that map inputs to outputs.

The Python HOWTO names the ML family and Haskell. Functions with no side effects are purely functional. Printing and sleeping are side effects. Python in this style may still assign local variables, while avoiding global changes.

The HOWTO calls this the opposite of objects in one respect. Objects keep state and methods that change it. Functional style passes data through functions. You can still pass objects such as messages into those functions.

The gains it lists are modularity, composability, and easier testing. A formal proof is mentioned, then called impractical for ordinary software. You test a small function by feeding it an input and checking the output. Iterators, later in the same HOWTO, are one Python tool for walking a stream of values one item at a time.

Can one language use more than one style?

Yes. Python’s HOWTO says Lisp, C++, and Python are multi-paradigm, and that you can write code that is largely procedural, object-oriented, or functional in each of them.

In a large program, the HOWTO says, the interface might be object-oriented while the processing is functional. C++ and Python support objects and do not force them.

Apple’s Swift overview describes type inference, optionals, and closures. It does not define a paradigm.

Python’s sample class header is class ClassName. You can convert a name to PascalCase for that shape. The tutorial does not require that spelling in every language.

Style How the opened docs describe it Examples those docs name
Procedural A list of instructions for the input C, Pascal, Unix shells
Object-oriented Objects that bundle state and behavior Java, Smalltalk, JavaScript, Python classes
Functional Functions from inputs to outputs, limiting hidden state ML family, Haskell, functional style in Python
Multi-paradigm Several of the above in one language Lisp, C++, Python

How should you choose a style for a web project?

Choose the style that matches the problem you are structuring, and stay with the vocabulary the language’s own docs use.

A web page is not a paradigm. Web design plans what the visitor sees. The program behind it might be steps, objects, or functions. Python’s guide is comfortable with that mix.

Start where the tutorial starts. Java’s lesson begins with objects, classes, inheritance, interfaces, and packages. Python’s class chapter bundles data and functions. The functional HOWTO lets readers who want language features skip ahead to iterators.

No percentage of object-oriented code appears in these sources. Procedural code says what to do next. Object-oriented code asks an object to behave. Functional code passes values through functions and treats hidden state changes as the thing to limit.

Frequently asked questions

Which languages does Python's guide call procedural?

The functional programming HOWTO says most languages are procedural, meaning programs are lists of instructions that tell the computer what to do with the input. It names C, Pascal, and Unix shells. It does not use the word imperative in that section. Declarative style is the contrast it draws next: you write a specification of the problem, and the implementation chooses the steps. SQL is the example.

What OOP features does the Python tutorial say classes provide?

The classes tutorial, in the Python 3.15.2 docs, says classes provide the standard features of object-oriented programming. A derived class can have multiple base classes, can override methods, and a method can call the base method of the same name. Objects can hold arbitrary data. Classes are created at runtime and can be modified afterward. The simplest sample header is class ClassName, which is a PascalCase spelling in the example, not a rule the page states for every language.

How does Java describe an interface?

Oracle's concepts lesson says an interface is a contract between a class and the outside world. When a class implements an interface, it promises the behavior that interface publishes. The same lesson calls a package a namespace for organizing classes and interfaces, and it points to the Java platform API as the library organized that way. The page notes that the tutorials were written for JDK 8 and may not show later language changes.

Is JavaScript's object model the same shape as Java's?

MDN's OOP glossary says JavaScript is heavily object-oriented, follows a prototype-based model, and also offers a class syntax for typical OOP paradigms. Java's lesson starts from classes, inheritance, interfaces, and packages, and it calls a class a blueprint. Both pages describe objects that bundle data with behavior. They do not describe the same syntax, and this article does not pretend the prototype model is a class blueprint.

Why does Python's guide say functional code can be easier to test?

The HOWTO lists formal provability, modularity, composability, and easier debugging and testing as advantages. Testing is easier, it says, because a function does not depend on system state you must recreate. You supply an input and check the output. It also says full mathematical proofs are mostly impractical for real Python software. Purity in Python usually stops short of banning all assignment inside a function.

Sources