Hacker 101/102 - Introduction to Programming w/Processing

5,209 views

Published on

Basic introduction to programming concepts using Processing. Developed for code4lib 2010 conference preconf "Hacker 101/102".

4 Comments
3 Likes
Statistics
Notes
  • Getting Started with Processing: A Hands-On Introduction to Making Interactive Graphics --- http://amzn.to/1pC7lY0
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Learning Processing, Second Edition: A Beginner's Guide to Programming Images, Animation, and Interaction (The Morgan Kaufmann Series in Computer Graphics) --- http://amzn.to/1RsFJki
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Processing: A Programming Handbook for Visual Designers and Artists (MIT Press) --- http://amzn.to/1UdwVPX
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • things
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
5,209
On SlideShare
0
From Embeds
0
Number of Embeds
830
Actions
Shares
0
Downloads
59
Comments
4
Likes
3
Embeds 0
No embeds

No notes for slide

Hacker 101/102 - Introduction to Programming w/Processing

  1. 1. hacker 101/102 code4lib 2010 preconference Asheville, NC, USA 2010-02-21
  2. 2. i. intro why are we here?
  3. 3. learn to hack?
  4. 4. ...not exactly
  5. 5. we work in libraries so we can help people
  6. 6. we hack to help ourselves help others
  7. 7. what’s a good hacker?
  8. 8. languages? standards? jargon? math? logic? frameworks?
  9. 9. nope!
  10. 10. a good hacker knows when to ask for help
  11. 11. a good hacker knows how to ask for help
  12. 12. a good hacker knows how to help other hackers
  13. 13. a good hacker knows other hackers to ask for help
  14. 14. when to ask how to ask how to answer whom to ask
  15. 15. i’m here because i want to be able to ask you
  16. 16. when to ask?
  17. 17. thirty minute rule
  18. 18. for today: three minute rule
  19. 19. how to ask? see “How to ask questions the smart way”
  20. 20. we’ll get started together
  21. 21. basics in Processing regexes in JavaScript glue it together in Python
  22. 22. explore on your own
  23. 23. get comfortable asking for help
  24. 24. ii. the basics Processing
  25. 25. canvas, grid, points
  26. 26. 200 300 200 400
  27. 27. lines, rects, ellipses
  28. 28. start end
  29. 29. syntax, functions, errors
  30. 30. don’t be afraid to break stuff
  31. 31. variables, loops
  32. 32. test type “integer” initial value increment repeating actions
  33. 33. every lang has loops • for (a=blah, a<foo, a=a+bar) {...} • for each (foo in blah) {...} • for i in range(20): ... • while (foo != bar) do {...} • next, continue, break
  34. 34. more variables, loops
  35. 35. even more variables, loops
  36. 36. explore on your own
  37. 37. iii. functions, objects, the main loop
  38. 38. why functions?
  39. 39. setup, draw, void
  40. 40. function structure RETURN_TYPE FUNCTION_NAME ([var a, ...]) {...statements...}
  41. 41. setup, draw • void: returns nothing (into the void!) • setup: prep stuff • draw: the “animation loop” or “main”
  42. 42. different kinds of “main” • Processing: draw() is like an animation “cell” • in a GUI: the user feedback loop • command-line app: parse args, then main() • web app: the user feedback loop
  43. 43. setup, draw, void
  44. 44. we can write this better
  45. 45. setup, draw, void
  46. 46. see the problem?
  47. 47. setup, draw, void
  48. 48. DRY Don’t Repeat Yourself
  49. 49. a little better
  50. 50. more task specific
  51. 51. add delay (10);
  52. 52. initialization now try this no loop! if/else i.e. “conditional”
  53. 53. • draw() is already a loop; why another? • “i” becomes state • tightens up draw()
  54. 54. what about objects?
  55. 55. obj ect i fied
  56. 56. • it says what it is • it removes a lot of repeated noise •it’s kinda overkill here • we don’t use rp1 and rp2 again
  57. 57. no single answer • design a matter of taste • sometimes things should be called what they mean • sometimes an “int i” is just an “int i” • think about what you’ll understand later
  58. 58. explore on your own

×