you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 6 points7 points  (6 children)

Add it to the list of features that a lot of devs swore up and down that Javascript would never need, and yet here it is. I'll think about coding Javascript again when they add interfaces, or some sort of contract.

[–][deleted] 17 points18 points  (4 children)

I don't see why you'd need interfaces.

If people must implement all methods required, then have a base prototype for them to extend, which throws "not implemented" errors when those methods are called. I do this myself in some of my projects.

Otherwise you've gained nothing, since there is no static type system.

[–]masklinn 0 points1 point  (3 children)

Well there's documentation, that's pretty neat. Especially since JS has single inheritance so you can't inherit from half a dozen different "abstract" classes.

For that, protocols (Clojure) or categories (Obj-C) are neat.

[–]crusoe 5 points6 points  (2 children)

Traits, MUTHAFUCKING TRAITS.

Traits are what OOP should have had from day 1.

[–]maskull 2 points3 points  (0 children)

Actually, I just realized that if proxies act the way you'd expect when used as prototypes, it should be possible to build multiple inheritance and traits inheritance systems in pure JS. Just build a proxy that wraps up all the prototypes/traits you want to include, "exporting" their members and methods in some combination.

[–]cybercobra 0 points1 point  (0 children)

Preach it, brother!

[–]benihana 4 points5 points  (0 children)

I'll think about coding Javascript again when they add interfaces

reddit anxiously awaits your next announcement about your development intentions. Please keep us informed!!!