Programming paradigm

898 views

Published on

Talks about different programming paradigms, their strengths & weakness, evolution of programming paradigms and some real life application of how companies have gained competitive advantage by using right paradigm to solve their problems.

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
898
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
38
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Programming paradigm

  1. 1. Programming Paradigms Bhavin Kamani
  2. 2. Cuisine
  3. 3. Music Genre
  4. 4. Imperative Programming Instructional Command Variable State Conditions Loops
  5. 5. Direct Efficient Inflexible Side Effects
  6. 6. Assembly, C COBOL, Visual Basic
  7. 7. Object Oriented Programming
  8. 8. Abstraction Maintainibility Learning Curve Over Engineering
  9. 9. C++, Java, C# Ruby, Python
  10. 10. Declarative Programming "What" instead of "How" Reduced Side effects Order of statements not crucial
  11. 11. Domain Specific Languages SQL
  12. 12. Domain Specific Languages Regular Expression
  13. 13. Functional Programming
  14. 14. Composability Concurrency Learning Curve Main stream support
  15. 15. LISP, Haskell, Erlang Closure, Scala, F#
  16. 16. Multi-Paradigm Programming
  17. 17. http://www.99-bottles-of-beer.net JavaScript
  18. 18. Lyrics 99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles of beer on the wall. 98 bottles of beer on the wall, 98 bottles of beer. Take one down and pass it around, 97 bottles of beer on the wall. 97 bottles of beer on the wall, 97 bottles of beer. Take one down and pass it around, 96 bottles of beer on the wall. -------------------------------------------------------------------------- -------------------------------------------------------------------------- 1 bottle of beer on the wall, 1 bottle of beer. Take one down and pass it around, no more bottles of beer on the wall. No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall.
  19. 19. Imperative Style var lyrics = []; for (var bottles = 99; bottles > 0; bottles--) { lyrics.push(bottles + " bottles of beer on the wall, " + bottles + " bottles of beer"); var next_bottles = ((bottles-1) == 0 ? "no more" : (bottles-1)); lyrics.push("Take one down and pass it around, " + next_bottles + " bottles of beer on the wall."); } var zero_bottle = "No more"; lyrics.push(zero_bottle + " bottles of beer on the wall, " + zero_bottle + " bottles of beer"); lyrics.push("Go to the store and buy some more, " + "99 bottles of beer on the wall."); document.writeln(lyrics.join("<BR>"));
  20. 20. Object-Oriented Style varBottleSong=function(num_bottles,stanza){ this.num_bottles=num_bottles; this.stanza=stanza; }; BottleSong.prototype={ sing:function(separator){ varbeer_form="bottlesofbeer"; for(varbottles=this.num_bottles;bottles>0;bottles--){ this.stanza.addLine(bottles+beer_form+"onthewall,"+bottles+beer_form); varnext_bottles=((bottles-1)==0?"nomore":(bottles-1)); this.stanza.addLine("Takeonedownandpassitaround,"+next_bottles+beer_form+"onthewall."); } varzero_bottle="Nomore"; this.stanza.addLine(zero_bottle+beer_form+"onthewall,"+zero_bottle+beer_form); this.stanza.addLine("Gotothestoreandbuysomemore,"+this.num_bottles+beer_form+"onthewall."); returnthis.stanza.write(separator); } } varStanza=function(){ this.lines=[]; }; Stanza.prototype={ addLine:function(line){ this.lines.push(line); }, write:function(separator){ returnthis.lines.join(separator); } } varsong=newBottleSong(99,newStanza()); document.writeln(song.sing("<BR>"));
  21. 21. Functional Style var BottleSong = function(num_bottles){ var bottles = function(n){ return (n == 0 ? "no more" : n) + " bottles"; } this.num_bottles = num_bottles; this.last_stanza = function(){ return ["No more bottles of beer on the wall, no more bottles of beer.", "Go to the store and buy some more, 99 bottles of beer on the wall."]; } this.stanza = function(n) { var line = [bottles(n) + " of beer on the wall, " + bottles(n) + " of beer."]; line.push("Take one down and pass it around, " + bottles(n-1) + " of beer on the wall."); return line; } } BottleSong.prototype = { sing: function(separator){ var bottles = _.range(this.num_bottles,0,-1) var that = this; return _.reduce(bottles, function(lyrics, n) { return lyrics.concat(that.verse_n(n)); },[]).concat(that.verse_0()).join(separator); } } var song = new BottleSong(99); document.writeln(song.sing("<BR>"));
  22. 22. bottles 0 = "no more bottles" bottles 1 = "1 bottle" bottles n = show n ++ " bottles" verse 0 = "No more bottles of beer on the wall, no more bottles of beer.n" ++ "Go to the store and buy some more, 99 bottles of beer on the wall." verse n = bottles n ++ " of beer on the wall, " ++ bottles n ++ " of beer.n" ++ "Take one down and pass it around, " ++ bottles (n-1) ++ " of beer on the wall.n" main = mapM (putStrLn . verse) [99,98..0] Haskel Solution
  23. 23. (defn bottles-str [n] (str (cond (= 0 n) "no more bottles" (= 1 n) "1 bottle" :else (format "%d bottles" n)) " of beer")) (defn print-bottle [n] (println (format "%s on the wall, %s." (bottles-str n) (bottles-str n))) (println "Take one down and pass it around," (bottles-str (dec n)) "on the wall.")) (defn sing [n] (dorun (map print-bottle (reverse (range 1 (inc n))))) (println "No more bottles of beer on the wall, no more bottles of beer.") (println "Go to the store and buy some more," (bottles-str n) "on the wall.")) (sing 99) Clojure Solution
  24. 24. Piet Solution
  25. 25. Whitespace Solution
  26. 26. Paradigm Evolution
  27. 27. Java 8 Lambda Expression

×