Garo Garabedyan's Divergent Thinking Blog

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.

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

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s