Skip to content

Instantly share code, notes, and snippets.

@frenchy64
Last active July 8, 2019 18:05
Show Gist options
  • Save frenchy64/2bff094b82aa2e778dc0b1c070f49f8a to your computer and use it in GitHub Desktop.
Save frenchy64/2bff094b82aa2e778dc0b1c070f49f8a to your computer and use it in GitHub Desktop.
Notes on JavaScript prototypes

Why Objects were successful

https://www.cs.cmu.edu/~charlie/courses/15-214/2014-fall/slides/25-history-oo.pdf

  • essense of objects is (dynamic) dispatch
  • dispatch provides interoperability
  • first-class interoperability is critical to frameworks and ecosystems
  • frameworks and ecosystems are economically critical to the software industry
  • likely a significant factor in objects' success
  • Also talks about early mistakes in Simula

Why objects are inevitable

http://www.cs.cmu.edu/~aldrich/papers/objects-essay.pdf

  • Cook's definition: "An Object is a value exporting a procedural interface to data or behavior

Self: The power of simplicity

http://bibliography.selflanguage.org/_static/self-power.pdf

  • real-world vs computers: can make sweeping changes by changing shared behavior in computers

Self: organizing programs without classes

http://bibliography.selflanguage.org/_static/organizing-programs.pdf

Lua has prototypes via the metatable and __index property

https://www.lua.org/pil/16.1.html

Why prototypal inheritance matters

https://aaditmshah.github.io/why-prototypal-inheritance-matters/

Prototypal OO using JS

https://alistapart.com/article/prototypal-object-oriented-programming-using-javascript/

  • rocking chair = prototype of chair + 2 rockers
    • no blueprint needed

JS the core 2nd ed

http://dmitrysoshnikov.com/ecmascript/javascript-the-core-2nd-edition/

Crockford on Prototypes

https://crockford.com/javascript/prototypal.html

  • Crockford "invents" Object.create
    • never included in the language originally
      • original JS: new f() produces a new object that inherits from f.prototype
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment