0
Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Functional programming

380

Published on

non-expert point of view; experts are allowed to send flames :-)

non-expert point of view; experts are allowed to send flames :-)

Published in: Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
380
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
5
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Transcript

• 1. Functional programmingVery very brief introduction ----- -------- O. Teytaud Can you define a function f such that: - theres no randomness - nonetheless, if you call f twice, you get two distinct results ?
• 2. Functional programmingVery very brief introduction ----- -------- O. Teytaud Can you define a function f such that: - theres no randomness or clock - nonetheless, if you call f twice, you get two distinct results ? Yes: double f(double x) { Static double sv=0; sv++; Return x+sv; }
• 3. Functional programmingVery very brief introduction ----- -------- O. Teytaud Can you define a function f such that: - theres no randomness or clock - nonetheless, if you call f twice, you get two distinct results ? Yes (other solution): double f(double x) { Return x+y; // y = global variable }
• 4. Functional programmingVery very brief introduction ----- -------- O. Teytaud This is termed a &#x201C;side effect&#x201D;: you apply function f on data x and this modifies sv... C, C++, and many &#x201C;classical&#x201D; languages allow side effects. Some people consider that side effects must be forbidden by programming languages. ==&gt; functional programming.
• 5. Functional programmingVery very brief introduction ----- -------- O. Teytaud Fundamental property of functional programming:myFunction(thisFunction(x),y,z+otherFunction) at 3pm in Taiwan has the same result asmyFunction(thisFunction(x),y,z+otherFunction) at 5 pm in Switzerlandwhatever may be the memory of the computer.
• 6. Functional programming: examples Existing implementations of functional programming: ObjectiveCaml CommonLisp Haskell F#...and also in specialized languages: R Mathematica
• 7. Functional programming: a classical joke Its impossible to do dirty programming in ObjectiveCaml.
• 8. Functional programming: a classical joke Its impossible to do dirty programming in ObjectiveCaml. But this does not mean that it is possible to do programming in ObjectiveCaml.
• 9. Functional programming: a classical joke Its impossible to do dirty programming in ObjectiveCaml. But this does not mean that it is possible to do programming in ObjectiveCaml. (it is also impossible to do dirty programming with my left shoe; it does not imply that my left shoe is a good programming language)
• 10. Functional programming: decide Ive tested ObjectiveCaml. Yes, its cool: no dirty programming, stable code.I definitely prefer C++ (closer to the (my?) human way of thinking...) for a fast development, but it might be true that functional programming should be used in cases in which you cant test. Example: the code which was responsible of the explosion of Ariane 5. Testing in real conditions is difficult...
• 11. Functional programming: real life Some development competitions have beenwon by teams working with functional programming. E.g.: Facebook tchat servers use Erlang; and ObjectiveCaml is now widely used. You can also do &#x201C;quasi&#x201D;-functional programming in C++: just do not use - global variables, - static variables, - dirty processor-dependent optimizations.