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.

Dear compiler please don't be my nanny v2

1,371 views

Published on

My 6 minute contribution to the AI Summit "Turing Tantrums" GDC 2013

  • Be the first to comment

  • Be the first to like this

Dear compiler please don't be my nanny v2

  1. 1. Dear compiler: Please dont be my NannySpeaker NameDino Dini NHTV University of Applied Sciences
  2. 2. Nanny says:
  3. 3. Nanny says:● Dont you ever use goto
  4. 4. Nanny says:● Dont you ever use goto● Regard preprocessors as bad
  5. 5. Nanny says:● Dont you ever use goto● Regard preprocessors as bad● Might we suggest always saying new
  6. 6. Nanny says:● Dont you ever use goto● Regard preprocessors as bad● Might we suggest always saying new● Fact is OOP should make you glad
  7. 7. Nanny says:● Dont you ever use goto● Regard preprocessors as bad● Might we suggest always saying new● Fact is OOP should make you glad● So you want overload?
  8. 8. Nanny says:● Dont you ever use goto● Regard preprocessors as bad● Might we suggest always saying new● Fact is OOP should make you glad● So you want overload?● La la lands where weak typing goes
  9. 9. Nanny says:● Dont you ever use goto● Regard preprocessors as bad● Might we suggest always saying new● Fact is OOP should make you glad● So you want overload?● La la lands where weak typing goes● Tis right to make everything private
  10. 10. Nanny says:● Dont you ever use goto● Regard preprocessors as bad● Might we suggest always saying new● Fact is OOP should make you glad● So you want overload?● La la lands where weak typing goes● Tis right to make everything private● And that brings us back to Dont.
  11. 11. Dont you ever use goto
  12. 12. Dont you ever use gotoContrary to popular belief, goto is not evil.Sometimes it can be the right tool for the job, especially when:
  13. 13. Dont you ever use gotoContrary to popular belief, goto is not evil.Sometimes it can be the right tool for the job, especially when: ● Prototyping non production code
  14. 14. Dont you ever use gotoContrary to popular belief, goto is not evil.Sometimes it can be the right tool for the job, especially when: ● Prototyping non production code ● Trying to fix bugs in finished code with minimal risks
  15. 15. Dont you ever use gotoContrary to popular belief, goto is not evil.Sometimes it can be the right tool for the job, especially when: ● Prototyping non production code ● Trying to fix bugs in finished code with minimal risks ● Porting legacy code
  16. 16. Dont you ever use gotoContrary to popular belief, goto is not evil.Sometimes it can be the right tool for the job, especially when: ● Prototyping non production code ● Trying to fix bugs in finished code with minimal risks ● Porting legacy code ● Implementing state machines
  17. 17. Dont you ever use gotoIf the code would have been clearer with a goto, thenperhaps a goto was the best thing to use.
  18. 18. Dont you ever use gotoIf the code would have been clearer with a goto, thenperhaps a goto was the best thing to use.Java does not support goto, but still reserves thekeyword. Adding goto support would take minutes, andwould not end the world.
  19. 19. Dont you ever use gotoIf the code would have been clearer with a goto, thenperhaps a goto was the best thing to use.Java does not support goto, but still reserves thekeyword. Adding goto support would take minutes, andwould not end the world. I Feel a disturbance in the Force...
  20. 20. Regard preprocessors as bad
  21. 21. Regard preprocessors as badI can decide for myself when it is appropriate to use macros or conditionalcompilation.
  22. 22. Regard preprocessors as badI can decide for myself when it is appropriate to use macros or conditionalcompilation.Java does not even allowconditional compilation,and it is hilarious, thehoops that you have tojump through as a result.
  23. 23. Regard preprocessors as badI can decide for myself when it is appropriate to use macros or conditionalcompilation.Java does not even allowconditional compilation,and it is hilarious, thehoops that you have tojump through as a result.
  24. 24. Regard preprocessors as badSome legitimate uses:
  25. 25. Regard preprocessors as badSome legitimate uses:● Porting legacy code
  26. 26. Regard preprocessors as badSome legitimate uses:● Porting legacy code● Avoiding repetitive boilerplate
  27. 27. Regard preprocessors as badSome legitimate uses:● Porting legacy code● Avoiding repetitive boilerplate● Abstracting of identifiers
  28. 28. Regard preprocessors as badSome legitimate uses:● Porting legacy code● Avoiding repetitive boilerplate● Abstracting of identifiers● Implementing support for multitasking
  29. 29. Regard preprocessors as badSome legitimate uses:● Porting legacy code● Avoiding repetitive boilerplate● Abstracting of identifiers● Implementing support for multitasking● Registration of string to object mapping
  30. 30. Regard preprocessors as badSome legitimate uses:● Porting legacy code● Avoiding repetitive boilerplate● Abstracting of identifiers● Implementing support for multitasking● Registration of string to object mapping● And much, much more stuff thats not computer sciency, but helps you Get Stuff DoneTM
  31. 31. Regard preprocessors as badC# learned the lesson of conditional compilation, but still will not let me usemacros. Which means more...
  32. 32. Regard preprocessors as badC# learned the lesson of conditional compilation, but still will not let me usemacros. Which means more...
  33. 33. Might we suggest always saying new
  34. 34. Might we suggest always saying newIt is a sad fact of life that programs have to allocate memory, which ismessy and slow and affects performance.But to rub it in all the time is just plain senseless.
  35. 35. Might we suggest always saying newIt is a sad fact of life that programs have to allocate memory, which ismessy and slow and affects performance.But to rub it in all the time is just plain senseless. Vector3 vec = current + new Vector3(1,2,3); DoSomethingImportant( new Vector3(a,b,c), new Vector3(d,e,f), new Vector3(g,h,i));
  36. 36. Might we suggest always saying newThis is what would actually happen if experienced programmers were notconstantly reminded that doing stuff causes memory allocations:
  37. 37. Might we suggest always saying newThis is what would actually happen if experienced programmers were notconstantly reminded that doing stuff causes memory allocations: Nothing....
  38. 38. Might we suggest always saying newAnd its not as if C# is consistent, is it?
  39. 39. Might we suggest always saying newAnd its not as if C# is consistent, is it?You are forced to say new all the time, but can then createaccessors that could actually end the world through what looks likean innocent variable read.
  40. 40. Might we suggest always saying new DebugOut ( fluffyKitten.name );
  41. 41. Might we suggest always saying new DebugOut ( fluffyKitten.name );
  42. 42. Fact is OOP should make you gladObject orientated programming did not turn out to be thecure for our ills.
  43. 43. Fact is OOP should make you gladAre objects really the best building blocks of code?
  44. 44. Fact is OOP should make you gladAre objects really the best building blocks of code?How about keeping data and functionality separateinstead?
  45. 45. Fact is OOP should make you gladAre objects really the best building blocks of code?How about keeping data and functionality separateinstead?The first thing an architect seems to do with OOP isseparate data from functionality through interfaces.
  46. 46. Fact is OOP should make you gladAre objects really the best building blocks of code?How about keeping data and functionality separateinstead?The first thing an architect seems to do with OOP isseparate data from functionality through interfaces.Compilers are generally designed around the OOP model,making it harder to solve programming problems inother ways.
  47. 47. Fact is OOP should make you gladThis means more...
  48. 48. Fact is OOP should make you gladThis means more...
  49. 49. So you want to overload?
  50. 50. So you want to overload?Overloading functions and operators really can be veryuseful, but many languages refuse to support them fordubious reasons.
  51. 51. So you want to overload?Overloading functions and operators really can be veryuseful, but many languages refuse to support them fordubious reasons.Javascript does not even support overloaded functions.
  52. 52. So you want to overload?Lets compare two pseudo code fragments:
  53. 53. So you want to overload?Lets compare two pseudo code fragments: Vector3 N = ( pos1 - pos2 ) . Normalise(); pos1 += N * speed;
  54. 54. So you want to overload?Lets compare two pseudo code fragments: Vector3 N = ( pos1 - pos2 ) . Normalise(); pos1 += N * speed; // or Vector3 N = NormaliseVector3( sub2Vector3( pos1,pos2 )); AddToVector3( ScaleVector3( N, speed ));
  55. 55. So you want to overload?Lets compare two pseudo code fragments: Vector3 N = ( pos1 - pos2 ) . Normalise(); pos1 += N * speed; // or Vector3 N = NormaliseVector3( sub2Vector3( pos1,pos2 )); AddToVector3( ScaleVector3( N, speed ));Questions?
  56. 56. La la lands where weak typing goes
  57. 57. La la lands where weak typing goesThe only reason for strong typing is, lets face it, performance.
  58. 58. La la lands where weak typing goesThe only reason for strong typing is, lets face it, performance.Why, oh why, does C# insist I put an f on my floats?
  59. 59. La la lands where weak typing goesThe only* reason for strong typing is, lets face it, performance.Why, oh why, does C# insist I put an f on my floats? float f = 10.5; // come on compiler, be sensible // It feels like I spend most of my // fixing this when you complain * Disclaimer: This is a rant
  60. 60. La la lands where weak typing goes float f = 10.5;
  61. 61. La la lands where weak typing goes float f = 10.5; Its a constant! What on earth does the error serve?
  62. 62. La la lands where weak typing goes float f = 10.5; Heres what would happen if you relaxed...
  63. 63. La la lands where weak typing goes float f = 10.5; Heres what would happen if you relaxed... Nothing....
  64. 64. La la lands where weak typing goes And this: Tank tank = GetObject("Tank") as Tank;
  65. 65. La la lands where weak typing goes And this: Tank tank = GetObject("Tank") as Tank; OK, got it, its a Tank!
  66. 66. La la lands where weak typing goes And this: Tank tank = GetObject("Tank") as Tank; OK, got it, its a Tank!
  67. 67. La la lands where weak typing goes And this: Tank tank = GetObject("Tank") as Tank; OK, got it, its a Tank!
  68. 68. La la lands where weak typing goes And this: Tank tank = GetObject("Tank") as Tank; OK, got it, its a Tank! This is a tank
  69. 69. Tis right to make everything private
  70. 70. Tis right to make everything privateIt started innocently enough, as: class Foo { public: int share_this; int share_that; // ... }But then this was seen as too easy by the designers of C#.
  71. 71. Tis right to make everything privateSince they decided that sharing information should be painful to aprogrammer, they insisted on: class Foo { public int share_this; public int share_that; // ... }
  72. 72. Tis right to make everything privateSince they decided that sharing information should be painful to aprogrammer, they insisted on: class Foo { public int share_this; public int share_that; // ... } // uh uh, wait...
  73. 73. Tis right to make everything privateSince they decided that sharing information should be painful to aprogrammer, they insisted on: public class Foo { public int share_this; public int share_that; // ... }
  74. 74. Tis right to make everything privateOf course, after a while you get sick of having your compiles fail....
  75. 75. Tis right to make everything privateOf course, after a while you get sick of having your compiles fail.... ...So you just put public in front of everything.
  76. 76. Tis right to make everything private● Typing public all the time is tedious
  77. 77. Tis right to make everything private● Typing public all the time is tedious● It slows you down when you forget
  78. 78. Tis right to make everything private● Typing public all the time is tedious● It slows you down when you forget● 95% of the code you write will never be part of some giant architecture.
  79. 79. Tis right to make everything private● Typing public all the time is tedious● It slows you down when you forget● 95% of the code you write will never be part of some giant architecture.● When you a prototyping you often do not know in advance what you want to be public
  80. 80. Tis right to make everything private● Typing public all the time is tedious● It slows you down when you forget● 95% of the code you write will never be part of some giant architecture.● When you a prototyping you often do not know in advance what you want to be public● Because C# does not support the friend keyword, there is no easy way to make data visible only to certain objects, so you make everything public anyway.
  81. 81. Tis right to make everything private● Typing public all the time is tedious● It slows you down when you forget● 95% of the code you write will never be part of some giant architecture.● When you a prototyping you often do not know in advance what you want to be public● Because C# does not support the friend keyword, there is no easy way to make data visible only to certain objects, so you make everything public anyway.● Its not even the right kind of privacy
  82. 82. Tis right to make everything privateWhat you really want is interfaces that can only be called byauthorised modules...
  83. 83. Tis right to make everything privateWhat you really want is interfaces that can only be called byauthorised modules... Maybe it would be good if only certain modules are authorised to call AddFunds()?
  84. 84. Tis right to make everything privateWhat you really want is interfaces that can only be called byauthorised modules... Maybe it would be good if only certain modules are authorised to call AddFunds()?
  85. 85. And that brings us back to Dont. ● Dont think you know my needs better than me
  86. 86. And that brings us back to Dont. ● Dont think you know my needs better than me ● Dont take my tools away
  87. 87. And that brings us back to Dont. ● Dont think you know my needs better than me ● Dont take my tools away ● Dont restrict creativity
  88. 88. And that brings us back to Dont. ● Dont think you know my needs better than me ● Dont take my tools away ● Dont restrict creativity ● Dont complicate the simple in the name of an ideal
  89. 89. And that brings us back to Dont. ● Dont think you know my needs better than me ● Dont take my tools away ● Dont restrict creativity ● Dont complicate the simple in the name of an ideal ● Dont stop me doing what needs to be done
  90. 90. And that brings us back to Dont. ● Dont think you know my needs better than me ● Dont take my tools away ● Dont restrict creativity ● Dont complicate the simple in the name of an ideal ● Dont stop me doing what needs to be done ● Dont keep arguing with me
  91. 91. And that brings us back to Dont. ● Dont think you know my needs better than me ● Dont take my tools away ● Dont restrict creativity ● Dont complicate the simple in the name of an ideal ● Dont stop me doing what needs to be done ● Dont keep arguing with me ● Dont get in my way
  92. 92. Don’t Bring Me Down

×