


JavaScript Inventor Speaks Out 267
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."
It Would Be Nice... (Score:3, Interesting)
On a related note, I had an interview at Adobe a while back and the interviewer mentioned that javascript was the scripting language for a lot of their products. I drew a blank on that one since I had no idea how use javascript for an application (and, subsequently, didn't get the job). 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?
Re:It Would Be Nice... (Score:3, Interesting)
Re:It Would Be Nice... (Score:2)
Re:It Would Be Nice... (Score:2)
Re:It Would Be Nice... (Score:4, Informative)
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).
Re:It Would Be Nice... (Score:2)
I dont know how much its used. I havent really seen it used regularly anywhere. Some companies might use it internally.
Re:It Would Be Nice... (Score:2, Interesting)
Most open source scripting languages can access COM objects on Windows. Once the syntax issues are out of the way, most of them work the same way.
Re:It Would Be Nice... (Score:5, Informative)
- 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
Re:It Would Be Nice... (Score:3, Insightful)
Javascript is a language
The DHTML DOM (window, document, location, etc...) is merely an API. When you code in another environment, there is another API. For exemple, when ASP uses JScript (and not JavaScript, but it's pretty similar), APIs are such as ADODB, file system access, db access, etc...
Small correction (Score:2)
You should read:
that can be embedded in any solutions
JavaScript (Score:5, Interesting)
It's a pity JavaScript rarely gets the attention it deserves as a legitimate programming language. Most guides to C begin with teaching you how compilers work; most guides to JavaScript teach you how to swap some images.
This is unfortunate as it's quite powerful: it supports first-class functions and an excellent generic object-system, not to mention the usual suspects such as dynamic memory management.
Hopefully its apparent resurgence these days (as browser vendors get their compatibility acts together) will change this.
Re:JavaScript (Score:2, Insightful)
Re:JavaScript (Score:2)
Re:JavaScript (Score:4, Interesting)
It seems to work. There must be a few people out there who still respect copyright.
I even put a BSD license on one of my scripts, essentially making it public domain, and somebody asked for permission to copy it.
shameless plug [mytsoftware.com]
Re:JavaScript (Score:3, Interesting)
Heh - interesting, I've had similar experiences. I've written a few (very) small OpenSource games - nothing major, nothing well-known. I've distributed them very clearly under either GPL, BSD or even 'public domain' licenses.
Yet people seem to have always asked my permission before using the source for anything, however tiny and insignificant the use. Some guys also asked my permission once to do a fork.
In the beginning it seemed quite weird to me, now I'm kinda used to it.
So yes, people seem to gener
Re:JavaScript (Score:2)
Re:JavaScript (Score:2)
Re:JavaScript (Score:2)
JSUIX [masswerk.at]
Re:JavaScript (Score:2)
I've often thought of creating a lite version of Python or Prolog that have some built-in DOM access added and all their parts that pose security issues removed. In general I think that it's a shame that we're mostly limited to one or two languages of limited compatibility for client-side web scripting. At least we can write some of that stuff in the
Re:JavaScript (Score:3, Informative)
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)
Re:JavaScript (Score:3, Informative)
Ruby says that they can be real languages (Score:2)
That's actually quite easily doable (Score:2)
Not supported in MSIE, of course, unless you happen to be on their developer team. (-:
The difference between the language and... (Score:5, Informative)
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,
Re:The difference between the language and... (Score:5, Informative)
On Windows (if you have a workstation or server), however, you probably already have the WSH accessible containers and the cscript.exe and wscript.exe interpreters. Simply making a script.js file (remember you can't use any browser objects, so search for "Javascript WSH" to get some more info) and running "cscript.exe script.js" will run your script from the command prompt.
Beyond that, you can build WSC (Windows Scripting Components) that are Windows COM DLL's written in scripting languages. HTA's (HTML Applications) are HTML files outside the browser container. Just rename an HTML file to
If you're looking for more "real" applications, JScript is a full-fledged, if not well documented, language for
Re:The difference between the language and... (Score:5, Interesting)
FYI - Learning Java can also be worth your time; it's not so bad. But really, if you're going to have your application execute on the client in a browser, then Java really isn't a good choice these days. (Although I'm sure some would beg to differ; it is *possible* after all. I just don't recommend it.)
Have fun!
Re:The difference between the language and... (Score:2)
Re:The difference between the language and... (Score:2)
Except for DHTML/AJAX all the other options (including Java) require a browser plugin. Usually, you can't trust your client to have this plugin already (including Flash if you're using newish features), so you're stuck getting your clients on to that plugin before you can deploy anyway.
As far as Java being the only dec
Re:The difference between the language and... (Score:2)
Re:The difference between the language and... (Score:2, Funny)
I know that today is wednesday.
JS is very functional (Score:5, Informative)
http://www.masswerk.at/jsuix/ [masswerk.at]
Re:JS is very functional (Score:5, Interesting)
Re:JS is very functional (Score:2)
Re:JS is very functional (Score:2)
Re:JS is very functional (Score:4, Funny)
That has got to be the coolest thing since the invention of French kissing!
Re:JS is very functional (Score:2, Informative)
Re:JS is very functional (Score:2)
Not to mention the well-known Javascript Lemmings [193.151.73.87].
Re:JS is very functional (Score:4, Insightful)
And how many other languages do you use to write client-side code for web browsers? The problem is that the browsers don't all implement the same standards for their internal object models... but this is a result of using JavaScript to implement differing browser APIs, not a failure in JS itself. It's like saying that ANSI C is lousy because the same code for a graphical app will create errors if you compile it under Windows, Linux, and Mac. The language is fine it's just that those platforms, much like the browsers, implement different graphics APIs.
JavaScript Vrs. TCL (Score:2)
Re:JavaScript Vrs. TCL (Score:4, Interesting)
Re:JavaScript Vrs. TCL (Score:2)
Re:JavaScript Vrs. TCL (Score:2)
Javascript doesn't suck (Score:5, Interesting)
As someone who'd only used Javascript in creating DHTML, I'd worked up a good hate against it. But what I'd hated was really the ridiculously incompatible implementations of the DOM in IE/Netscape. I also hated the embedded space itself--shitty delivery method (encoded or called from HTML, no #include, no namespaces).
Then I started writing extensions for firefox. I'm trying to show my company that (firefox + xul + js) > (ie + activex). I'm mostly successful, since we already have lots of XML over HTTP data services primed for XmlHttpRequest.
But it turns out that the language doesn't suck so bad. Sure the namespace problem is JS's fault, but the rest is the embedding. Using JS for firefox exntensions allows you to code to one platform; make more OO libraries, etc. I even generate classes from the DTDs I make the XML services from.
Who would've thunk it's really a decent language in the dynamic, lambda-toting, functional-ish area?
Re:Javascript doesn't suck (Score:2)
Oh, yeah?
Re:Javascript doesn't suck (Score:5, Informative)
That's not a feature, it's a bug. It's not FF, it's the w3c [w3.org]. And it's the right decision. Standards and all that, right?
The document object already has a shitload [mozilla.org] of properties, and this IE idea doesn't cooperate nicely, since the property namespace clobbers the id namespace. Bad browser-maker! No cookie!
Re:Javascript doesn't suck (Score:2)
Re:Javascript doesn't suck (Score:2, Informative)
Thinking more about it, what you may want is an implementation of E4X [ecma-international.org], 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.
Re:Javascript doesn't suck (Score:2)
Re:Javascript doesn't suck (Score:2)
[Plus this code has a bug. If the element doesn't exist, you get different values (undefined or null) depending on the codepath.]
Re:Javascript doesn't suck (Score:2)
That's why we have this companion function:
function bad(n) { return n == undefined ? true : n == null ? true : false; }
Re:Javascript doesn't suck (Score:2)
Re:Javascript doesn't suck (Score:2)
Nesting ?: syntax makes baby Jesus cry.
Re:Javascript doesn't suck (Score:2)
Re:Javascript doesn't suck (Score:2)
Re:Javascript doesn't suck (Score:2)
z = function (k) { return k; }
z(x);
z(f);
z(f());
z(f()());
JS rocks (Score:4, Insightful)
Re:JS rocks (Score:2)
Re:JS rocks (Score:2)
Javascript has a number of nice features; I can forgive it a l
Re:JS rocks (Score:2)
I took your first example and wrote it how I would write it. Look at your code now: function Dimension(width, breadth, length){ this.width = width this.breadth = breadth this.length = length } a = new Dimension(1, 2, 3) alert(a.length)
Just like you have beautiful perl and python you can
Re:JS rocks (Score:2)
Actually, you missed the point on that example; I should have been clearer.
What I was complaining about was that array elements share namespace with array methods. Which means that once you assign array["length"] to something, array.length doesn't return what you think it does! You can't have an element called 'push' and have access to the Array.push() routine at the same time. This is mind-boggling brain-damaged.
You can also do crazy stuf
Re:JS rocks (Score:2)
Here's the design decision you hate: a JS object is a single-namespace collection of properties, each mapping a string to an arbitrary value. I made that decision quickly, but consci
JS book? (Score:2)
Re:JS book? (Score:2)
http://www.crockford.com/javascript/javascript.ht
Relief at last! (Score:5, Insightful)
"With DHTML and AJAX hot (or hot again; we've been here before, and I don't like either acronym)
Bingo!
The man's right on.
Don't evolve; stay a *standard* (Score:3, Interesting)
JS is not going away, so it ought to evolve. As with sharks (and relationships, see Annie Hall), a programming language is either moving forward, or it's dead.
No, when a programming language doesn't chance, it's called a standard. Look at what we've been able to do keeping html, css, and javascript a stable target for so many years! It's like Space Invaders on the Atari 2600 -- nobody who created that console, its hardware designed specifically for playing Combat and Video Olympics, expected someone to be able to slap six sprites in a row, much less have the player shoot then down one at a time. The 'standard' that was the 2600, however, gave a stable platform for programmers to learn tricks that would give the console life well beyond its creators' expectations.
We've got something like that with javascript, and we can see what happens when we compare to something like Visual Basic 6. Developers are still upset about Microsoft's decision to drop official support for VB6 in an attempt to force people to upgrade to VB.NET. Know what? Those upset programmers have found that VB6 hasn't rusted and simply continue using it to create their apps. There are more companies than you'd know (here's one [blackbaud.com]) whose major apps are/were written in VB6, the 'prototyping language'. They're not quite ready to cast the baby out with the bath.
Fix bigs in javascript? Absolutely. The issue is that we've reached a point where nearly every browser anyone uses supports a 'single' flavor of javascript and we're all familiar with how to make our code work with the few quirks that remain crossplatform. There is a standard on nearly every box on the net that coders can assume will be there for them. I wouldn't want to see anyone mess this stable delivery platform up, splitting the user base into something like what we had in the Netscape 4.x/Mozilla/IE 4 & 5 days. Now *that* was an ugly time to code.
The bottom line is that evolution is an overused metaphor. You've got two choices if you'd like to propagate your genes into the future: immortality or reproduction. Immortality was a little too difficult to accomplish for living, unique individuals. Perhaps there were little organisms that could live forever, but something squashed 'em. They're gone. That's not a problem in the digital world, folk. We can make as many exact copies of an individual as we'd like. Javascript modules are not unique. They don't need to evolve. (I mean, come on, he even mentions sharks, a design that hasn't changed in millions on millions of years!)
Javascript should shoot to become an immortal standard, not another field of play and debate.
Re:Don't evolve; stay a *standard* (Score:2)
My point was that JS ought to respond to feedback in its niches, not stay unchanged for years on end (as it has, apart from bug fixes). I agree it doesn't need six legs or two heads. But "evolve" -- as in "respond to feedback from users" -- means more than "bug fixing". See my roadmap blog for more on this.
Re:obfuscated code as a feature?!?! (Score:2)
You are pretty much on target with the rest of your thinking but that point is "off base". When painters hide the true meaning of a painting... well that is just damn cool!
Not to nitpick (I'm usually not a nitpicker)
And why not? (Score:5, Insightful)
Honestly. Why should you be able to? Amazon SELLS books. It's not an on-line library. That's not the service they are offering.
Re:And why not? (Score:2)
1. Let The Page Load
2. Turn off Javascript
3. Ctrl-A, right click, view selection source.
Works for every method i've seen of trying to hide HTML source. I wonder if the idiots buying it know how easily the "security" is broken.
Re:And why not? (Score:2)
It is "mostly harmless" that you want to circumvent a system that will let you look at a few pages before you buy? Why would you even want to do that? Are you dishonest? If you're not trying to scam a book, why would you care? Trying to justify bad behavior by saying that Amazon is trying "too hard" to protect their interests is no more than a scam to get someth
Re:And why not? (Score:2)
Re:And why not-free for me? (Score:2)
Re:And why not-free for me? (Score:2)
Give it up. I'm not biting.
Re:obfuscated code as a feature?!?! (Score:3, Insightful)
It's writing code and hoping nobody else can understand, modify, improve, or possibly circumvent it. To be perfectly honest, I don't think code should be more obfuscated than it already is. The simpler and easier to understand, the better
Re:obfuscated code as a feature?!?! (Score:2)
Re:obfuscated code as a feature?!?! (Score:2)
And using short variable names too, I guess?
With interpreted languages like JavaScript it does does cut down the parsing and processing time a fraction, so why not? Check out the compact code on Google's homepage, which is downloaded a gazillion times, and benefits from the size reduction.
Re:obfuscated code as a feature?!?! (Score:3, Insightful)
If Amazon didn't at least attempt to prevent you from accessing every page of each book, they'd be unable to offer the service at all as there's no way the publishers would agree to it. They'd essentially be providing a mechanism to get the text of the book for free.
If enough people piss about with it, Amazon *will* be forced to either withdraw the service, or just put up (say) five pages of each book and le
Re:Just what I wanted! (Score:5, Funny)
Yes, but this is a discussion about JavaScript, not Flash.
Re:Just what I wanted! (Score:2)
Flash is extremly picky about client side security, since it's the most widespread web/internet client plattform in existance and they don't want to lose that edge.
Good reasoning if you ask me.
Re:Just what I wanted! (Score:5, Insightful)
<a href="http://www.slashdot.org" onclick="window.open(this.href,'_blank');return false;">Slashdot</a>
So you can argue that XHTML blows, or that you shouldn't open links in a new window, but if you decide you want to be standards compliant, you are going to need some client script. This is not the only example.
-David
Re:Just what I wanted! (Score:3, Insightful)
Re:Just what I wanted! (Score:3, Insightful)
Re:Just what I wanted! (Score:3, Insightful)
You can do this with CSS, and without having to call back to the server for the "help" content as another web page
Define your help notes as divs which are hidden (display:none). Then you have your "help" hyperlinks point to those divs, which can then become visible (because they have the focus a
Re:Just what I wanted! (Score:2)
As for people with visual impariments, I'm not concerned with helping them view my sites. I guess that makes me a horrible person.
Re:Just what I wanted! (Score:2)
Re:Just what I wanted! (Score:2)
The user doesn't need any such scripting to open a new window, only control freak developers
Re:Just what I wanted! (Score:3, Informative)
http://www.w3.org/TR/xhtml-modularization/DTD/xhtm l-target-1.mod [w3.org]
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.
Re:Just what I wanted! (Score:2)
The "target" attribute is specifically for frames. However, if you want to use frames, then you should be using the Frameset [w3.org] DTD (where it is defined) and not the Strict [w3.org] one.
The "target" attribute's actually defined in XHTML 1.0 Transitional [w3.org], too, but the OP was talking about XHTML Strict.
Re:JavaSuck? (Score:2, Informative)
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.
Re:JavaSuck? (Score:2)
ASP isn't based on visual basic, ASP just means Active Server Pages.
It would be like saying that CGI is based on Perl.
Instead of environment variables, asp provides some COM objects : request, response, session & application.
The scripting language is up to you, you can use VBScript, Perl, Python, PHP, C and probably even Brainfuck !
wooof!
Re:JavaSuck? (Score:2)
I've been in unix land since pre win2k, last working on
the biggest drawback is the lack of native associative arrays
create a few more than 100 scripting dictionaries and you get "out of memory" [though I plucked 100 from mid air, I just ran out one time when using one of my php idioms creating an array of dictionaries inside a loop, didn't bother to work out the *actual* limits]
VBscript is one of the least expressive languages.
It is
They have. (Score:3, Informative)
Re:They have. (Score:2)
As for the AC comment - tiresome troll.
Re:They have. (Score:2)
Re:They have. (Score:2)
Re:I need to agree with fellow Slashdot participan (Score:5, Informative)
Re:I need to agree with fellow Slashdot participan (Score:3, Informative)
Re:Is it just me... (Score:3, Informative)
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.
Re:Misuse of operators (Score:2)
Re:Misuse of operators (Score:2)