Skip to content

Instantly share code, notes, and snippets.

@satindar
Created May 8, 2015 04:26
Show Gist options
  • Save satindar/8baa4306b0c327e3df35 to your computer and use it in GitHub Desktop.
Save satindar/8baa4306b0c327e3df35 to your computer and use it in GitHub Desktop.
Imperative vs. Functional Programming
With the rapid growth of languages and framworks such as Swift and React you may have heard the terms functional, declarative, and immutability more often. It's often contrasted with the term "imperative". Many authors of technical blogs will assume that you know are familiar with what these terms mean but since so many developers are self taught (particularly in web and mobile programming) it's a big assumption that the reader is comfortable with these terms.
When these terms are described to a developer they may offer the responses, "I have no idea what you are talking about" or "Oh, that makes sense. Isn't that just called...uh...programming?". Of course if you've only programmed in a certain domain you may only be familiar with one particular paradigm. Describing a paradigm as "data and behavior are encapsulated as objects and these objects can influence and change other objects by passing messages" may sound insane to a developer that has only worked with Haskell, but a Java developer would be right at home and may look at you and say "that's just called programming".
Discussing the differences between Functional and Imperative programming can (and has...and is still..) be debated at great length but to really understand the mainstream definition of the terms there are only a few important things that you should keep in mind to understand the distinctions (and what the strengths and weaknesses of each are). Let's use realy code examples to examine the major differences.
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment