Learning to think Functionally

  • Learning a functional language without understanding the paradigm of functional programming will feel really clunky to use, as you will just be retrofitting your imperative ideas into functional code.
  • Functional programming was initially more of a hype in academia than in the industry, but it seems that functional programming is really picking up in the industry and it might be very important for you to learn it.
  • Object Oriented makes code understandable by encapsulating moving parts. Functional Programming makes code understandable by minimizing moving parts. The fewer things you deal with, the less you screw up.
  • Functional: perspective of minimizing shared state. If the functions rely on nothing but the inputs, then they don’t need to be scoped. It also means the functions are reusable.
  • In functional we can pass around functions and use higher-order functions.
  • As time passes, programming languages handle more and more things for us. Even though this might mean less efficiency, fortunately computers are getting faster.
  • Think about results, not steps. Think on a higher level about what you want to achieve. Find the appropriate higher order functions that provide the framework to achieve that.
  • Think more about transformations, less about unique data structures or data types
  • fold, filter and map are your best friends.
  • Benefits of functional: code that is easier to reason about and easier to parallelize.
  1. A prime is a number that is not divisible by any number less than itself, except 1.
  2. A prime is a number that is not divisible by any number less than or equal to its square root, except 1.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store