Search⌘ K
AI Features

Programming Paradigms

Explore the procedural programming paradigm in Bash, focusing on how functions modularize code, manage complexity, and prevent repetition. Understand Bash's imperative nature and the benefits of using functions for clearer, maintainable scripts.

We'll cover the following...

Bash is a procedural programming language. Procedural languages allow us to divide a program into logical parts called subroutines. A subroutine is an independent block of code that solves a specific task. A program calls subroutines when it is necessary.

A subroutine is a deprecated term. It is called a function in modern programming languages. We already came across functions when considering the declare Bash built-in. Now, it is time to study them in detail.

Functions

We should start with the terminology. It will explain to us why functions were introduced and which tasks they solve.

But, what is procedural programming? It is one of the paradigms of software development. A paradigm is a set of ideas, methods, and principles that define how to write programs.

There are two dominant paradigms today. Most modern programming languages follow them. These paradigms are the following:

  1. ...