JavaScript Inventor Speaks Out
Anonymous Coward writes "Brendan, on his mozillazine blog talks about JavaScript 1, 2, and in between in light of DHTML and AJAX. In an informal blog entry he answers frequently asked questions such as fixing Unicode in regular expressions, multi-threading, weak numeric typing, and obfuscating code."
The difference between the Javascript language and the browser objects themselves has become more and more clear to me as I've worked heavily with both more complex Javascript like AJAX (where you aren't spending much time directly interacting with browser objects, but rather staying "inside" Javascript), working with JScript.NET for commandline programs, JScript in WSH and HTA as well as Photoshop scripting.
.NET assemblies etc.)
Many of the things that bother me about "Javascript" turn out to be problems with IE or Mozilla's objects and not the language itself. Don't get me wrong, things like the Javascript date objects still bug me, but I'm growing to like the language itself much more than I used to.
If you've only ever used Javascript in a browser, you may not realize that much of what you're working with is really the browser's object model. All of the window., document., document.form, etc. interaction form.submit(), etc. are all browser object properties and methods.
I noticed before posting some questions about scripting outside the browser. In those environments, you just get a different set of objects instead of document.form, you get objects for the filesystem or an active image, just like in any other programming language that uses objects from outside (COM objects,
The Glass is Too Big: My Take on Things
Try this site to see what I mean.
http://www.masswerk.at/jsuix/
As already mentioned Acrobat 7 Forms is driven by Javascript. Also apparently Illustrator has Javascript support, which is no surprise because many of the Illustrator team also worked on Adobe's SVG plugin. Overall it makes sense: throw in a Javascript interpreter, break down your document (pdf, picture, movie, etc) into XML objects (DOM), and let users write Javascript to manipulate the document. The biggest deal is to make sure users don't manipulate objects in unintended ways.
Maybe because we actually know what we are talking about.
Brendan Eich worked at Netscape back when the web was pioneered.. he created Javascript while there, and wrote the entire javascript engine for the Netscape browser (version 2 or 3, can't remember).. facts are facts.. I'm sure theres more info at wikipedia.
That's not a feature, it's a bug. It's not FF, it's the w3c. And it's the right decision. Standards and all that, right?
The document object already has a shitload of properties, and this IE idea doesn't cooperate nicely, since the property namespace clobbers the id namespace. Bad browser-maker! No cookie!
It's ECMAscript. Name hasn't caught on yet. ECMA = European Computer Manufacturer's Association, I do believe. Mozilla used to have some bugs where you couldn't use that as the attribute value for a "script" element. Or maybe that was with SVG.
It's also responsible for Google Maps. That's the only big one that jumps out at me, but there are a few other uses I've seen, that I've liked. Try out greasemonkey, and make javascript work for you.
Thinking more about it, what you may want is an implementation of E4X, which looks cool. I think it's going into newer mozilla-based browsers soon.
It lets you address a parsed XML file in XPath-ish terms, like rootelement.child.text and such.
Javascript is a scripting language that can be plugged into anything that has a script host for it. Dont confuse javascript with the DHTML DOM. Plenty of javascript code is perfectly valid and does not run inside a browser:
- Windows Scripting Host allows you to write shell scripts in many languages (Javascript, Perl, VBScript) You can install new script engines and it will host those languages as well. WSH gives you a object model to access the disk and other windows components. (COM, ActiveX, etc).
- Classic ASP used the Windows Script Host javascript engine so that js can be the language for ASP. (instead of the default of vbscript). Again, you could use any language that a script engine was installed for, including PERL. (see ActivePerl).
- I also believe some cgi scripts can be written in javascript.
Just because you aren't accessing the DHTML DOM objects (document, location, windows, etc) doesn't mean you aren't coding javascript!
-David
When an application uses javascript for the scripting language, does that mean a javascript parser is also implemented into the application? Or can javascript be used in a standalone environment?
A javascript parser is included in the application. The opensource ultima online server UOX3 used SpiderMonkey (Mozilla's javascript engine) to handle server-side scripting.
It's actually not that difficult to link spidermonkey into your application. I did it once for a benchmark program (it would pull a web page, and parse the javascript banners etc and time how long it took to download every piece of data required to render the page).
You can't run a javascript script from the command line. You can't click on an icon to run a javascript program
I guess you haven't run Windows in quite a while, because all of this works as expected. (The console command is cscript myscript.js)
Whenever I hear the word 'Innovation', I reach for my pistol.
As well as GMail, the new Google Custom Frontpage (You know you can drag those boxes around?), and hmm.. well, just disable JS in your browser and see how many websites still function. It's ubiquity is why popups exist, as the GP pointed out, but the reason popup blocking software exists is because simply turning off JS would "break the internet," in the eyes of most users.
https://www.eff.org/https-everywhere
You can be standards compliant and still use target with XHTML strict. One of the bigs things about XHTML is that it is modularized and target was just moved to a module which you can import in your documents:m l-target-1.mod
http://www.w3.org/TR/xhtml-modularization/DTD/xht
Using JavaScript for this, which people can disable or just selectively cripple, is a terrible idea and you start getting all these non-standard handlers spread around.
It was Netscape 3. Netscape 2 didn't have Javascript support. I remember, because I have an old 68K PowerBook with a copy of Netscape 2.
Removing all unneccesary whitespace and replacing var and function names with 1 or 2 letter replacements is also a means of compression.
Open source languages are not designed to only be used on open source projects, restricting what it can be used for goes against the whole point.
Besides, nobody has a problem with GCC producing output without embedded data to make it reversable.
You also have stuff like Rhino that makes Javascript a _compiled_ language. You also have a .NET Jscript compiler. So, Javascript _can_ be a compiled language.