Garo Garabedyan- a private blog

Everything here is written and belongs to me except otherwise noted.

Erik Meijer, Functional Programming, Channel 9 MSDN

leave a comment »

These are my notes on Erik Meijer, Functional Programming, C9 MSDN, 2008 technical interview.

Object Oriented Programming is State plus Behavior. Haskell and functional programming are pure languages. Programming languages are classified in useful, pure, and honest. Honesty is when type systems tells you exactly what is going on; types tell you what the system will do. Dynamic programming languages do not mention types and so they are honest, some of them make money. Haskell enables side effects but is honest about them, if you call drinkCaffe function, the cup will be empty after the end of the execution.

Dishonest: int f ();
returns int, but it can read a changing int.
In Haskell: IO <int> f (); declares side effect

In Java signatures specify which exceptions can be thrown, int f (…) throws … ; exceptions in some sense are side effects.

Haskell is pure and honest.

Functional programming
Functional programming is programming using mathematical functions. Popular explanation of functional programming is programming with no side effects, and the letter explanation is wrong.

The same arguments return the same result.

Honest:
int f (int x) {
return x+5;
}

Dishonest- returns different int every time
int f (int x) {
return x + Random();
}

Side effects: Lets remove side effects: Random, Exceptions, Threads, IO. So it is like muted. Up to the extreme it became useless. Early Haskell was the same.

Haskell does:
Argument -> (World -> Result, World)
Argument -> IO Result

I can not copy the world, someone can be observing it. The way you compute is by using IO (reader or write, ot both).

Written by garabedyan

May 25, 2009 at 17:40

Leave a Reply