7 Easy functional programming techniques in Go

Click for: original source

Deepu K Sasidharan put together this article for Go developers interested in functional programming. Do not worry, you don’t have to learn functional programming oriented languages like Haskell or Clojure(or even Scala or JavaScript though they are not pure functional programming languages) since Go has you covered and this post is for you.

Hence in functional programming, there are two very important rules:

No Data mutations: It means a data object should not be changed after it is created. No implicit state: Hidden/Implicit state should be avoided. In functional programming state is not eliminated, instead, its made visible and explicit.

The article then lists:

  • First-class and higher-order functions
  • Pure functions
  • Recursio
  • Lazy evaluation
  • Type system
  • Referential transparency
  • Data structures

This is just an introduction for those who are trying to apply some functional programming techniques in Go. There are a lot more that can be done in Go and with the addition of generics in the next major version, this should be even easier. Nice one!

[Read More]

Tags golang programming functional-programming