From: Brian Mitchell Date: 2005-09-19T08:36:13+09:00 Subject: Re: Language recommendations from ruby persons.... On 9/18/05, Gavin Kistner wrote: > On Sep 18, 2005, at 4:12 PM, Brian Mitchell wrote: > > Javascript. It is a very cool language. Like Io in many ways too. If > > you can get passed the bad rap of DHTML then this language is very > > well designed. > > But, to put in my two cents, it ain't perfect. The language is made > up of objects (with methods, properties), and it lends itself quite > well to making simple hash-objects which all 'inherit' from the same > object. (The 'prototype' property of functions is like Lua's __index > metatable property, causing a lookup-chain to be used for specific > objects. Despite the name of the property, it is not a 'prototype- > based' language, since instances of a 'class' refer to that class, > rather than being copies of it.) I think that could be argued but no matter. It has prototype features with other features also available. > However, despite my own love of JavaScript, it ain't pretty in three > regards: > 1) There's no standalone interpreter (that I know of, and certainly > not part of any 'official' distribution), which leaves you at the > mercy of WSH or some sort of web-based interpreter[1]. There are javascript libraries on certain platforms but beyond that I think Rhino can be made standalone. > > 2) Similarly, the core language can do very little on its own. No > file IO, no http libraries, no threading, no matrix or math > libraries. You're at the mercy of whatever additional libraries your > interpreter (or own JS bindings) give you.[2] > The libraries are lacking, but with some cleverness hard things like asynchronous execution can be handled with CPS and other nice tools. I/O is lacking. Good enough to learn still as the DOM is a rich library in itself (not great IMO but still very useful). Math is poor but is good enough or can be built upon. Same goes for matrix stuff. > 3) You can simulate a class, but not too well[3]. (You can use > closures to define 'private' and 'protected' methods, but they > require new instances of the method functions to be allocated for > each instance of the object.) Inheriting one class from another is > even more difficult[4]. > This type of emulation can actually be simplified if your private etc.. methods are kept in a separate object and delegated to. The idea is to minimize copying by using intermediate objects that can be hidden a number of ways (function based closures can be powerful tools). You probably know this though. Toy around. I am sure you can find some ways to simplify your class system to make it very painless. Though, in the end, you probably have more experience than me. > Lua is powerful because it's bare-bones speedy and simple, but it's > not enjoyable to work with as a scripter. Ruby is awesome for the > scripter, but (at the moment) too slow to do everything in for CPU- > intensive apps. JS is sort of a nice mix between pleasing features > and speediness. But only if you have a good interpreter and > environment exposing all the native objects you need to get your work > done. > Lua is good when you need to be practical. I never fell in love with its tables system. seems too far out of the way for how I think. I guess I should have mentioned it.. I still only recommend it as an embedded language. > Basis for my analysis: I've been programming in JavaScript in web > browsers since 1996, and using it in my company's 3D product[5] with > JS bindings to C++ native methods[6] for the last year. Cool. > [1] http://phrogz.net/tmp/simplejs.html > [2] http://phrogz.net/ObjJob/objects.asp?langID=4 > [3] http://phrogz.net/JS/Classes/OOPinJS.html > [4] http://phrogz.net/JS/Classes/OOPinJS2.html > [5] http://www.anark.com/ > [6] http://phrogz.net/ObjJob/objects.asp?langID=11 > Brian.