ditonthouikwel ditonthouik​wel

Niner since 2008


  • Erik Meijer: Functional Programming

    From the video, the main point seems to be that there are pure and impure functions. A pure function will give you the same result each time when you pass it the same arguments. An impure function will not.

    Now it seems to me, that there can not be such a thing as a pure function. Because every function takes some time to be executed, so every function has as a side-effect that time has passed, or ticks increased. So if you use Ticks anywhere in your program, as in the example in the clip, all functions would become instantly impure.

    I liked the distinction between honest and dishonest functions. An honest function gives you an indication of wether or not it changes anything other then the parameters passed while a dishonest does not.

    What i liked most though was the explanation of how lambda functions were just a shorthand notation for a kind of class. That made lambda functions alot easier to understand.

    It's a bit strange though that instead of getting to see alot of benefits that you can get from using pure functions, about 40 minutes of the video were actually about the disadvantages of it and why only having pure functions doesn't work.

    Now i'm not sure if this is the right place to ask questions, but i wonder why functions still give a result. When you follow the convention that any result given , can also just be an out parameter of the function. It's easy to see that y = f(x) is the same as f(x,out y). However, when taking c# for example, there are a lot of things i could do in the second form that aren't possible in the first form. Like having multiple out parameters f(x, out y, out z). Or even overloading the function with a different type for the out parameter: f(int x, out int y) and f(int x, out string y). 

    As a second pondering, switching between functional and object oriented, is just passing the object data as first parameter to the object function. So all object oriented programming is also functional programming. It's just grouped together with a bit more intuitive syntax.

    ps: thank you for providing a smaller download channel 9 crew. With a download cap of 12 GB a month in this backwards country, it is really appreciated to be able to get those vids in smaller sizes.