Programming Paradigms

Complete Developer Podcast - En podcast af BJ Burns and Will Gant - Torsdage

Kategorier:

According to the dictionary a paradigm is “a typical example or pattern of something, a model.” in reference to language it is “a set of linguistic items that form mutually exclusive choices in particular syntactic roles.” Programming paradigms classify programming languages based on the features of the language or the rules around how code is written in that language. Languages can be classified into multiple paradigms with some languages being specifically designed to be multi-paradigm. This allows the programmer to choose how to best implement the language or the framework around that language to meet the needs of the program or app they are writing. Many of these languages have a primary paradigm such as being primarily object oriented but allowing for other paradigms like procedural or functional. To understand how languages work we’ll start with looking at the Turing machine designed by Alan Turing in 1936. This is a mathematical model of computation defining a machine that manipulates symbols on a strip of tape based on a table of rules. Within this construct any computer algorithm can be simulated with a Turing machine. Along the same lines a programming language is said to be Turing Complete if it can be used to simulate any Turing machine. What that basically boils down to is that a language is Turing Complete if it can simulate or create any given computer algorithm. Programming paradigms are ways of thinking about programming languages or sets of languages. There are many paradigms out there and they are not mutually exclusive. However, there are a few exclusive dichotomies which languages tend to fall into. Sometimes languages are designed to fit into a paradigm whereas other times they were built for a purpose and then are placed in a paradigm. These are just a few of the myriad of programming paradigms available for study. While it’s easy to think of a particular language as being one paradigm or the other it is important to know the history of the language and how it can be used. Many modern languages allow for multiple paradigms, even if they were originally written with a particular one in mind. Use the information here to better understand the languages and frameworks you use and how they relate to others that you interact with on a regular basis. Episode Breakdown Structured vs Non-Structured The earliest Turing complete programming paradigm was non-structured. The non-structured paradigm can be found in both high level and low level languages. The flow of programs in non-structured languages use jumps to labels or addresses. In many of these languages line numbering is important with “goto” statements being the jump that moves to the line number or label. Non-structured programming is therefore hard to read and produces spaghetti code, though it’s proponents, such as Donald Knuth, argue that structured programming can be just as hard to understand. Structured programming was designed to improve the flow and readability of programs. It became popular after a letter by Edsger Dijkstra was published titled “Go To Statements Considered Harmful”. The Structured Programming theorem states that a group of flowcharts, or more generically control flow graphs, can compute any computable function by combining subprograms in one of three ways: sequence, selection, or iteration. Sequence combines subprograms in a linear fashion with one performed followed by another. Selection uses a boolean expression to decide which subprogram to perform. Iteration repeatedly runs a subprogram as long as a boolean expression is true. Structured programming uses control flow constructs like if/else, loops, blocks, and subroutines to guide the flow of a program rather than unstructured jumps to different areas of code.

Visit the podcast's native language site