- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Javascript allows responsive web fronts.
etc, it ignores the linebreak. You could speed it up by making the ; required at all times.But then in the end you still have to submit or redirect and the responsiveness is negated somewhat.
So they invented XMLHTTPRequest.
Among the funny things on JS there is the reserved but unsupported class keyword, and a function keyword that doubles as, um, a class constructor.
Among the most annoying annoyances of JS/ECMA is the fact that linebreaks CAN be statement terminators, IN CERTAIN CONTEXT. This renders true multiline strings impossible, but if the interpreter detects continuation of the statement on the next line, eg. via
Admin
Which language would that be? Certainly not Java - Javascript has nothing to do with that apart from the name.
Lacks a proper concept? What's wrong with prototype-based OO, other than the fact that you're clearly not smart enough to understand it?
Like any language, then. Like using C to write desktop applications, PHP to write command-line utilities, Ruby to write web apps, and Perl to write anything apart from obfuscated one-liners.
Like 100% of all other programming languages? So what's different?
Worse, they might actually be forced to open their minds. OH NOES!!! We can't have that!
Admin
If you want a serious discussion about that topic, mind your tone.
Admin
The syntax doesn't come into it. For example, Dylan is a superset of Scheme while having the usual boring syntax.
http://www.crockford.com/javascript/little.html
It's better than most languages manage...
Admin
Your tone doesn't appear to be any different.
Sincerely,
Richard Nixon
Admin
Hmmm, first you say that JavaScript is "an extremely cheap clone of an already poor language", then you resort to bashing other peoples (not mine) replies to your post instead of contributing to any kind of useful discussion. I for one would be very interested to hear why you think that JavaScript is an extremely cheap clone of an already poor language, and what language you think that JavaScript is a clone of. Do YOU want a serious discussion? If so, go right ahead!
Admin
From a quick glance, the lambda calculus thingy seems to be the only extraordinary similarity between Lisp and JavaScript.
I doubt many programmers use that in it's full awfull power.
What's the use of a perfect formalized semantic when in real live there are several different javascript interpreters (aka "web browsers"), each behaving slightly different?
Admin
AFAIK there are hardly any problems with the language implementations themselves. What differs are the object models for the HTML documents and the browser environment.
Admin
I use both prototype-based OO and closures all the time. A handy example use of lambdas is to add a Ruby-style .each (and .collect, and .map...) method to arrays, so that you can do things like this, in place of for loops:
var total = 0;
[1,1,2,3,5,8].each(function(n){total += n;});
var squares = [1,11,134,156].map(function(n){ return n * n; });
In general, when you say, "It is the only extraordinary similarity," you are pointing out the similarity between all functional programming languages; and you seem to be saying that they are all equally useless to non-geniuses, which is not really true.
And, I won't comment on the usefulness or non-usefulness of 'formal' semantics, but I have yet to see any particular point on which the Internet Explorer or Mozilla implementations stray from the ECMAScript specification. If you are referring to the DOM as the differing behavior, that's legitimate, but it is an API that is not directly part of the language.
Admin
It's one thing to bash abstract thinks like a language and it's another thing bash people.
Which language is JavaScript a clone of? JavaScript combines the basic syntax of Java with semantics found in other languages like Lua, Perl, Python, LISP.
Admin
I'm not at all saying that it's useless, but I think it's not often fully utilized .
There are other browsers, like Safari, Opera; there are older browsers.
Admin
That is principally a problem with educating programmers. If programmers were not spoon fed object-orientation, they wouldn't understand that either. Functional programming is not as difficult or complicated as it is made to sound.
My cheat sheet here (Webmaster in a Nutshell) claims that I.E. 4 and Netscape 4.5 were both compliant with the spec. (I would interpret that as "Compliant or really close".) As for Safari and Konqueror; Opera; and IE/Mac, I'm not really worried. I can't say that I have exhaustively tested them, but they are all correct or close. Older and more obscure browsers are in too little use to mention unless you are specifically targeting users of embedded devices.
Admin
The "lambda calculus thingy" *is* Scheme, almost. It's incredibly powerful. If you're interested, read the lambda: the ultimate... papers (http://library.readscheme.org/page1.html) which describe some of Scheme's ideas (don't like to link in case the forum software buggers it up).
If they behave differently with respect to semantics, where those are defined, they don't interpret JavaScript correctly. Different functions being available in different web browsers is a shame, but as a programming language JavaScript is really quite good (and nothing like Java).
Admin
No, it is O(nm), which can generalize to O(N^2). It is only fast because n and m are small. If you indexed all the pages that technical support should have indexed, it would be slow, and hard to maintain. Not to mention how slow it would be because of the load time if the user is still on a modem.
This is only easy to maintain because the people maintaining it are too lazy to type all the keywords. If they had all the keywords required, for each page, this would be slow and hard to maintain.
Admin
A more accurate history of Javascript is that it is descended from an interpreted dialect of C called CEnvi. (I cannot a reliable reference to confirm this.) In fact, it was called Livescript until it was renamed Javascript under some marketing pretense. Modern versions have more in common with Self than any of the above languages, other than the C-descended appearance of the language and the presence of C-style loops and branches, rather than Smalltalk-style messages.
(Correction to my code example above, s/.map/.collect)
Admin
You forgot about lotus notes.
Admin
Would downloading the Google databases save bandwith too?
Admin
Message to self: RBYP.
Admin
What about witch burning?
Admin
Well, that sucked for the witches. JavaScript sucks for programmers AND end users.
I think a better metric is the amount of hot air produced. The amount of hot air produced by burning witches, even allowing for extreme cases such as Agnes Nutter, is rather negligible when compared to, say, a forest fire. But neither hold a candle to the amount of hot air produced by modern, industry-grade marketing departments, such as that of Netscape when it introduced and named JavaScript.
Admin
O(n²) is a special case of O(nm) (where m is O(n)), not a generalization. Also, there's three nested loops with not necessarily constant iterations in the given code snippet, so I'd rather say it's O(nmo).
Admin
Actually, I write JavaScript form validations all day, every day, and it does an excellent job of it (and keeps me employed). I don't understand the concept of bashing languages, because all of them may fit a particular job or task, but not *all* jobs and tasks. In my opinion if you tried to design a truly "everything" language it would be extremely cumbersome in most situations. Just like I wouldn't write a spreadsheet app in JS, I wouldn't want to use some other client side like Java just to check that someone entered a number less than ten in a text box for a medical form. I wouldn't try to rebuild your car engine using just one wrench, either.
Admin
Great point.
Admin
Because it's been even more misused than Visual Basic, which is quite a lot of misuse.
Uh?
You're not referring to Javascript as a "java clone" are you ?
Not really, even though the ECMA specs suck hairy balls, the language itself is fairly clean and E4X has quite cool additions to JS 1.5.
It's lacking some kinds of modules and namespaces, but that's just requests of a pythonista.
These are very trueJS is not a bad language at all.
Most of it's implementations (browsers) on the other hand are full of holes and inconsistant, that's the real quirk.
Well, both Internet Explorer and Firefox give you Javascript accessors to their XSLT engines...
You should be a bit more careful with your wishes... behold the Simple Javascript Database!
Admin
Object literals and global variables are a perfect recipe for modules. (Prototype uses this to extreme; it has a function Try.These(f1, f2...) as the only thing in the object Try.)
MyModule = {
my_function1: function(args){ body; },
my_function2: function(args){ body; },
my_global: value,
my_inner_module = {
inner_crap: function(args){ body: }
}};
If you are using prototype-based inheritance, you would just need some helper functions to store prototypes in modules (and use modules to build useful prototypes).
I have my own sets of functions for this crap, but see prototype.js for the basic idea.
(And I don't actually namespace anything yet, my projects aren't that big.)
Admin
It has been discussed before, but let's roll back the discussion. The original question was: Why does everyone hate JavaScript so much?
During the discussion, I've learned that JavaScript is related to functional languages, especially Lisp. But this is not at all obvious, since Netscape and Sun decided to call it JavaScript, not LispWithCStyledSyntax.
On the other hand, in many cases, HTML pages containing JavaScript are created on the server by a Java program (JSP, Servlet, JSF, Struts...). There was a time when Java Applets were regulary used on web pages. So I think it's fair to assume that many programmers doing web programming are familar with the Java language. It's also fair to assume that many programmers are not familar with Lisp or functional programming. For that reason, they do not appreciate or utilitze the power of functional programming given in JavaScript. All they see is a scripting language that tries to look like Java, but lacks many of the concepts given in Java and seems to use some keywords ("function", "var") in rather strange ways. That plus the problems with different APIs (DOM) in different browsers and other browser-related problems make some people (including myself, I admit) more-or-less hate JavaScript.
Admin
And legions of programmers have cursed them for that marketing ploy. Especially all regular contributors to Java-related newsgroups.
It pretty much lacks ALL of the key concepts of Java. Hardly anyone would think that it "tries to look like Java", were it not for the name.
Admin
That's not modules, that's namespace emulation.
By "modules", i meant having import-ish statements in JS files instead of having to link all your JS from your HTML and getting a whole damn mess in your global namespace.
Admin
It didn't make that much of a difference for the small programs that have been written in the early times of JavaScript, since the DOM was not evolved then and browser support was lacking.
Admin
...You wound me.
I perl'd up 2 megs of data to be pathological and came up with a fairly complex query, just to watch it take forever to crash horribly. =D
The only thing I don't understand is why the guy discusses AJAX, yet refuses to store the data in XML strings. Obviously there's a lot of room for major feature refinement here. I'm going to modify the backend and sell the code to Alex's XML-crazy company for millions. Score!
Admin
Right... have you ever used CL?
Where in JS are macros? Where's the normal map/reduce suite? Where's the native code compilation? Where are the full set of handy iterative operations? Where's CLOS with generic functions? (No, prototype-based OO doesn't count.) For that matter, where's LET?! JS's scoping rules (function and global) piss me off.
JS is not derived from CL. Maybe it's Scheme? No, where are the continuations. If anything, you might say that JS comes from Lisp 1.5, with lexical scoping thrown in, but without most of the improvements that came since then.
JS has closures. CL and Scheme have closures. That's about the full extent of the semblance.
Admin
Whereas Richard's Tone is always rosy. ( :p)
Admin
In Internet Explorer (at least), that can be accomplished by dynamially inserting a script element with the appropriate attributes. A similar method probably works in Mozilla. More generally, in all other browsers that support XmlHttpRequest (or alternative methods) in some form, you could fetch the source and run "eval(request.responseText)". That's hackish, but it should work. (I'll try it at work tomorrow.)
In fact, I'm glad you pressed me to think of this; the application I'm developing uses a lot of Javascript that should not all be exposed to the world before the user logs in.
Admin
good results for the end user not really wtf
Admin
Firefox gives an error. Somethingorother isn't a function.
So there you are.
And writing an SQL interpreted for JS is just plain nutty. I've written the usual handy things to pick up elements, like elemsByClass() and elemsByTag(), but I wouldn't dream of implementing a full CSS-selector function "elemsBySelector()". Just think of the magnificent overhead and function overload!
I agree with ammoQ that js is still far from being a reliable programming platform, but that's not JS's fault, that's just because all these browser makers do things their own way. IE5/Mac doesn't even support array.push() !
But one notable difference in implementation is the rounding of floats to ints. I'm not sure which is which anymore, but IE rounds up and Gecko rounds down. I was calculating something recursively down to a single pixel, and one of the two browsers fell in an infinite loop, while the other stopped just 1 pixel short.
I don't know if that's 'quirky' or in violation of the spec.
Another thing about JS is that it's inherently slow due to it being interpeted in an engine that runs inside a browser instead of being a standalone program. The same thing plagues heavier Actionscripts. The objects it typically manipulates (element nodes) are relatively heavy. A loop that produces only a few hundred elements will keep your browser busy for a second or two.
But all in all, I love JS, because I love how I can juggle around the graphical things called HTML elements and enhance the browsing experience*. :)
*) that does not include trails of stars that follow your cursor, but rather, areas that switch colour when you click a radio, layout stretching etc. True interface enhancements.
Admin
Of course you could display the searc items if the result is empty. "You would better type something like searchitem1, searchitem2..."
Admin
Strange... it works with my Firefox. (1.0.7 on Linux)
Well, if it worked on the Windows CE Internet Explorer, I would immediately know a good use for it. Unfortunately, it doesn't.
For intranet applications, where the IT department has control over the browsers in use, it's acceptable. For the WWW, there is
always the need to fall back to support other/older/script-disabled browsers, which limits usability.
I don't aggree. Interpreted languages are also often used outside the browser, e.g. PHP scripts; in many cases, they are fast enough.
Admin
That's got more to do with Microsoft. They tried to implement a language before they knew how. It was the first time they had ever tried to do even POSIX-level regular expressions. Add to that their blatant disregard for standards, with an eye on resetting standards according to their defacto standards.
I know that "bashing" Microsoft is a no-no here. But Microsoft's inability to implement an existing standard is really the culprit here, don't blame the language that they scuttled.
Admin
Thank you, but I know what AJAX is. However, even with AJAX, hitting a server every time a letter is typed is a WTF simply because you have to throw massive amounts of server and bandwidth at the problem to make it work on a large basis. Google can do it because they have massive amounts of server and bandwidth.
The use of AJAX is not the WTF I was talking about, it's doing a complete HTTP request on every keypress that is the WTF.
Admin
I really hope you're kidding (or that I never have to work with you). Roundtrip to server for every character typed ... that's why broadband was developed, right?
Admin
I don't know what you're saying. You seem to be using mild flames and dense sarcasm at the same time and that's hard to distill.
Please answer the following with a non-sarcastic Yes or No:
Is it a WTF to send a request to the server very time a character is typed?
I say, Yes.
You say?
We've developed a system that would benefit greatly from AJAX updating specific parts of the application page in a second, instead of doing a full form submit and basically having the entire system reload after applying a simple change.
Would you accept it if Photoshop restarted every time you added a layer?
Admin
I hope you're checking input on the server side as well....
Rob
Admin
In other news, Macromedia ColdFusion should now be considered a nuclear proliferation hazard :)
Admin
Er, that's what happens when you use an ssh session or similar, you know :) Of course, google's one does a search each time as well, but they're good at that, and no doubt cache. And IIRC they're not strictly using AJAX, rather something lighter-weight of their own devising.
Admin
AJAX is the name given afterward to the entire scope of techniques that use XmlHttpRequest (or similar methods) to fetch data asynchronously and avoid postbacks. "Lightweight" has nothing to do with it. (The name 'AJAX' has been discussed into the ground, so I'm not keen to talk about it again.)
Admin
I'm horrified that nobody mentionned the obvious references in the search "results".
TPS. Inetech. C'mon - you guys saw "Office Space", right? RIGHT?
No? Go do so now, with 20 of your best techie friends. Then read this script and laugh rather than scratch your head.
David.
Admin
So, in your opinion, the following network protocols are WTFs:
Telnet (actually it is, but that's a different story)
SSH
RDP
ICA
VNC
X (actually it is, but that's a different story)
NX
Admin
My biggest beef with javascript is its complete and utter lack of any sane form of type-ing.
This makes writing plugins, and debugging other peoples complex code a pain in the ass.
I once tryed to modify a pluggin for Firefox (the Chatzilla irc client, if I remember correctly), and gave up after about a week of trying to understand what was going on where and being sent to which.
Admin
Admin
why don't you get fucked