Your SlideShare is downloading. ×
0
Functional programming
Functional programming
Functional programming
Functional programming
Functional programming
Functional programming
Functional programming
Functional programming
Functional programming
Functional programming
Functional programming
Upcoming SlideShare
Loading in...5
×

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.
Text the download link to your phone
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 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
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 “side effect”: you apply function f on data x and this modifies sv... C, C++, and many “classical” languages allow side effects. Some people consider that side effects must be forbidden by programming languages. ==> 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 “quasi”-functional programming in C++: just do not use - global variables, - static variables, - dirty processor-dependent optimizations.

×