views:

149

answers:

4

I am really a big fan of javascript. It is really a great prototype based OOP language. Now I want to learn some other prototype based language. Really really interested in some design guideline i.e How can I manage the code without classes etc. Which language should I choose ? Some resource in design patterns for prototype based language ?

+2  A: 

This is a large subject. I suggest you read this article on wikipedia. At the bottom you will see a list of different languages.

Christian Vik
+1  A: 

Broadly, javascript is the most common (and, perhaps, only?) prototype-based language in use today, but you can use the Prototype Pattern in many different languages like Java and Python - for examples see The wikipedia page.

I would suggest you look for tutorials and guidance on the Prototype Pattern rather than looking for a specific language to work in, particularly since you're in perhaps the most appropriate one already. Note that javascript can be run on the Java platform via Rhino.

The best all-round introduction to prototype patterns, defending their use, is one of Steve Yegge's blog posts, 'The Universal Design Pattern'.

Steve Yegge also points us towards Martin Fowler's article on the topic, which I am off to read!

Phil H
Can you refer me some design guidelines/patterns for prototype languages?
Tinku
+2  A: 

The best guidelines that I have read to take advantage of JavaScript's prototypical nature were in the book JavaScript the Good Parts and you can apply these guidelines to other languages also. I changed the way I code in Python after reading this book.

If you want to learn a language similar to JavaScript, try ActionScript first. Both are based on the same standard. It will be easy and rewarding.

jbochi
yeah, A great book indeed!
Tinku
I really want to check how this prototype nature changes the gof design patterns
Tinku
+11  A: 

The answer to both of your questions is Self. Self is the original prototype-based OO language, and also probably the best one (for a completely unscientific and subjective definition of "best", of course). (In fact, IMHO it's (together with Newspeak) one of the best OO languages, period.)

Anyway, the nice thing about Self is that it also contains a lot of excellent documentation, including but not limited to the famous Self tutorial Prototype-Based Application Construction Using SELF 4.0

There are also a great number of resources at the old Self website at Sun Research:

These two (together with the tutorial mentioned above) explain pretty much exactly what you are asking about. (In fact, the second one pretty much contains your question "How can I manage the code without classes" word for word in the title):

Then, there is Self; The Movie, an introductory video about the Self programming language, the Self GUI, the Self system and the Self VM starring Self's lead designers and developers. Unfortunately, it came out in 1995 on VHS, and when the video was finally digitized, the original tapes were already degraded. You can find several versions of the video on this site with Smalltalk videos. I personally find the Large QuickTime easiest to view.

Here's a couple of other interesting Self links:

Dave Ungar, the primary designer of Self gace a talk at Stanford in September, titled Self and self: whys and wherefores. Streaming video of this talk is available.

A slight problem with Self is that it was basically abandoned by Sun in 1995 in favor of an obscure little scripting language for making animated cartoon characters in electronic TV guides on TV set-top-boxes. (You might have heard of it, it's called Java.) Thus, the latest stable release 4.3 only runs on OSX on PowerPC ( maybe x86, too) and Solaris on a Sparc CPU. A couple of months ago, though, the Self project was picked up again by some of its former members as well as some new fans of the language, and it has now been ported to Linux and OSX on x86, with a usable 4.4 Alpha 2 release available and a final release expected in January.

A couple of other interesting prototype-based languages are:

  • NewtonScript (inspired by Self) was intended to be the application development language for the Apple Newton PDA; it is also the direct inspiration for JavaScript
  • Slate is "a clean slate object-oriented Smalltalk-style environment"
  • Io is a prototype-based programming language inspired by Smalltalk (all values are objects, all messages are dynamic), Self (prototype-based), NewtonScript (differential inheritance), Act1 (actors and futures for concurrency), Lisp (code is a runtime inspectable/modifiable tree) and Lua (small, embeddable)
  • Ioke is a prototype-based programming language that is inspired by Io, Smalltalk, Lisp and Ruby

As far as your question about how to structure programs goes, I must admit that I find that classes actually obscure the object-oriented design. I mean, there is a reason why it's called Object-Oriented Programming, not Class-Oriented Programming.

Jörg W Mittag
It was a pity I can vote for you only once ;)
Eineki
Great Answer! thx
Tinku