nolo said:
In this very thread in fact.
If you are talking about "s0lnic" then you should note that he has
hardly made a dozen posts in the last 3 month and the only code he has
posted featured the usual cross-browser error and needed to be corrected
before it was fit for its proposed purpose.
I appreciate it.
Why has a library not been written this way?
In what way? Such that the code used conforms to language's
specification and does not rely on inconsistent implementation details?
Lots of libraries have been written in that way. For example I have not
yet noticed anything in dojo that relies upon language extensions or
non-standard implementation features. Granted the evidence that dojo's
authors don't understand the code they are writing suggests that that
is itself probably best attributed to coincidence, but still it is the
case.
Obviously it's not your responsibility to do it, or to even
know the reason why it hasn't been done thus far,
Except it has been done, and is probably the norm, even in otherwise
very dubious library code.
but if so many people are in error, and it causes you
any distress,
What makes you think it causes me any distress? I am massively cynical,
so a world where idleness, ignorance, ineptitude and incompetence are
endemic is reassuring (almost comforting).
it would behoove you to write one, or at
least begin one.
One what? A general-purpose library? Doesn't that imply a
presupposition that a general-purpose library would be
something that would be useful to have? If that a-priori
assumption is not itself valid then creating such an object
could be a bad idea and I could be entirely justified in
not spending my time pursuing folly.
Perhaps set up a project? Clearly you care a lot about
this subject, and have invested much time in it. This
is just another avenue by which you can participate in
-- and even shape -- the future of how javascript is used.
Why do I need another avenue to shape the future of how javascript is
used?
So this is the browser's problem.
No, it is the programmer's responsibility. The responsibility of the
browsers is no more than to correctly implement the standards that they
claim to implement. Whatever they do beyond that is up to them.
It does appear that web browsers being permissive leads to problems when
people try to learn programming entirely by trial and error in a
restricted set of browsers and then try to move on to cross-browser
scripting.
But if you think about it, if 90%
of people do something one way, and that way doesn't conform
to "the standard" (in this case, ECMA), doesn't the
way most people do it BECOME the standard?
But what then 'becomes the standard'? The code I highlighted is amenable
to three different interpretations in web browser environments, and
actually behaves radically differently in the two most popular browsers.
Is that either JavaScript's or JScript's interpretation that 'becomes
the standard', or do you mean that it becomes the standard to be writing
code that behaves differently in each and every browser it encounters?
We tried that and it did not work, which is why the standardisation of
the language (and the DOM) was started.
One of the main reasons that it is currently possible for the uses of
javascript to be taking the directions they are taking is that
ECMAScript has been stable since the turn of the century and so its
implementations have become very complete and stable.
It may be horrific in its
implementation, syntax, whatever, but so is HTTP.
What is wrong with HTTP? It does precisely what it was designed to do,
and does it very well. Of course you start to see issues as soon as you
attempt to use HTTP for something other than what it was designed for,
but that is hardly surprising or unusual.
So you either adapt
and use it, or try to make change.
Again, this may be the browser's fault then.
No, it is the programmer's fault.
Bear in mind that browser developers do have to cater to
existing web pages, and have all sorts of testing to try
to ensure that nothing breaks in future versions. I
highly doubt that just because a page doesn't conform to
ECMA standards, the browser developers will say "screw
that web page, if they don't follow ECMA they don't get
a proper rendering in our browser."
ECMAScript conformance has nothing what so ever to do with rendering.
Whether the Prototype.js code conforms to the ECMA standard or not was
not the issue. The issue is that the code does not actually do what its
author clearly thinks it does, and what it does do is not even the same
in the two most common browsers. Re-writing it as ECMA 262 conforming
code only acts to avoid that issue, as the code will then do the one
thing it is programmed to do, and do that same thing on (at absolute
minimum) all the browsers that Prototype.js is interested in.
It would also be possible to re-write the code so that it acted in a way
that made sense in terms of how it would be interpreted under
JavaScript(tm) and JScript, where you would short-circuit the
heavyweight - if - test on finding that the - each - function was
defined prior to the test (i.e. wherever the test was futile). The
result would not be any more cross-browser but at least it would show an
author actually programming the library instead of being at the mercy of
misconceptions and coincidence.
This may work if the percentage of "bad" web pages were
vanishingly small, but hey, this is the real world where people are
stupid and market share is of vital importance to a browser's
continued existence.
Market share has nothing to do with the existence or viability of web
browsers. Recently the growth area in web browsers has been browsers for
embedded devices (usually mobile phones), and that is simply because
that is virtually the only market where money is exchanged for web
browsers (even if indirectly). Unlike the desktop browser market where
if the user doesn't get the browser for free they go and get one form
someone else. The embedded browsers don't have much market share (yet),
but they do have the potential to fund their own development, return a
profit, and continue to exist for that reason.
I'm not saying I'm encouraging bad coding, or
stupidity, but I'm being a realist.
You are not being a realist. You are assuming that you have enough
information to make informed judgments about a subject while admitting
near total ignorance of the technologies involved. A realistic position
would be to recognise that you are probably not yet qualified to judge.
Once all market share is captured, THEN you can begin to
gradually enforce whichever standards are the best. But
until then, it's a free-for-all.
<snip>
No web project is ever created without it's having some purpose. That
is, there is always someone who wants something from it. That
'something' may be profit/turnover, publicity, goodwill, specific
functionality, etc. (or some combination of those sorts of things). The
'professional' web developer's responsibility should be to maximise the
project's ability to achieve that 'something'. That is not a
"free-for-all", it is a knowledge driven process with a context specific
pre-defined direction.
I truly do appreciate your perspective. I did a little
research on you, and you appear to be a very intelligent
individual, although (and I don't mean to be destructively
critical) a bit of an idealist/ purist--which the world
does need, but isn't the way the world works.
The way the world works at the moment has the demand for my (client-side
scripting) skills exceeding their supply. Which leaves me
(idealist/purist or not) selling in a seller's market and quite happy
with the outcome. And the direction javascript use has taken makes me
think that that situation is not going to change in the near future.
When my boss comes to me and says, "Can we do this thing ... ?" (as he
usually does at lest a couple of times a week) I can answer "yes", "yes,
but ..." or "no" and be pretty sure that when I say "yes" I can deliver,
when I say "yes, but ..." I am accurately enumerating the pertinent
caveats, and that when I say "no" he is not going to be able to find
anyone else who can deliver what I cannot. This while the vast bulk of
the 'competition' are operating at a level of knowledge and
understanding that is below those of the authors of the libraries that
they have learnt to be dependent upon. While the authors of those
libraries don't actually know enough to be programming with javascript.
Can you judge the 'harm'? A while ago I was directed to a web page where
a web developer was proudly explaining how he had used a particular
rapid development process/system to create an e-commerce site, and how
easy/profitable it had been for him. He was very satisfied with the
outcome, and though his clients were also very happy with the outcome.
However, when I viewed the site using IE 6 I found that the shopping
cart did not work at all, which is pretty fatal for an e-commerce site.
Looking at the source for the site it immediately became obvious that my
problem was because of the specific configuration of my IE 6, but
simultaneously I observed that the code would only 'work' with 3 or 4
'major' desktop browsers in their default configurations.
There is a lot of nonsense talked about 'target audiences' when trying
to justify only supporting limited sets of (default configurations of)
browsers. It is a notion that starts with odd assertion that there is a
strong relationship between groupings of individuals and the web
browsers they use such that a 'target audience' implies some specific
set of web browser will be used by that audience (as opposed to
admitting the reality where anyone could be using just about any
(non-archaic) browser at all and that it is only a trivial coincidence
that the majority of them will be using the 'most common' browsers). The
'target audience' excuse also suffers from web 'statistics' problem,
where HTTP is inherently resistant to accurate browser usage statistics
gathering and most statistics gathering techniques are incapable if
distinguishing 'minor' browsers from 'major' browsers.
On the other hand the notion of 'target audiences' did have something to
contribute to this particular project because the e-commerce site in
question was selling web icon imagery. That means that its 'target
audience' is web developers, web designers and people in related fields.
While generalisations about web browser usage are inherently problematic
it certainly is the case that this particular target audience is the
target audience that is _most_ likely to be using non-standard web
browsers and web browsers in non-default configurations (because they
are the single group of users most likely to know about a wide range of
browser, have attitudes towards the browsers they use, and be confident
about configuring those browsers in precisely the way that suites them).
This means that from the point of view of the e-commerce site's client
the web developer's 'decision' to create something that only worked with
default configurations of 3 or 4 browsers was potentially harmful. It
effectively throttled potential turnover at the design stage. Of course
they don't appreciate that as if they had been in a position to make
that sort of judgement they would not have needed to employ someone else
to create the site for them. So instead they employed a 'professional'
and trusted that they would not be screwed as a result.
(Remember that this e-commerce site could have been created such that it
could take money off anyone who's browser is capable of making HTTP(S)
connections, displaying HTML pages, showing images and submitting a from
in a POST request (which is pretty much every non-pure text web browser
that has ever existed).)
The ironic aspect of this is that a month or so after this site was
pointed out to me I was in the office on a Saturday afternoon knocking
up some web material for a sails presentation and my boss decided that
he wanted different/better icon graphics. He could not get (hold of) any
of our designers to come in and create the graphics and didn't think he
could afford to leave the task until Monday. So he went to Google,
credit card in hand, to find and purchase some off the shelf graphics.
The very fist site he hit was our e-commerce icon seller above. He liked
one of the sets of icons and so hit the shopping cart to purchase them,
and it did not work for him. It did not work for him because his IE is
not in its default configuration either, but his is not in its default
configuration because our technical department found out that he had let
some spyware get onto his laptop and so leaked a company e-mail address
book (meaning we all got spammed continuously for a couple of months).
So they have clamped down his browser security in the Internet zone and
arranged that he (and I) cannot re-set those settings. The practical
upshot was that my boss's money went to a different seller of web icons.
So given that the original web developer was proud of his creation, and
how easy and profitable it had been (for him), so much so that he
published a web page to boast about his triumph, do you think he
appreciated the harm his design decisions had done? I don't think so,
and if challenged I bet he would make a lot of noise about working in
the 'real world' and play down the impact of his design decisions on his
client's turnover as 'not statistically significant' (without daring to
ask their opinion on the subject).
Again, if they are so trivial, why wouldn't a "good" library
have been written?
For a start; a total disconnection of responsibilities. You just don't
need a 'library' to do trivial things.
But where is your statement of a valid justification for the creation of
a 'library' to start with? Without that we haven't even arrived at this
question.
Wouldn't evolution cause the "good" librarues to bubble up
and become the de facto standard? Wouldn't "bad libraries"
break in future revs, independent browsers, etc, and the "good
libraries" gain mind- and market-share with each manifestation
of the "bad libararies'" failure?
In a world where people don't see demonstrations of a library's author
not knowing the language well enough to actually be programming with it
as sufficient grounds to dismiss the use of that library out of hand it
is quite likely that manifestations of failure would go unnoticed (or be
disregarded).
Richard.