Hook
More breakout videos from this creator.
Functional programming and its core is very easy to define you just use pure functions without any side effects you can't change the variables value you cannot throw an exception you cannot read or write user input the idea of functional programming is harder to grasp because we interact with the word in an object oriented way We all understand what is an object It's an encapsulation of a bunch of functions if I want to turn the light on and off I do it by changing its state and mutate its value Whereas if I want to turn the light on and off in a pure functional way I have to take a light that is on and return a light that is off without changing the light I passed in because it's immutable it's kind of similar to using a version control system you commit something new but an old version is still there and you want to make small meaningful incremental steps to change your versions any object oriented programming tutorial learn how to print Helloworld this is a table of content of functional programming in Scala and this is where you learn how to use I/O for OOP things get chaotic and complex as your codebase grow which is like the real word it's complex and chaotic for FP because we have these restrictions it's safer to trust other people's code I can just take a block of code if I know it's purely functional put it in my program and because the code is purely local does not change anything 20 lines away it's easier to reason about But a lot of problems we encounter comes from real world which relies on side effects FP does not prohibit side effects it just handles side effect in a different way that is more contained and under control For example if some error occurred instead of throwing an exception we return this error as part of the result for the caller to handle however they want I don't see myself writing any purely functional code for any project I work on but it's more like a design philosophy you have in the back of your mind and you can use the ideas of functional programming for whatever you work on