View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Prototype Based Programming: An Integral Part of the Future of Object Oriented Programming? (Including Smalltalk?)

By Tony Espejo. Email here.

This topic is a good extension on Lex’s lecture of “Language Choices.”

First off, I would like to say that my knowledge of prototype-based programming was slim to none before I read an article on Slate, an experimental prototyping-based derivative of the Smalltalk language. The only reason I even read the article was because of it’s relation to Smalltalk, which I’ve been currently thinking about all semester thanks to CS 2340 (CowboyNeal).

So what is prototype-based programming? That is a good question, and one I asked myself after finding out about Slate. Well, since I took CS 1322, my knowledge of object oriented programming consisted of only class-based programming. You know? The one where you create a class that defines the layout of the objects you intend to instantiate from it? Well, with prototype-based programming, you don’t even use classes. I know what you are thinking. I was thinking it too. How in the world can object oriented programming exist if we don’t use classes! Java uses classes. Squeak uses classes. I thought every OO language uses classes. Nope. Not all of them. The Self language is the crème de la crème example. But I will talk about Self later (Wikipedia).

With prototype-based programming you create only objects. If you want more of that type of object you “clone” it. If you want to add or change functionality of an object, you “clone” the object, and change what you want in the new “cloned” object. Objects don’t have pointers to classes in pointer based languages, they just point to another object. So you may have this sort of tree structure where every object points to another one, all the way up the tree until the root object. The root object will probably be some sort of “generic” object (Wikipedia).

Is it practical? Sun seemed to think so. You know that company backing that popular caffeinated language. What’s it called again? They were developing another language, Self, a prototype-based object oriented language. Look here at some of the projects the Self Group was working on. Have you ever heard of Morphic? Yeah, thank Self for that wonderful invention (The Self Homepage). There are other languages that are moving towards prototype-based programming. Some of these are Javascript, Cecil, NewtonScritp, lo, MOO, and REBOL (Wikipedia).

So, what are the advantages of prototype-based programming? You probably have already thought about some yourself.

In pointer based languages, you save memory. Instead of having a class definition take up memory, and every instance take up memory, clones of objects generally take up a small amount memory, to almost none at all. Remember? Every object just points to another object. Thus the fewer changes you make to a clone of an object, the fewer the amounts of new data need to be stored, and thus the fewer amounts of memory you need for a new clone (Wikipedia).

Prototype-based languages will help simplify the understanding of each object. I have known people who have struggled with the concept of classes when taking CS 1322. It is usually the most important hurdle to understanding class-based languages. Those who grasp the concept faster, usually end up with the better grade. Prototype-based languages are very intuitive. It makes it easier to learn a language, and easier to sift through a very large program (Smith).

Prototype-based languages also make it easier to fix bugs in code. This is because prototype-based languages use the concept of “slots.” A method is a slot. This term is used because you can change the functionality of any object, just by changing a method. When you place new code into an object's “slot” – viola! You have changed the functionality of that object. Even data can be considered a “slot”. Thus fixing bugs in a large scale program is easy. Just change the “slot” that you are having a problem with (Wikipedia).

User Interfaces would benefit from the use of prototype-based languages. User interfaces contain a small amount of objects. Objects tend to be created in interfaces for very specific purposes. Instead of creating many classes for different purposes, or creating a few large classes, each with many methods for implementation, cloning objects may be an easier solution (Smith).

Will prototype-based programming replace other current practices in object oriented programming? Of course not! Prototype-based programming comes with its disadvantages too. Prototype-based programming will only be good for specific purposes. It doesn’t benefit the nature of repetitive types of data, such as those used in databases. In fact, prototype-based programming would decrease efficiency for these types of systems. Class-based programming would still be the recommended solution for these kinds of problems (Smith).

What does prototype-based programming have to do with Smalltalk? Take a look at Slate. Slate is still in a very early stage of development. The goals of its developers are to improve inefficiencies with current object oriented languages. For a concrete list of reasoning in why slate is being developed, look here. Slate also plans to utilize Morphic, that fun and friendly tool we utilize in Squeak (The Home of the Slate Programming Language).

Once again, I’m not trying to say that prototype-based languages are the replacement for all things object oriented. I just wanted to share some insight on a different way to go about object oriented programming. That, and show off something cool that I learned recently. : )

Note: This topic was discussed briefly in the "Building User Interfaces" lecture.

References:
CowboyNeal. "The Slate Programming Language." http://developers.slashdot.org/developers/04/03/27/1627220.shtml?tid=126&tid=156&tid=162&tid=99.
CTO: Self. http://cliki.tunes.org/Self.
Guzdial, Mark. "Buidling User Interfaces."
    http://coweb.cc.gatech.edu:8888/cs2340/uploads/4154/6-BuildingUserInterfaces.ppt.
History of Morphic. http://minnow.cc.gatech.edu/squeak/2139.
The Home of the Slate Programming Language. http://slate.tunes.org/.
The Self Group. http://research.sun.com/self/people/group.html.
The Self Homepage. http://research.sun.com/self/.
Smith, Walter R. "Using a Prototype-based Language for User Interface: The Newton Project’s Experience." http://wsmith.best.vwh.net/OOPSLA95.pdf.
Spoon, Lex. "Language Choices." http://coweb.cc.gatech.edu:8888/cs2340/uploads/4154/18-LanguageChoices.ppt.
Wikipedia. "Prototype-based programming." http://en.wikipedia.org/wiki/Prototype_based.

Want to discuss this topic further? Then do so right here: Prototype Discussion

Links to this Page