There are probably five main styles of programming, which may overlap, and often relate to particular languages. We have imperative, declarative, object oriented, functional and logic programming styles. These are more commonly called programming paradigms than styles. The list below has each style with an iconic sibling language to implement it.
- imperative - C, or BASIC
- declarative - SQL
- object oriented - Smalltalk
- functional - Haskell
- logic - Prolog
Imperative programming begins with the 3 rules of coding: sequence (code executes left to right, top to bottom), selection (if, case) and iteration (loops), and may develop to structured programming. There's something very low level and intuitive about imperative programming but the best programming is rarely done in this style. With imperative programming, our code explains how a problem is solved - the solution can often be understood by tracing through the steps in the code. Imperative code often has a closer relationship to machine code than other styles.
With declarative programming, one declares a statement or code block to solve a problem. Declarative features are generally higher level. We see declarative features in SQL, many functional and logic programming languages.
Object oriented (OO) programming began in the late 1960s, cumulating in Smalltalk (Alan Kay: 1970 to 1980) and design patterns (1990s through to the noughties). 1980s onward saw several post-Smalltalk languages implementing OO features: C++, Java, C#, Javascript. These four now dominate the world of code. Yet your OO-purest is a Smalltalk coder at heart!
Functional programming (FP) began in academia. Elements of LISP (Designed by John McCarthy, 1958) are functional, Robin Milner created ML in 1975. 1980s saw a commercial FP language: Miranda (David Turner). Haskell began in 1987, mostly as a copy of Miranda, ever refining itself, yet staying lean and clean. Modern functional programming stresses, functions as "first class" elements of the language, declarative programming, prefers immutable data. Other commercial FP languages are: OCaml, F#, Scala, Clojure, ...
Logic programming languages began in earnest in the early 1970s with Prolog. Coding styles are very declarative and applications often have an AI basis, data analysis or both.
All these styles mix, to some extent, in actual languages in use. Yet a language is classified with the style which is most important to it. For example we call Scala a functional programing language, even though it is very OO too. Javascript has always had functional features but does not have immutable data. There's even a style called functional Javascript. Yet Javascript will always be an OO language first.
I began this in response to a question : what programming language should one learn first? It's not really a sensible question. You should learn each of the programming language styles, and sub-styles. [e.g. sub-styles: structured programming as a sub-style of imperative programming, design patterns as a sub-style of object-oriented programming, They are not really sub-, but more like meta-, or supra-styles]. We can also recognize certain idioms that span all styles: DRY, SOLID, ... A lot of good coding practices seem orthogonal to implementing specific use cases. You could begin with imperative programming (first six books in list below), and apply the wisdom in the books to your code. Object-oriented languages dominate business, so read books 7 to 12, but only 12 is specific only to OO (in a sense). Finally, you need at least some functional programming and the last two are good starters.
Beginner programmer reading list.
TBH, A beginner can begin with any programming, or programming language book. Yet you won't really have graduated from beginner until you've read most of the 14 books below. Read and apply the lessons of all 14 and you're past beginner/junior programmer level.
- Code Complete: A Practical Handbook of Software Construction, 2nd Edition, by Steve McConnell
- The Art of Readable Code, by Dustin Boswell and Trevor Foucher
- Programming Pearls (2nd Edition), by by Jon Bentley
- 97 Things Every Programmer Should Know, by by Kevlin Henney
- Clean Code: A Handbook of Agile Software Craftsmanship, by Robert C. Martin
- Test Driven Development: By Example, by Kent Beck
- Agile Principles, Patterns, and Practices in C#, by Robert C. Martin and Micah Martin
- Refactoring: Improving the Design of Existing Code, by by Martin Fowler
- Working Effectively with Legacy Code, by by Michael Feathers
- Growing Object-Oriented Software, Guided by Tests, by Steve Freeman and Nat Pryce
- Agile Java: Crafting Code with Test-Driven Development, by Jeff Langr
- Object Design: Roles, Responsibilities, and Collaborations, by Rebecca Wirfs-Brock and Alan McKean
- Programming in Haskell, by Graham Hutton
- The Joy of Clojure, 2nd Edition, by Michael Fogus and Chris Houser
No comments:
Post a Comment