Activate your free membership today | Log-in

Monday, June 27th, 2005

Grokking Prototype-based OO in JavaScript

Category: JavaScript

<>p>“JavaScript doesn’t seem very OO”. I hear that a lot. How far from the truth it is though. A lot of us are just trained to think that OO == CLASS BASED OO, which has won out in a lot of popular OO languages of late.

JavaScript is fully OO, and arguably more so than many other languages (everything is an object, thank god). It just so happens that Brenden Eich was a fan of Self, and choose to sent JS down the path of prototype based OO.

Take some time looking into the way that JS works. It is actually ridiculously elegant, and if you need to grok inheritence read the smart article Object Hierarchy and Inheritance in JavaScript.

Another way to grok this all, is to go to Glenn Vanderburg‘s talk about JavaScript on the NoFluffJustStuff conference tour.

His opening intro is one of the best starts to a presentation I have ever seen. Absolutely classic.

Armed with the knowledge, you will find your head exploding as you realise the power that you have in JavaScript. You can change anything. Hence the quote that JavaScript is LISP with a different syntax!

Related Content:

  • Two ways to SUM a complex expression
    From the given table I want to derive the count for OOS as a separate field (CntOOS) that gives me the number of times 'OOS' appeared in the above...
  • FAQ: Lotus Notes, Domino and JavaScript
    Caught in a JavaScript jam? Before posing a question to our SearchDomino.com experts, check out our list of frequently asked questions on JavaScript...
  • Diet Ajax, 100% JavaScript free
    The open source Ajax framework ZK 1.0 has been released with its own markup language along with XUL and XHTML components to get around programming in...
  • Microsoft works on Ajax JavaScript tools
    In a session at the recent Ajax Experience conference in San Francisco, Matt Gibbs, development manager in the UI Framework and Services team at...
  • Junk JavaScript?
    Should JavaScript and HTML be replaced with "proper" languages that might give more bang for the buck in rich Internet applications (RIAs)? One reader...

Posted by Dion Almaer at 11:25 am
5 Comments

+++--
3.2 rating from 14 votes

5 Comments »

Comments feed

JavaScript is LISP with a different [in that whacked out and broken kind of way] syntax [with no macros].

Comment by Bob Ippolito — June 27, 2005

I guess it’s also worth mentioning that “Object Hierarchy and Inheritance in JavaScript” was written in 1997, and has not been updated for modern variants. For example, it describes how one would implement an instanceOf function, because there is no instanceof operator. Well, there is one, and it’s been there since JavaScript 1.4.

Comment by Bob Ippolito — June 27, 2005

Indeed, I’ve found Javascript an elegant, flexible and powerful language, against my original expectations.

Comment by Mike Harper — June 28, 2005

Thanks, Dion! That made my day.

Comment by Glenn Vanderburg — June 29, 2005

If you know of any people that developed for the Apple Newton PDA, ask them about prototype based OO. Newtonscript, the language invented for the device, was the first use of a prototype language in a commercial setting. I did that for 2 years before switching to Java. It took a while to get my brain thinking in a Class-Oriented way instead of Object-Oriented.

I do have some problems with parts of JavaScript’s syntax, but the prototype nature is welcomed.

Comment by Greg Vaughn — June 29, 2005

Leave a comment

You must be logged in to post a comment.