Evolution of a Prototypal Language User

  1. Fresh out of Java or C++, learning JavaScript. Look up on the internets how to define a class. It doesn’t quite work. Avoid the “new” keyword, because it is dangerous.
  2. Learn about prototypes. Design constructors that work how you expect. Re-introduce “new” into your code. Note: Many programmers stop here. And that is fine.
  3. Learn about Object.create, Object.getPrototypeOf. Mix and match constructors with just “raw” Object prototype usage. Monkey-patch native prototypes. Use prototypes to do everything.
  4. Come back to sanity. Use constructors+prototypes to define objects, but use Plain Old Functions more often. Prefer composition to “is-a” inheritance, but use is-a when it makes sense. Use new and prototypes to create objects that all extend the same prototype, because, well, why not?
  5. Re-read the Gang of Four book that you once thought was so inspiring. Grok how the “class” pattern is just a special case of disciplined prototype re-use. Realize that prototypal inheritance makes a lot of those patterns trivial, and it’s a bit silly to spend so much time on them.
  6. Begin to notice actual applications that are best moduled with prototype chains. (Branching recursive file-system walks, configuration object overriding, inheritance trees, etc.)

I’m really wondering what’s next on this list.

The great thing about enlightenment is that it doesn’t end. It is continually extending itself in multiple non-overlapping directions.

  1. pixel67 reblogged this from izs
  2. bosch-mfq-3550 reblogged this from izs
  3. donwb reblogged this from izs
  4. wellwaterpumps reblogged this from izs
  5. water-cooling reblogged this from izs
  6. shashikiranreddy reblogged this from ugra
  7. jonprins reblogged this from izs
  8. fusionet24 reblogged this from izs
  9. ugra reblogged this from izs
  10. lachstock reblogged this from izs
  11. izs posted this
maybe something awesome from lorempixel.com