JavaScript
last edited September 5, 2005 11:30:19 (216.183.152.17)
| |
|---|---|
| Edit / History / New / Search | Quick Links: Home / Recent Changes / Glossary / Jobs / Forums / Help |
|
CocoaGlossary:Languages
A scripting language used on web pages, and originally created by Netscape. JavaScript offers basic interaction, but no file system access. If you're interested in adding JavaScript capabilities to your applications, the Mozilla JavaScript engine is open-source - get it from http://www.mozilla.org/ Also check out Rhino from the same site ( http://www.mozilla.org/rhino ) which is a JavaScript implementation in Java, with a command line interface. It's bundled with JSC which is the JavaScript to Java byte-code compiler (do I have to point out how wildly cool this is?).
JavaScript for OSA adds the possibility of writing AppleScript in JavaScript (with the mozilla engine!), look for it here: http://www.latenightsw.com
JavaScript is an interesting language to program in; it is not object oriented in the same way as ObjC, C++ and Java is, where every class inherits form other classes in a tree-like structure. In JavaScript inheritance is created by something called prototypes. There are no real classes in JavaScript everything is objects, and new objects are made by calling a function that acts as a constructor (init in ObjC), the function itself is an object. Instance variables can be added on the fly, wherever, whenever, some examples:
JavaScript is really the coolest scripting language there is, I'd love to see a CLI version of it, with access to the filesystem and GUI-routines. Most people just thinks it's a C-style scripting language for the web, but it's not. There is actually a CLI version in Rhino, see above. [late edit] -- TheoHultberg RUMOR has it that Mac OS X 10.2 will be scriptable not just by AppleScript, but also via JavaScript !!! Your CLI wish just may come true sometime late this summer. :) Bummer that it didn't (current version is now 10.2.2 and no JavaScript)... Well, as posted above, it already is, just not made-by-apple (see www.latenightsw.com). It would be nicer if apple did it, since then it would be more integrated, now one needs JavaScript for OSA. AppleScript is far from the CLI, though. It would be cool to be able to make JavaScript-Cocoa-apps in AppleScriptStudio though.
Apple's recent contribution to the KDE kjs project (http://www.opensource.apple.com/projects/others/JavaScriptCore-0.2.tar.gz) is a nice sign.
Brendan Eich, the creator, talks about his creation and where it's heading: http://weblogs.mozillazine.org/roadmap/archives/008325.html -- Theo
Apple's JavaScript implementation includes a kind of bridge (similar in spirit to Cocoa-Java, AppleScript Studio, PyObjC et al.) between Objective-C objects and JavaScript. It can make Objective-C objects behave like JavaScript objects when used by JS code, and allows access to JS objects from the Objective-C side by using proxies and setValue:forKey: / valueForKey:. However, I don't know if it can handle some features that are usually essential for code to be completely useable to create a full Cocoa app (i.e. subclassing), although I'm surprised Apple didn't create an AppleScript Studio-like environment in Xcode for JS. See the plugin architecture for Dashboard for a demonstration of what JSCore? can do on the Objective-C side. -- l0ne aka EmanueleVulcano | |
| Edit / History / New / Search | Quick Links: Home / Recent Changes / Glossary / Jobs / Forums / Help |