Code Reading

Code Reading

Learning More about Ruby by Reading Ruby Source Code'

F2dcf6633971844e19ca96ea294ba976?s=128

高見龍

May 31, 2013
Tweet

Transcript

  1. None
  2. 高見 龍 です

  3. 高 見龍 です @eddiekao

  4. Code Reading Chimpr Learning more about Ruby by Reading Ruby

    Source Code
  5. I come from Taiwan photo by Fishtail@Taipei

  6. photo by J o n a G r a p

    h Y 
  7. photo by HeyNix

  8. photo by randomwire

  9. None
  10. None
  11. I’m a Python guy (≈ 2 years) I’m a iOS

    app guy (≈ 2 years) I’m a Flash guy (≈ 8 years) I’m a Ruby guy (≈ 4 years)
  12. But not a C guy, yet!

  13. Ruby > Rails

  14. “I’m a SHOW OFF person”

  15. “Experience Sharing is fun”

  16. Current Status 80% iOS app, 20% Ruby/Rails

  17. 100% Ruby Lover!

  18. None
  19. Web Development Conference in Taiwan

  20. None
  21. 2 days, 3 tracks session

  22. 750+ attendees

  23. all tickets sold out in 4 mins

  24. WebConf Taiwan 2014

  25. Will be held on Jan 2014

  26. 850+ attendees in 2014, hopefully.

  27. All about web development

  28. 楽しい

  29. http://webconf.tw

  30. Code Reading

  31. Why read source code? How to start? What I learned?

    Anything interesting?
  32. Why read source code ?

  33. Ian Ruotsala

  34. http://blog.rubybestpractices.com/posts/gregory/005-code-reading-stdlib.html “once you start digging around in someone else’s code

    base, you’ll learn a lot about your own strengths and weaknesses” - Ruby Best Practice
  35. See how the Core Team write Ruby

  36. photo by chaines106 Read the source, Luke!

  37. source http://kyaraben.seesaa.net/article/168967765.html source code は友達

  38. Contribution!

  39. Committer in my dream!

  40. FUN! :)

  41. Requirement ?

  42. C language

  43. “What if I don’t have any skill of C?”

  44. “Just Learn It!”

  45. Curiosity and Passion

  46. Where to Start ?

  47. get source files!

  48. download from Ruby website, or clone from github

  49. Ruby 1.9.2 p290

  50. None
  51. Quick browsing.. :)

  52. * .c + * .h * .rb (stdlib)

  53. Let’s have some fun!

  54. Object Class String Array Hash

  55. “ruby.h”

  56. Object => RObject Class => RClass String => RString Array

    => RArray Hash => RHash
  57. “object.c”

  58. Init_XXXX( )

  59. “all Class’s class is a Class”

  60. “new”

  61. class A def initialize puts "hello" end end a =

    A.new
  62. Proc

  63. How to execute a Proc?

  64. proc.call proc[ ] proc.yield proc === 123

  65. attributes

  66. push v.s. <<

  67. Object ID

  68. What else?

  69. Haskell-like syntax :)

  70. head (x:_) = x tail (_:xs) = xs

  71. people = { "Eddie" => ["green", "eddie@digik.com.tw"], "Joanne" => ["yellow",

    "hello@yahoo.com"] } people.map { |name, (color, email)| puts [name, email] }
  72. parse.y#8277-8299 shadowing_lvar_gen( ) people = { "Eddie" => ["green", "eddie@digik.com.tw"],

    "Joanne" => ["yellow", "hello@yahoo.com"] } people.map { |name, (_, email)| puts [name, email] }
  73. Method missing

  74. Anything interesting ?

  75. Interesting naming.. XD

  76. Conclusion

  77. “from basic structure”

  78. “don’t be afraid of source code”

  79. source http://kyaraben.seesaa.net/article/168967765.html source code は友達

  80. References

  81. http://i.loveruby.net/ja/rhg/book/ “Rubyソースコード完全解説” (RHG) by 青木峰郎

  82. http://patshaughnessy.net/ruby-under-a-microscope “Ruby Under a Microscope” by Pat Shaughnessy

  83. Chimpr Hope we all can become Jedi Master someday :)

  84. 高見 龍 です

  85. 以上です。 ご清聴ありがとうございました thanks for your listening :)

  86. 高見龍 Contacts photo by Eddie Website Blog Plurk Facebook Google

    Plus Twitter Email Mobile http://www.eddie.com.tw http://blog.eddie.com.tw http://www.plurk.com/aquarianboy http://www.facebook.com/eddiekao http://www.eddie.com.tw/+ https://twitter.com/#!/eddiekao eddie@digik.com.tw +886-928-617-687