Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Programming Languages and their influence in Thinking

1,451 views

Published on

Regional Scrum Gathering Ecuador 2015 Key Note

Published in: Software

Programming Languages and their influence in Thinking

  1. 1. agile software development & services Los Lenguajes de Programación y su Impacto en el Pensamiento Hernán Wilkinson Twitter: @HernanWilkinson Blog: objectmodels.blogspot.com www.10pines.com
  2. 2. The world “we live” in … ?
  3. 3. The world “we live” in … ?
  4. 4. The world “we live” in … ?
  5. 5. The world “we live” in … ?
  6. 6. Bret Victor - Thinking the unthinkable
  7. 7. Language <-> Thinking
  8. 8. What we can not talk about… we can not think about (or it is difficult...)
  9. 9. Do not Insist on English
  10. 10. Aimara: Pasado y Futuro (nayra) (qhipa)
  11. 11. What is the relationship with Programming Languages? (K. Iverson: “Notation as a tool of thought” 1979 ACM Turing Award)
  12. 12. If a programming language does not allow me to “TALK” (write) about certain things … Then I can not THINK about certain solutions
  13. 13. Let’s see Li st <Cust omer > sel ect edCust omer s = new Ar r ayLi st <Cust omer > ( ) ; f or ( Cust omer cust omer : cust omer s) i f ( cust omer . nameSt ar sWi t h( “ H” ) ) sel ect edCust omer s. add ( cust omer ) ; r et ur n sel ect edCust omer s;
  14. 14. Let’s see Li st <Cust omer > sel ect edCust omer s = new Ar r ayLi st <Cust omer > ( ) ; f or ( Cust omer cust omer : cust omer s) i f ( cust omer . nameSt ar sWi t h( “ H” ) ) sel ect edCust omer s. add ( cust omer ) ; r et ur n sel ect edCust omer s; Li st <Account > sel ect edAccount s = new Ar r ayLi st <Account > ( ) ; f or ( Account account : account s) i f ( account . i sOver dr aw( ) ) sel ect edAccount s. add( account ) ; r et ur n sel ect edAccount ;
  15. 15. Let’s see Li st <Cust omer > sel ect edCust omer s = new Ar r ayLi st <Cust omer > ( ) ; f or ( Cust omer cust omer : cust omer s) i f ( cust omer . nameSt ar sWi t h( “ H” ) ) sel ect edCust omer s. add ( cust omer ) ; r et ur n sel ect edCust omer s; Li st <Account > sel ect edAccount s = new Ar r ayLi st <Account > ( ) ; f or ( Account account : account s) i f ( account . i sOver dr aw( ) ) sel ect edAccount s. add( account ) ; r et ur n sel ect edAccount ; What is the problem?
  16. 16. We have repeated code! Li st <Cust omer > sel ect edCust omer s = new Ar r ayLi st <Cust omer > ( ) ; f or ( Cust omer cust omer : cust omers) i f ( cust omer. nameSt arsWi t h(“H”) ) sel ect edCust omer s. add ( cust omer ) ; r et ur n sel ect edCust omer s; Li st <Account > sel ect edAccount s = new Ar r ayLi st <Account > ( ) ; f or ( Account account : account s) i f ( account . i sOverdraw() ) sel ect edAccount s. add( account ) ; r et ur n sel ect edAccount ;
  17. 17. Code != Text
  18. 18. How do we remove it?
  19. 19. Technique: 1. “Contextualize-Copy” the repeated code to some “place” 2. Parameterize what changes 3. NAME IT!!! 4. Use it :-)
  20. 20. cl ass Col l ect i on<T> { publ i c Col l ect i on<T> <<NAME>> ( ?) { Li st <T> sel ect ed = new Ar r ayLi st <T> ( ) ; f or ( T anObj ect : t hi s ) i f ( ) sel ect ed. add ( anObj ect ) ; r et ur n sel ect ed: } this Copy the repeated code to some place Li st <Cust omer > sel ect edCust omer s = new Ar r ayLi st <Cust omer > ( ) ; f or ( Cust omer cust omer : cust omers) i f ( cust omer. nameSt arsWi t h(“H”) ) sel ect edCust omer s. add( cust omer ) ; r et ur n sel ect edCust omer s; Li st <Account > sel ect edAccount s = new Ar r ayLi st <Account > ( ) ; f or ( Account account : account s) i f ( account . i sOverdraw() ) sel ect edAccount s. add( account ) ; r et ur n sel ect edAccount ;
  21. 21. Parameterize what changes Li st <Cust omer > sel ect edCust omer s = new Ar r ayLi st <Cust omer > ( ) ; f or ( Cust omer cust omer : cust omer s) i f ( cust omer. nameSt arsWi t h(“H”) ) sel ect edCust omer s. add ( cust omer ) ; r et ur n sel ect edCust omer s; Li st <Account > sel ect edAccount s = new Ar r ayLi st <Account > ( ) ; f or ( Account account : account s) i f ( account . i sOverdraw() ) sel ect edAccount s. add( account ) ; r et ur n sel ect edAccount ; How do we do it?
  22. 22. An object that represents “code”
  23. 23. cl ass Col l ect i on<T> { publ i c Col l ect i on<T> <<NAME>> ( Cl osure aCl osure) { Li st <T> sel ect ed = new Ar r ayLi st <T> ( ) ; f or ( T anObj ect : t hi s ) i f ( ) sel ect ed. add ( anObj ect ) ; r et ur n sel ect ed: } this Copy the repeated code to some place Li st <Cust omer > sel ect edCust omer s = new Ar r ayLi st <Cust omer > ( ) ; f or ( Cust omer cust omer : cust omers) i f ( cust omer. nameSt arsWi t h(“H”) ) sel ect edCust omer s. add( cust omer ) ; r et ur n sel ect edCust omer s; Li st <Account > sel ect edAccount s = new Ar r ayLi st <Account > ( ) ; f or ( Account account : account s) i f ( account . i sOverdraw() ) sel ect edAccount s. add( account ) ; r et ur n sel ect edAccount ; aClosure.execute(anObject)
  24. 24. cl ass Col l ect i on<T> { publ i c Col l ect i on<T> sel ect ( Cl osure aCl osure) { Li st <T> sel ect ed = new Ar r ayLi st <T> ( ) ; f or ( T anObj ect : t hi s ) i f ( ) sel ect ed. add ( anObj ect ) ; r et ur n sel ect ed: } self NAME IT! Li st <Cust omer > sel ect edCust omer s = new Ar r ayLi st <Cust omer > ( ) ; f or ( Cust omer cust omer : cust omers) i f ( cust omer. nameSt arsWi t h(“H”) ) sel ect edCust omer s. add( cust omer ) ; r et ur n sel ect edCust omer s; Li st <Account > sel ect edAccount s = new Ar r ayLi st <Account > ( ) ; f or ( Account account : account s) i f ( account . i sOverdraw() ) sel ect edAccount s. add( account ) ; r et ur n sel ect edAccount ; aClosure.execute(anObject) The most difficult part because it means that we understood the repeated code meaning
  25. 25. Li st <Cust omer > sel ect edCust omer s = new Ar r ayLi st <Cust omer > ( ) ; f or ( Cust omer cust omer : cust omer s) i f ( cust omer . nameSt ar sWi t h( “ H” ) ) sel ect edCust omer s. add ( cust omer ) ; r et ur n sel ect edCust omer s; Li st <Account > sel ect edAccount s = new Ar r ayLi st <Account > ( ) ; f or ( Account account : account s) i f ( account . i sOver dr aw( ) ) sel ect edAccount s. add( account ) ; r et ur n sel ect edAccount ; cut omer s. sel ect ( cust omer - > cust omer . nameSt ar t sWi t h( “ H” ) ) account s. sel ect ( account - > account . i sOver dr aw( ) )
  26. 26. What did we gain? 1. Few words  Simplicity, Easier to understand, read, remember, etc. Less bugs! 2. We created a new “abstraction”: select (filter in Java 8) 3. … and we removed duplicated code!!
  27. 27. Now… let’s do some reflection
  28. 28. 1. Because we are use to that code (is the programming language the problem or us?) 2. Because there is no “concept” to remove it Why didn’t we see the “duplicated code”
  29. 29. Why didn’t we came with a solution? 1. Because the programming language does not provide us with a “concept” to think about a solution!
  30. 30. …and much much more…. Imagine how your designs would be if you could use closures You can create your own control flow “sintax” Further reading: LAMBDA The Ultimate…
  31. 31. Hamming / Closure If there are certain objects that can not be created in some languages … … and given the solutions provided by some programming languages… The statement: “There are design solutions that are unthinkable in some programming languages” ¿Does it surprise you?
  32. 32. Meta-Conclusion Object = ¿Data + Code?
  33. 33. Meta-Conclusion Object = ¿Data + Code? If you think so, you don´t understand OO yet
  34. 34. Meta-Conclusion Data is an Object Code is an Object An Object is a “superior” concept that unifies data and code
  35. 35. What is the problem?
  36. 36. No If!
  37. 37. Now… let’s do some reflection
  38. 38. Why did we not see the “polymorphic message”?  Because 'if' as a reserved word is a “primitive construction”, there is nothing behind it  Therefore it does not make us think in polymorphism
  39. 39. If as a message
  40. 40. A programming language is its creator's state of knowledge
  41. 41. timeToRun
  42. 42. timeToRun
  43. 43. timeToRun
  44. 44. timeToRun
  45. 45. timeToRun
  46. 46. timeToRun
  47. 47. timeToRun
  48. 48. timeToRun
  49. 49. Extending a Language!
  50. 50. How can we add specific behavior to an object? Let's see an example
  51. 51. Now… let’s do some reflection 1. What are the solutions we lack due to limited meta programming? 2. What do we loose if we do not have a meta- circular language?
  52. 52. How do we learn a new word?
  53. 53. Do we: 1. Stop our brain 2. “edit" a new definition in our dictionary 3. “Compile” the new definition 4. Restart our brain?
  54. 54. NO!! Why do we have to do it with our programs?
  55. 55. Can our programs “change while running”? Can our programs “learn” as we learn?
  56. 56. Yes, they can!... If they are METACIRCULAR Apply Eval
  57. 57. If we don’t have meta-circular languages, then we can not think about solutions that are natural in our daily lives!!
  58. 58. Let’s think again… Are these concepts new?
  59. 59. Lisp John McCarthy Alan Kay “We must know our history if we don’t want to reinvent … not only the tire, but a a flat tire”
  60. 60. Conclusions  Do not accept languages without Closures  Do not accept languages without good meta-programming  Create your own extensions!  Liberate yourself from the programming language and frameworks
  61. 61. Conclusions  Learn other programming languages Lisp/Scheme Smalltalk Forth and more...  Learn our history
  62. 62. "The Humble Programmer” E. Dijkstra “The tools we are trying to use and the language or notation we are using to express or record our thoughts, are the major factors determining what we can think or express at all!"
  63. 63. Questions?
  64. 64. agile software development & services Muchas gracias! info@10pines.com www.10Pines.com twitter: @10Pines Argentina Tel.: +54 (11) 6091-3125 Alem 693, 5B (1001) Buenos Aires

×