JavaScript is a scripting language created by BrendanEich at Netscape that supports PrototypeBasedProgramming, Object OrientedProgramming, and FunctionalProgramming. It was originally called LiveScript, but the name was changed to JavaScript for marketing reasons. Microsoft calls their version JScript. There is now a standardized version, EcmaScript [http://www.ecma-international.org/]. Some have claimed it is Lisp in C's clothing - http://lambda-the-ultimate.org/classic/message8778.html - but being a dynamically-typed functional language is not enough to make something Lisp. JavaScript lacks many features that are crucial to Lisp; macros perhaps being at the top of the list. (Are macros crucial to Lisp? Or, just a great CLOS feature? (Macros *are not* a CLOS feature, they have little to do with CLOS, and actually, the other way round, quite a lot of CLOS would usually be expressed in terms of various macros.)) Perhaps JavaScript is a "dialect of Lisp" in Java's clothing. Or, JavaScript is Scheme in Java's clothing. JavaScript is commonly found in WebBrowser''''''s and servers. It can be embedded in HTML for both client-side and server-side processing. Recently, JavaScript has gained renewed interest for its RPC capabilities. See AjaxWebApplications. On Windows systems, it can be used (along with VBScript) with the Microsoft WindowsScriptingHost as a system scripting language. On Macs, it can be used as an OpenScriptingArchitecture language alongside AppleScript through the use of a plug-in (based on SpiderMonkey, see below). Mozilla.org has two open-source implementations of JavaScript engines, one in Java (RhinoInterpreter, see http://www.mozilla.org/rhino) and one in C (SpiderMonkey, see http://www.mozilla.org/js/spidermonkey). Both engines are embedded in a lot of products and also available for the command line. It's also the basis for DynaScript, the server-side scripting language for Sybase Dynamo (their answer to ASP). '''Language Features''' Unlike Java's inheritance model, JavaScript is prototype and slot based - sorta like NewtonScript and SelfLanguage. It is really quite neat! -- AnonymousDonor * ''Unfortunately, this is going to change with the forthcoming version 2.0, where JavaScript will have a more traditional class-based approach.'' ** (Oh thank you Jesus! -- PaulMurray) *** ''um.. Paul, that's not a good thing, the class based approach is less powerful and less dynamic. Prototypes give you everything classes do and more.'' ** Fortunately for us, prototypes aren't going away. You still can have prototypes. Classes, as it turns out, are just a way of writing constructors, a feature which prototype-languages typically lack. I think some definitions of "object-oriented" are limited due to the nature of popular OO languages. I haven't used JavaScript directly, but I have used a prototypical language. The prototype is really just a delegate, which from a certain perspective is all that inheritance is, except that delegation is a run-time association between objects, while inheritance is compile time, therefore delegation is more flexible. Polymorphism can exist without inheritance. As a matter of fact, delegation promotes composition, which in turn promotes polymorphism. -- GregVaughn I haven't tried this in JavaScript, but if it's truly Self-like, then you don't need to do name-mangling to accomplish inheritance. Instead, you adopt a Smalltalk-style metastructure as a matter of convention, including a process and method execution model. Then, by convention, every "prototype" delegates every method to its "class", which looks in its metaclass to see how to interpret it. Since delegation *is* inheritance, you'll get what you want. JavaScript supports true LexicalClosure''''''s via function literals. A closure (also known as LambdaExpression''''''s after LISP - where they probably originated) is simply an anonymous sub-routine that closes over the namespace of lexical variables within the scope of the block that defines the function body. For some interesting use of closure-like behavior for JavaScript event callbacks, see BeyondJS [http://w3future.com/html/stories/callbacks.xml]. JavaScript is an interesting language. Arrays, objects, maps (AssociativeArray) are all unified. Members seem to be rather like slots in the SelfLanguage. The way objects can inherit from one another is very dynamic. I think you could do quite a slick UI framework for JavaScript. ''Yes, you could, and you might end up with something like MozillaXul.'' MicroSoft are working on adding StaticTypeSafety support: http://msdn.microsoft.com/workshop/languages/clinic/scripting07142000.asp '''Testimonials''' My friend NickSimons has got surprisingly passionate in favour of JavaScript as a pretty good object language in recent months. -- RichardDrake '''Cross-platform compatibility''' The AchillesHeel of JavaScript is its inconsistent behavior across the various platform/browser combinations. As a result, it is virtually impossible to use it to do anything robust on the client side. -- TomStambaugh Yes, a big problem with writing JavaScript for the browser is the inconsistencies of its implementation across the various browsers. Take a look at my JsUnit. It's a unit testing framework for running JavaScript UnitTest''''''s inside the target browser. A nice side-effect of this is that you could run your tests in your target browsers. -- EdwardHieatt Sorry, I can't agree at all. Ok, due to differences between the Explorer and Netscape versions there is some confusion. But I always try to write in unicode: one single version of a homepage for both. Period. Try looking at my page on French verbs conjugations - http://verbes.eduinfo.com -- PieterJansegers I disagree with the points about inconsistencies in implementation. If you say that about JavaScript then you must say the same thing about HTML. Netscape provides very good documentation on its DevEdge website and if you follow their guidelines then you will be able to write script that works in version 3 & 4 browsers (JavaScript 1.2) and version 5 browsers (JavaScript 1.5) with very very few problems. The inconsistency problem manifests itself significantly in implementation of DHTML and DOM - particularly in version 4 browsers - but this can be overcome by writing an abstract API that either uses switching or the BridgePattern. JavaScript is actually a lot more flexible than is commonly believed. -- WalterRumsby It is quite possible to write compatible code as long as you do not use the DocumentObjectModel (which is not part of the language definition anyway). Take a look at my JsUnit, which is available for a big number of environments as long as their engine is based on the ECMA standard. -- Jörg Schaible In short, JavaScript suffers from a TightlyCoupledReputation problem (JavaScriptSucksInBrowsers). '''JavaScript and Wiki''' Is there some JavaScriptEnabledWiki? -- FridemarPache Yes, check out Jeremy Ruston's TiddlyWiki (http://www.tiddlywiki.com/) - the original is stand-alone HTML with all logic implemented in JS. There're now several spin-offs using PHP/MySQL... -- KarstenSchmidt Does anyone knows of any library (or way) that allows to write JavaScript CGIs? I'm planning on writing a WikiWikiWeb in JavaScript, I've found a really neat interpreter/byte-code compiler and it's a great way to learn the programming language (not the DOM/browser stuff)... Thanks! -- DavidDeLis I may have misunderstood the question here, but if you use ASP you can use JScript to write server side code. -- TobinHarris ''No, I meant JavaScript as an application building language, like C++ or Java, not as server-side stuff. I've written a small CGI library that allows me to access the query_string variables, but it's pretty weak, I'd prefer to work with one already done. Anyway...'' -- DavidDeLis * The SpiderMonkey project generates a standalone executable as a reference implementation. I am interested in using JavaScript and Wiki as a way of building a FilesystemBasedWiki or a WikiForLiterateProgramming. -- AndyGlew '''Future''' Have you looked at the proposal of JavaScript 2.0? The ECMA TC39 group is working with the proposed draft at http://www.mozilla.org/js/language/js20/index.html .#23You can find a lot of resources on JavaScript on the Mozilla project page http://www.mozilla.org/js/language/ as well... Two compilers that translate JavaScript 2.0 to JavaScript 1.X are Jangaroo (http://www.jangaroo.net/) and Mascara (http://ecmascript4.com/). ---- Don't forget the Netscape JavaScript console - type javascript: into the URL field - better than dosument.write or alert() for tracing variables, etc. -- DaveEveritt ---- If used appropriately, JavaScript is an easy and effective tool for creating dynamic Web-based interfaces for proprietary Intranet applications. ''As long as you have some form of defence against CrossSiteScriptingExposure, attacks from people outside who know what you're using inside.'' ---- I only found out about Wiki yesterday, but I have been using a guestbook which stores the updates in JavaScript function calls. My Web pages include these and I provide the code to be called. This makes JavaScript really useful, as you can update the data on a page. Have a look at http://www.btinternet.com/~doug.h.rice/gbbook (broken link: unhosted) and http://www.dougrice.plus.com/gbbook/. I hoped that BTOpenworld would provide the guestbook script that saves JavaScript Function Calls along side their normal guestbook script, but I need help in working out how it would make them money. It allows me to knock together simple applications quickly, and avoid a lot of the complications of server side programming. From my limited knowledge of the PHP/MySQL solution, your database query gives you an array of the data from the database search. My idea gives you an array of data, it's just all the data that the guestbook users post in the order that they post the data. It is similar to Wiki. -- DougRice ---- A nice feature of JavaScript is its treatment of functions as first class objects, which allows Closures and HigherOrderFunction''''''s. ---- '''For more information on JavaScript see:''' * http://en.wikipedia.org/w/wiki.phtml?search=JavaScript * http://c2.com/cgi/wiki?search=JavaScript ---- '''Some JavaScript Tutorials''' * http://www.afterhoursprogramming.com/tutorial/JavaScript/Introduction/ * http://www.geocities.com/binnyva/code/javascript/basic_tutorial/index.html * http://www.geocities.com/SiliconValley/Station/4320/ * http://www.yourhtmlsource.com/javascript/basicjavascript.html * http://hologuides.com/JavaScript/ * http://eloquentjavascript.net/ ---- '''Presentation''' JavaScript is a ScriptingLanguage. See the definition at: http://en.wikipedia.org/w/wiki.phtml?search=scripting+language JavaScript enables you to write fixed menus easily and quickly--pull-down menus, windows, menus for the right click of the mouse and other things (given the right environment). A non-programmer thinks, "For those who can't put together 3 lines of code in any language, javascript is god-send!" It's actually a product of Netscape and subsequent contributors and is JustAnotherProgrammingLanguage, though one shaped by its birth within the framework of a WebBrowser. ---- Paste the following as js.html in a local text file and open in your browser you can edit and run simple JavaScript code in the text field without refreshing (the button calls the eval() function). A simple ide for learning.