programming paradigms

Paradigms

All programming languages can be classified, based on their features, into some programming paradigm.  Some of these paradigms are concerned with implications for the execution model of the language or whether the sequence of operations is defined by the execution model.  Others with the way that code is organized, such as grouping code into units along with the state that is modified by the code.  And yet others are concerned with the style of syntax and grammar. 

Imperative

Imperative programming focuses on HOW to execute program logic and defines control flow as statements that change a program state.  Main traits include direct assignments, common data structures, and global variables.  Example: C, C++, Java, PHP, Python, Ruby. 

Each statement changes the state of the program, from assigning values to each variable to the final addition of those values.  Using a sequence of five statements the program is explicitly told how to add the numbers 5, 10 and 15 together. 

Declarative

Declarative programming focuses on WHAT to execute and defines program logic, but not a detailed control flow.  Main traits include fourth-generation languages, spreadsheets, and report program generators.  Example: SQL, regular expressions, Prolog. 

Declarative programs can be described as context independent.  meaning they only declare what the ultimate goal is, not the intermediary steps to reach that goal. 

Procedural

Procedural programming specifies the steps a program must take to reach a desired state, usually read in order from top to bottom.  Main traits include local variables, sequence, selection, iteration, and modularization.  Example: C, C++, PHP, Python.