Mozilla Extending Javascript? 286
Nomad128 writes "Mozilla's Deer Park 1 Alpha RC appears to have extended the Javascript spec for the first time in quite some time. New features include Array object methods "every" (logical AND), "some" (logical OR), "map" (function mapping), and "forEach" (iteration). They also appear to have added native XML support. Will this speed up the development of AJAX applications and give Moz a leg-up over IE7?"
Javascript Extensions (Score:5, Insightful)
On the other hand, it looks like the things that they did add were mostly based on standards and the DOM spec, so we'll see where this goes.
Re:Javascript Extensions (Score:5, Informative)
Re:Javascript Extensions (Score:2)
Of course, who wouldn't want their web page to be Mozilla-only? I think I am going to rewrite my webpage with these extenstions in mind. Fuck off and die, IE.
Re:Javascript Extensions (Score:3, Insightful)
Re:Javascript Extensions (Score:3, Funny)
Or a web developer... or a network administrator... or an accountant... or a construction worker... or a dentist... or a single mom... or a student... or a man... or a woman... or a child... or...
Re:Javascript Extensions (Score:5, Insightful)
They shouldnt be used where they impact on cross browser compatibility though.
Re:Javascript Extensions (Score:5, Funny)
Was it just me or did anyone else finish that sentence with, "our javascript overlords" or some other such permutation?
I might watch too much of The Simpsons.
Re:Javascript Extensions (Score:3, Funny)
Re:Javascript Extensions (Score:4, Insightful)
Given that the joke was only used on the simpsons once, I think the more reasonable explanation is that you read too much slashdot!
Re:Javascript Extensions (Score:2, Redundant)
Re:Javascript Extensions (Score:3, Interesting)
This mainly depends whatever any other browser picks it up. Compare this with last stor
Re:Javascript Extensions (Score:5, Informative)
A conforming implementation of ECMAScript is permitted to provide additional types, values, objects,
properties, and functions beyond those described in this specification. In particular, a conforming
implementation of ECMAScript is permitted to provide properties not described in this specification, and
values for those properties, for objects that are described in this specification.
Re:Javascript Extensions (Score:2)
Re:Javascript Extensions (Score:3, Insightful)
Unfortunately, it will be a cold day in hell when IE has decent support for the standards -- and add an aeon or two until older versions of IE are phased out.
This said, I'm not a web developer myself -- but when I updated our company's website recently, I would have spent around 10% of the time I needed. Coding around all quirks in different browsers is NOT FUN.
Re:Javascript Extensions (Score:3, Interesting)
one can replace any functions that are missing or don't work how you like them.
I remember back in the days before getElementById in I.E. I added my own so that I could write my code assuming it was present
document.getElementById = function (id) {
as you go along you find out what works what doesn't.
It's not *that* different from developing wxWindows or gtk to work
Re:Javascript Extensions (Score:2)
Mozilla, Opera and Internet Explorer all implement Javascript remarkably well.
(As a C/C++ developer) would you call differences/bugs in some "commonly expected to be present" 3rd party library a problem with the C/C++ language?
Re:Javascript Extensions (Score:4, Insightful)
It's exactly why the metric system is so much better than the imperial one: instead of land miles, sea miles, survey miles, international miles, furlongs, leagues, feet, etc, you have just a single unit. Even Americans can't stick to a single mile (they have like 3 or 4) -- and this is what makes miles something really repulsive to me. Similarily with web standards: if you need to write everything separately for every possible browser and its version, everything becomes a hell -- no matter if the browsers come from the Bad or the Good side.
Re:Javascript Extensions (Score:2)
I'm an American, and I'm quite sure that we have exactly one mile, of 5,280 feet, called the statute mile.
Mariners use for navigation a nautical mile, which is roughly 6076.115 feet. Its length is set by the diameter of the earth. One nautical mile along the equator equals one minute East or West of Greenwich. The nautical mile was dreamed up by the British. Unless you are navigating a boat, you don't need to know any of this.
Re:Javascript Extensions (Score:5, Informative)
The following mimics the forEach extension - and works in Mozilla, Opera and IE
Array.prototype.forEach = function(fn) {
for(var i =0; i this.length; ++i) {
fn(this[i], i, this);
}
}
function foo(obj, index, array) {
alert("index " + index + " is " + obj);
}
[4,5,6].forEach(foo);
(Only had a quick look at the Mozilla article and 5 mins knocking the source up, so excuse any silly errors)
Re:Javascript Extensions (Score:5, Informative)
Array.prototype.map = function(fn, array) {
var thisObject = array == undefined ? this : array;
var result = [];
for(var i =0; i thisObject.length; ++i) {
result.push(fn(thisObject[i]));
}
return result;
}
function makeUpperCase(obj) {
return obj.toUpperCase();
}
strings = [ "hello", "Array", "WORLD" ];
uppers = strings.map(makeUpperCase);
alert(uppers);
alert(strings);
Re:Javascript Extensions (Score:2)
Re:Javascript Extensions (Score:2)
Re:Javascript Extensions (Score:2)
Strings call chain is "String prototype object" --> "Object prototype object"
But anything with a call chain ending in the Array prototype object would be affected.
Re:Javascript Extensions (Score:2)
All Javascript objects contain a property "prototype" that references another object. When you invoke a method on a object, the prototype property chain is searched for a matching definition.
When a JavaScript String is created, its "prototype" property references the "String-Prototype object".
Th
Re:Javascript Extensions (Score:2)
(Mozilla extension) forEach
(Mozilla extension) map
Belong within ArrayPrototypeObject, not StringPrototypeObject.
Obviously.
What? (Score:3, Insightful)
Re:What? (Score:2, Interesting)
Would I use this for a site that outsiders would ever access? No.
Re:What? (Score:2)
Does it need to be used in any other places to have been worthwhile, from the Moz people's perspective?
Moz Extensions (Score:5, Interesting)
Make way for the "butt-heads" (Score:2, Interesting)
Which means more special-case code for web developers.
Re:Make way for the "butt-heads" (Score:2)
The question springs to mind...
"Why?"
One of the big features MS are pimping for IE 7 is standards compliance - I'd be surprised if everything works perfectly, and they'll still be all the other versions to deal with, but I really don't see why they'd delibrately run in and implement what is essentially a few simple methods, and an implementation of a W3C spec.
I have to say, I'm more interested in implementation of some CSS3 attributes, and the <canvas> tag.
HaHaHa (Score:2)
But I do not mind that because otherwise we would not have font, css and many of the other things people take for granted in html.
Re:Moz Extensions (Score:2)
Damned straight. I'm no Microsoft apologist, but they clearly document which DOM functions are W3C and which are proprietary.
I have a book which is five years old from MS Press which documents each and every object, collection, property and method -- and the standard they belong to -- in IE4/5.
I have DHTML which I wrote for IE4 which still runs perfectly on FireFox.
For that matter, making a LOT of my code work with modern bro
Re:Moz Extensions (Score:2)
It will if they don't deprecate the tabular data control. Did you RTFS?
Funny... I thought ECMAScript was an open standard (Score:2, Insightful)
Mind you, we are talking about the people who brought you the BLINK tag.
Re:Funny... I thought ECMAScript was an open stand (Score:4, Interesting)
Re:Funny... I thought ECMAScript was an open stand (Score:2, Insightful)
Funny... that exact same argument didn't work for Microsoft with their extensions to Java... why should we let Mozilla get away with it?
Re:Funny... I thought ECMAScript was an open stand (Score:2)
Funny... that exact same argument didn't work for Microsoft with their extensions to Java... why should we let Mozilla get away with it?
If you don't want to use the new functions, don't. A bit of javascript that renders in IE doesn't magically not work in Mozilla because of these new functions. Effectively, they're adding a few new functions to their standard implementation - they're not changing the way pre-existing functions work (like MS did with Java).
Re:Funny... I thought ECMAScript was an open stand (Score:3, Insightful)
I don't care about the case; I care about the arguments that nearly everyone on Slashdot made at the time as to why Microsoft were in the wrong - namely that they w
Re:Funny... I thought ECMAScript was an open stand (Score:2, Insightful)
Compare the amount of IE written in Java to the amount of Mozilla written in Javascript. Compare the advantages of having a Windows-specific Java program to a 100% portable Java program. Compare the active progress of the Java standard under its developer vs. the stagnant progress of the Javascript standard, and ask yourself which language needed outside help more.
Looks like hypocracy on the surface, but if you dissect the issue mos
Re:Funny... I thought ECMAScript was an open stand (Score:3, Insightful)
When Microsoft subverts open standards in an embrace and extend manner, it's evil.
When Mozilla (or anyone else does it), it's great! It's good! It's expected! It's the way innovation goes forward!
You are not arguing with any kind of logic. I still don't understand why comments like this get modded up. Sigh. So let me break this down real slow for you.
The problem with MS's Java extensions wasn't that they added extra functionality to the language or the VM. The problem was that they did so in
Re:Funny... I thought ECMAScript was an open stand (Score:2)
It's really a semantic argument I guess. In the confines of the term "embrace and extend", extending is something bad. While writing "extensions" to software, or suggesting "extensions" to a standard is something that happens all the time.
Standards aren't codified to stop all development and make things boring. They're written so that there's one place and system
"Nearly everyone on Slashdot" (Score:2)
I care about the arguments that nearly everyone on Slashdot made at the time
I don't know why this is so hard to understand: Slashdot has around 800,000 registered users. A typical Slashdot story will have around 500 comments from perhaps 200 or 300 different registered users, i.e. around 0.03% of all.
Let this sink in: the set of people commenting on a story will be a highly selected sample of those who care about that particular subject, and it won't necessarily be representative of Slashdot readers
Re:"Nearly everyone on Slashdot" (Score:2)
Let this sink in: the set of people commenting on a story will be a highly selected sample of those who care about that particular subject, and it won't necessarily be representative of Slashdot readership.
And yet you always seem to see the same opinions expressed and modded up to +
Re:"Nearly everyone on Slashdot" (Score:2)
And yet you always seem to see the same opinions expressed and modded up to +4 or +5, time and time again. That takes not only the posters, but the moderators too.
Moderators for a story will be self-selected in much the same way as the posters.
It really does get hard to shake the feeling that while the readers of slashdot have a wide variety of opinions, the Slashdot Readership is pretty much agreed on most topics.
People usually get that feeling in most cases where you've got a vocal minority and
Re:Funny... I thought ECMAScript was an open stand (Score:2)
Re:Funny... I thought ECMAScript was an open stand (Score:2, Informative)
For the record, the new methods are NOT ECMA standards, according to the Array object reference [mozilla.org]. In other words, developers relying on these methods will be locking themselves into Gecko, unless other vendors scramble to support them, which they will likely do in buggy and incomplete ways--which, incidentally, is exactly what standards (like ECMAScript) were s
Re:Funny... I thought ECMAScript was an open stand (Score:2, Insightful)
This specification has been around since June 2004, look it up on http://www.ecma-international.org/ [ecma-international.org]
Dark Peer? (Score:2, Funny)
Oh well, time to RTFA.
Article badly termed? (Score:5, Interesting)
Re:Article badly termed? (Score:5, Funny)
Re:Article badly termed? (Score:2)
Re:Article badly termed? (Score:2)
This is veering off topic, but what the heck.
<Stewey from Family Guy>
"It's not that I want to kill her... I just want her not to be alive anymore.
</Stewey from Family Guy>
Re:Article badly termed? (Score:3, Informative)
The point is that Mozilla is simply adding a few new functions. They've also documented the functions and released them in such a way that copying them exactly woul take no real effort. Hell, you can add the same functionality to your pages, in a completely cross platform manner by including:
Array.prototype.forEach = function(fn) {
for(var i =0; i this.length; ++i) {
fn(this[i], i, this);
}
}
function foo(obj, index, array) {
alert("index " + index + " is " + obj);
}
[4,5,6].forEach(foo
Re:Slashdot post badly termed? (Score:3, Informative)
By analogy, the C++ language has changed once since 1997 (with the technical corrigendum that fixed a couple relatively minor issues).
However, it was only fairly recently that there has been a compiler and library that has implemented the standard apparently correctly.
This does not mean that when a compiler writer adds support for the hell that is 'export' he or she is extending the language. By contrast, the only thin
Kettle meets Pot (Score:4, Insightful)
So, people used to get pissed off about Microsoft playing around with scripting features in IE that weren't available on other platforms, but now it's going to be an *advantage* for Mozilla?
Hello-o-oo-oooo-o-ooooo...
Re:Kettle meets Pot (Score:2)
Do you really not see the difference?
You'd really have to be completely stupid to use JavaScript in a web page that only works in one browser, even if that browser has a 90% market share. You'd have to even more stupid to use JavaScript in a web page that only works in a browser with less than 10% market share.
I really don't think these "extensions" are intended to be used in web pages. I'm also pretty dubious of your (unintended?) implication that the folks at Mozilla are doing things to lure deve
On the road to Mozilla 2.0 (Score:2, Insightful)
Wow (Score:2)
Or, heaven forbid, they'll actually use the actual standards based (and *GASP* Microsoft sponsored) ECMAScript as a base which had already fixed their embarassingly humerous (for a 1995 language) Y2K bug...
Re:Wow (Score:2)
what about the few of us stuck in no-mans land? (Score:2, Funny)
Ok, I am whining again, but you would whine too if you had
Re:what about the few of us stuck in no-mans land? (Score:3, Informative)
Re:what about the few of us stuck in no-mans land? (Score:5, Insightful)
I don't think you have any idea what you're talking about. These extensions to JavaScript will make the language easier to program in, which will be nice for the parts of Mozilla that are written in JavaScript (quite a bit, actually) and for things like Firefox extensions. It doesn't sound like they'll provide any undesirable functionality - we're not talking about floating popup windows here.
Why can't anyone write something to block all of this stuff out, I don't want to see graphics, or animations, or hear sounds,
That's precisely what several Firefox extensions do, and these additions to JavaScript will make extensions like that easier to write and maintain (and probably faster to use and smaller to download).
I love Opera, and it is my browser of choice but I still have to deal with unwanted flash animations.
Well, maybe you should switch to Firefox with the FlashBlock extension [mozdev.org]. Or if you really never want to see Flash animations, you could always uninstall the Flash plugin...
Re:what about the few of us stuck in no-mans land? (Score:2)
Satelite internet could be an alternative but that's only marginally better if you're expecting the responsiveness and throughput of DSL/Cable etc. Typical satellite instalations are latent anywhere between 800ms~1200ms. I've seen a couple under 600ms regularly but these were rare. Not to mention 500kbps is about as high as you can get with it.
Direcway [direcway.com] have been at it for a while, Starband [starband.com] Provides
Re:what about the few of us stuck in no-mans land? (Score:2)
P.S. If satellite is out of the question 2 and 3 phone line bonded dialup is also possible in windows and linux.
About standard compilance (Score:3, Interesting)
But that's not necessarly a bad think in my opinion. If one browser starts extending and empowering web developper in many and novel ways, this browser may well raise the bar for all browsers and shit expectation (if developper find, in mass, that the features are worthwhile, cool, useful, etc...).
However, deviance from standards are bad if they are unsignificant, unrevolutionary, unimportant, just a little improvement (not to confound with many little improvments that combined can make a big difference).
So if you're going to deviate from standard, do it big time!
The best part.. (Score:4, Interesting)
The other killer feature is, of course, SVG support by default -- unlike the crappy Adobe plugin, fast and reliable SVG support. A lot of stuff that is currently done in Flash can be done in SVG without any dependency on non-free software (or unstable, experimental open source players). Personally, I'm most excited about its possible uses in Wikipedia. Unlike a bitmap file, an SVG can be collaboratively edited: translate text, fix mistakes, and so on. Beyond illustrations, SVG is also useful for zoomable timelines [wikimedia.org], of which Wikipedia has quite a few, and which are already exported as SVG.
I think that Firefox support for SVG could be a major reason to switch from other browsers if we come up with cool SVG-based applications (not that we really need more reasons to switch!). One thing that would be neat is the ability to generally pan and zoom an SVG file even if there are no JavaScript controls for that, I haven't seen that functionality. Perhaps a bookmarklet or GreaseMonkey script could do the trick.
I can't wait for the final version, but I'd be happy to wait 3 months longer if that's how long it takes to get it ready for primetime. One thing is for sure: Firefox 1.1 will kick butt.
Re:The best part.. (Score:3, Informative)
I would like to add another use to the list, though. Having an SVG canvas to use for XUL apps will be a blast to play around with. As a weather nerd, I can't wait to create XUL web apps with a GIS backend that uses SVG to describe the map and weather data. Combining the XUL widgets with a vector based canvas area will be quite the combination.
That said, I believ
Re:The best part.. (Score:2)
Caching pages is a good use of RAM, if you've got it, not a waste. It's a killer feature precisely because UI responsiveness matters. A lot.
For years, in Opera, I've been able to use mouse-rockers to instantaneously switch back and forth between pages. In FireFox, doing the same thing is currently slug-slow and is a major reason why Opera is still my primary browser (the other reason being its quick full-page zoom with +/-).
Anyway, if you're stuck on a s
Re:The best part.. (Score:2)
Firefox has memory leaks. That is a fact and the developers know about it and are fixing it; slowly.
The hard part is finding test cases that exibit the problems without using most of the code base to render it.
The other hard part is that there are only so many programmers (working on mozilla) that know the intricacies of debugging Garbage-Collection memory management. It is quite complex, and time consumin
Array methods (Score:4, Insightful)
They'll just run a bit faster in Mozilla/FireFox, is all, since they'll be run as part of the interpreter rather than as interpreted code.
Most of the other stuff is based on W3C standards.
Short version: I'll continue to do cool stuff quickly in Moz and spend time writing workarounds for MSIE, just like I've been doing for the last 4-5 years. Nothing particularly new about that.
What the World Needs Here (Score:3, Insightful)
World Peace would be nice too.
Canvas in Firefox 1.1 Developer Preview Release (Score:2)
Is is basically a direct-mode graphics canvas, as specified by WhatWG canvas specification [whatwg.org], which allows you to draw all kinds of graphic primitives using Javascript. This is based on Apple's implemented in Safari.
I would hope that some highly innovative graphics-applications can become possible using Javascript, when this goes mainstream.
Re:Canvas in Firefox 1.1 Developer Preview Release (Score:2)
Does lines, circle, elipses...
Impressive, but tends to slow down your browser, somewhat.
You know the answer (Score:2, Insightful)
Are web designers going to use it = no since they like "write once, run everywhere"
Will extension developers use it = yes
Will anybody remember the person responsible for Javascript in the first place?
Well, see for yourself, a document that he maintains Roadmap [mozilla.org]
Javascript - blech (Score:2)
Re:Javascript - blech (Score:2)
I wonder how much trouble it would be to embed a restricted Python in Mozilla...I should probabl
Re:Javascript - blech (Score:2)
Really, I just want decent OO.
Native XML is a very neat feature (Score:4, Interesting)
var html = <hmtl/>
html.head.title = "my title";
print(html);
This prints as:
<html>
<head>
<title>my title<title>
<head>
<html>
Although this is a contrived example, I find the ability to access XML as native objects using dot-notation to be very convenient and useful.
All this nice new stuff... (Score:2)
More links (Score:4, Informative)
The article has links to New Web Developer Features [mozilla.org] and New Extension Developer Features [mozilla.org]. There's also a page listing New Browser Features [mozilla.org] and an unofficial page listing Notable bug fixes [squarefree.com].
Restrict extensions to extensions (Score:2, Interesting)
Mozilla and Cairo (Score:3, Interesting)
Check out the blog of the main developer thats doing this development. Hes got some excellent demo screenshots.
http://weblogs.mozillazine.org/roc/ [mozillazine.org]
who browses with javascript activated, anyhow? (Score:2)
I usually do not, since I don't want silly animations chewing up cycles, or annoying floating thingees obscuring content.
Sure, it's annoying to have to click through menus to turn javascript or java back on for those few pages where I need it, but that's less annoying than having it turned on by default.
Re:who browses with javascript activated, anyhow? (Score:2)
Wow. Somebody ought to write an extension for THAT.
Make out of standard obvious... (Score:3, Insightful)
ie it should be very recognisable that you are using something that is not part of the ECMA standard.
In Java land, that's made somewhat obvious by the import statement - the namespace for standard is java/javax, and, eg com.* or org.* etc are for everything else.
Actually the same should be the case for HTML etc.It should be obvious when there are tags/features being used outside of the standard just by looking.
The best way to let people code to standards is making it easy as hell to tell what is standard or not - without reading a gazillion pages of specs that they may not even understand.
ws
Standards? (Score:3, Interesting)
What happens if the company wants to scale up later to allow clients to view or to incorporate this great new stuff on the/a public website. It just doesn't make much sense to me in the long run.
Am I missing something important here?
Deer Park (Score:2, Insightful)
Well, let's see. Netscape invented JavaScript, Microsoft did its best to break it. But, not without the help from the Mozilla Foundation, the proprietary plot has been demolished and by now everyone, except the most lazy and ignorant, seems to know that you can't trust Microsoft's innovations to lead you to the light.
But isn't it about the time to make another step forward? And who would YOU choose to bring you there? As for me - I, for one, welcome our
cursor (Score:2)
URI values on CSS cursor properties
On Windows, OS/2 and Linux (Gtk+ 2.x) one can now use an arbitrary image as the mouse cursor while a given DOM node is being hovered. Any image format supported by Gecko can be used for the image (SVG, animated GIF, and ANI cursors are not supported).
how about a native, non-blocking wait() (Score:2)
Re:Firefox "stuck" at 10% market share (Score:5, Funny)
Hmm..
Firefox for OS X (Score:2)
Re:Sounds familar... (Score:2, Insightful)
lmao
More to the point foreach is great
so instead of:
var y = x.childNodes;
for(var i=0; iy.length; i++){
do something with y[i]
}
i could just do
foreach(x.childnodes as y){
do something with y
}
So getting back to the point
Re:Sounds familar... (Score:2)
I love questions answer themselves.
Re:Sounds familar... (Score:2)
Your argument isn't very insightful if you haven't found that you can do for(i in varname[i]) to access in sequence all of the variables in arrays or even objects.
Re:Sounds familar... (Score:2)
Re:Avalon and XAML (Score:2)
Microsoft doesn't have any kind of idea or concept of Avalon and XAML replacing HTML. It's mean
Re:Avalon and XAML (Score:3, Informative)
For the love of god, NO!!! Do not rely on client-side scripting for input validation. If you insist on doing it, you still need to do it again on the server. Failure to do this properly opens your app to bad data and even (unnecessary) security risks. It's really not that hard to alter or fake a browser's POST data.
Hell, I'm guilty of doing this myself. When my domain registrar asked for data they didn't need, all it
Re:for each!!!!! (Score:2)
Re:for each!!!!! (Score:2)
If you want something similar to PHP's foreach, you can use for
As I've remarked in another post, implementing these methods in a cross-browser and forward-compatible fashion is not difficult if you know what you're doing: