tags:

views:

129

answers:

4

I've just started learning javascript and noticing its attributes relating to other OO languages (weakly typed like php/tcl, has error handling and inheritance like java's model). When I was learning java there were several "C++ vs. Java" comparisons that really helped me wrap my head around the philosophy of the language.

Javascript does seem to have some stuff different than other languages such as closures, was wondering if anybody knows a good comparison/rundown of the language compared to the functional/OO languages i know (php, C/C++, java, tcl) to help me get a handle on it.

Thanks!

+2  A: 

That's tough. It's a bit of everything. Scheme in Java clothing, I think it's been called.

Eich was going for something functional and then got the mandate to make it look like Java. Knowing the forces that shaped JavaScript help explain why it's such a mix.

Nosredna
A: 

Hi ambertch. I've always personally considered javascript to be similar to ruby. I'm not sure if you'll accept this as an answer to your question, as I've never personally read a "comparison" of the two, but maybe it'll help your google searches. :-)

hobodave
Especially if you use Js.Class. http://jsclass.jcoglan.com/
Nosredna
Thanks Nosredna! I'd never seen that.
hobodave
+3  A: 

Here's a good comparison article: Where does Javascript fit in?

It covers Javascript's intended applications, and the differences among it and OO languages, including Java, as well as the general strengths and weaknesses of its approach.

And here is a fantastic diagram showing the relationships among pretty much every language. It characterizes Javascript as a descendant of both Smalltalk and (of course) Java.

pianoman
The diagram shows javascript descending from smalltalk via self, which is not an insignificant fact, particularly in relation to this question, because javascript's object system takes more from self than it does from smalltalk.
Breton
Yeah, I thought that was nifty :)
pianoman
Diagram is MIA.
Sean McMillan
Just tried it and it worked...here's the URL, and then the original containing URL:http://people.mandriva.com/~prigaux/language-study/diagram.pnghttp://rigaux.org/language-study/concepts-history.html
pianoman
A: 

Javascript's OO model is more prototype-based instead of class-based. Unfortunately, class-based languages have been so overwhelming in popularity that alternative OO models are quite obscure nowadays.

With regards to Javascript, look up Self and Scheme, from which Javascript inherited key design principles.

Daniel