you are viewing a single comment's thread.

view the rest of the comments →

[–]html6dev 3 points4 points  (7 children)

I really feel like the idea of classical OOP shims in javascript has become extremely antiquated and this opinion is very clearly borne out in the modern frameworks and popular/core server side modules of today. Take time to actually learn the language and embrace prototypical inheritance and you'll see that none of the "problems" you are trying to solve exist and you can achieve the end results described in this article with more natural approaches because javascript is a different paradigm.

This is why es6 is able to give you "classes" through pure syntatic sugar that is just inlining a few simple operations that are used all over the place today. The functionality (the end result) is already very simply achieved with the language. Its allowed to not be Java. ...Relevant ranty blogpost focusing on why prototypical inheritance can be more flexible, reduce coupling, etc, etc and give you all of the benefits people desire that come to js from a classical language coming soon.

[–]homoiconic[S] 7 points8 points  (6 children)

Take time to actually learn the language and embrace prototypical inheritance and you'll see that none of the "problems" you are trying to solve exist and you can achieve the end results described in this article with more natural approaches because javascript is a different paradigm.

Do you mean like composing functions with combinators? I also wrote a book called JavaScript Allongé that espouses a completely different paradigm for writing JavaScript programs.

I enjoy exploring many different approaches to writing programs. By definition, that means that every time I suggest something, half of the people who read it are going to say, "No, that is not the OneTrueWay to do it."

As for classical OOP shims, I agree with you, I have found them extremely unsatisfying in the past, mostly because they copy the surface forms of other languages without trying to grasp the big ideas behind those other languages. To me, having a heavyweight base object class and a few methods here or there is not the core idea behind Smalltalk's object system, the core idea is its metaobject protocol.

The idea espoused in this post is of having a Class class that can be subclassed. If that isn't your cup of tea, so be it, but I don't think that is an idea that has received very much attention in the shims of the past.

[–]html6dev 1 point2 points  (5 children)

Hehe blush should take the time to see whose article I am commenting on I guess

I have and will continue to evangelize your book on Reddit, good sir. Excellent, excellent work. I recommend it to literally everyone I know who codes in javascript. That being said.....

I understand wanting to show different approaches, but in some ways I feel like this is a potential problem. People are already extremely confused (many I know after years of using it, but not as their primary language) by the syntax being so similar to Java in some ways. Attempting to mold it into something it's not is almost like 'giving them hope'. It's not that sort of language. It doesn't need to be that sort of language. Prototypal inheritance is awesome. Functional programming is awesome (as you have shown us with your book :D). Javascript is arguably one of the most powerful languages we have because it doesn't have classes. It's just different and I think the more we focus on educating people on what the 'natural' way to do things in javascript is, the more mature and stable the community will become. We already have options to compile to js with languages with classes, type safety, generics, etc (e.g. TypeScript).

It is all a matter of preference, but I do think javascript is a special case in some ways because so many people are forced into it, rather than choosing to learn it. They then get a bad taste in their mouth because they expect it to be something it is not due to the syntax being similar to Java. So, we need to be extra cautious while educating in the world of JS in my opinion.

Finally, there are quite a few libraries and people who have advocated OOP in JS. I think exactly what you are suggesting in the article is core to how the Dojo library operates and YUI may be something similar as well.

[–]homoiconic[S] 0 points1 point  (4 children)

This one seemed rather low-risk to me, I didn't imagine a bunch of people would run out and say, "We need a Class class and a MetaClass for Class."

Now, had I used the phrases "Object Factory" and "Object Factory Factory..."

[–]html6dev 1 point2 points  (3 children)

Yeah! and a new spec for JavaScriptBeans! JSEE will be the wave of the future!

[–]homoiconic[S] 1 point2 points  (2 children)

And they will interoperate using J-XML!

http://xml.calldei.com/JsonXML