- 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
Yeah, use really weird characters like ð or å or the eternally fun æ
Admin
I think most people also realize that tail-calls are not required by the ECMA-262 spec (they are for ECMAScript4) and no interpreter actually implements them anyway (most can handle ~1000 or so recursive calls before stack-overflow, I think).
Javascript is the epitome of half-assed. There is so much potential in there, completely mired by idiocy. Sadly, Javascript 2.0 throws out all the possibilities and goes back to the sad-old class based inheritance system, basically ignoring the prototype system inherited from SELF (that it never quite got right anyway...).
Admin
Hmmm.
Maybe I'm missing something but what precisely is the point of this javascript function? To turn everything uppercase?
Why on earth would anybody want to turn all text into uppercase?
Admin
JUST BECAUSE.
Admin
I see something hideous like an 'onfocus="mega_validate()"' on every field, just to make sure that (say) any Swedish characters in the name enforce Swedish rules on the ZIP code, the sex, etc etc. Function mega_validate() would then call validate() in some weird recursive way, possibly with added Ajaxy yumminess, and that would explain the hideous delays.
I think Jake was right to stop the code where he did. (And I think it was wrong to reinstate it, but that's a matter of taste.) There is clearly a lot more WTFery behind the scenes here.
Admin
Really? They took out prototyping? That SUCKS. If anything, other languages should be implementing prototyping.
Admin
What I particularly like about the fuþorc alphabet is that the name itself sounds like a WTF.
Admin
And what is this O(f(n)) thing you guys keep talking about? We're programmers, not mathematicians! No need to worry about that.
Admin
Isn't that the Javascript/functional language way of saying W(t(f))?
Admin
Admin
Admin
But at least he can write the symbols down, even if he's not a mathematician ...
I mean, that should qualify at least for a Senior Web Designer post, with special responsibility for escaping angle brackets in Javascript.
Admin
If you can't look at joke like this and figure out why it's funny, you definitely shouldn't be posting here.
Admin
Admin
So stupid. Obviously this needs more ifs.
Admin
What's with all the "else" thingies? Cut them out and your sources will be way smaller! You may laugh, but after you implemented proper uppercasing for all currently known uppercaseable unicode characters, you will notice the difference.
Admin
"This machine is a piece of GAGH! I need dual Pentium IV processors if I am to do battle with this code!"
That says it all, really.
Admin
Admin
"You question the worthiness of my Comment?! I should kill you where you stand!"
Admin
And anyone named François is just plain out of luck, no matter how he capitalizes his name...
Admin
Whilst it's not perfect, it's not the worst possible solution. I think his machine was at least partly to blame for the speed issue...
Admin
Care to go back to Reading Comprehension School?
Or don't they have one in Podunk?
btw, can you spell O(n^2)?
Admin
This can be done without Javascript at all. Use text-transform: uppercase on the client side and convert the form data to uppercase on the server side.
Admin
Architect's type and work completely in upper case. I don't know why but that's just what they do.
It still dumbfounds me that these people don't think "there could be an easier way" and google to find the .toUpperCase() function. The mind boggles.
Admin
I don't see how it can be slow as described. Assuming the input is 100 characters, it only takes ... ~300... 2^30...
oh shit.
Admin
A missed opportunity, sir. You shoulda said Alexander Papadimoulis.
Admin
What drives me nuts is web pages used to submit an e-mail address that cannot recognize a valid e-mail address.
I used to get so much spam at my usual e-mail address that it was unusable. In response, I finally started accepting e-mail only if it satisifed one of the following criteria:
The sender's e-mail address is whitelisted.
The e-mail is encrypted with my PGP key.
The e-mail is digitally signed with their PGP key.
This worked pretty well. It pretty much cut out all the spam. But there were times when I couldn't get e-mail from some people who were unfamiliary with PGP.
So I set up a bunch of whitelisted to adddresses. For example, if my e-mail address is [email protected], it also accepts e-mail addresses of the form [email protected], [email protected], [email protected]. I selected a specific list of words, none of which have anything in common with any other word in the list, and whitelisted e-mail addresses using them after the +. Then I would give out each e-mail address of this form, e.g. [email protected], to one organization or person.
Thus, [email protected] may be refused unless it satisifes one of the other three criteria, but [email protected] would be whitelisted. If I should start to receive spam or other unwanted e-mail at [email protected], I can blacklist that e-mail address and leave the same alone.
Unfortunately, it seems that many web pages that ask for e-mail addresses don't recognize e-mail addresses containing a '+'.
Admin
I would think that almost any polynomial-time algorithm would be more than sufficient for such a small data set.
Javascript must suck even more than I thought it did.
Admin
I don't see the problem either =S. I would expect even a few thousand characters to be quick. I mean, how slow can a memcpy be?
Admin
Admin
Admin
I expected something like
Captcha: genitus
Admin
Thank you for your interest in this post. Unfortunately we are unable to offer you a position as our pile of rancid manure^W^W^W^Wcode tried to capitalize your application but hung before it got as far as "down" and "coke". :P
Admin
...and yet, it is not TRWTF. TRWTF is in the comments, of course.
Admin
TRWTF is tu write
var char = A.indexOf(oldval.substr(i, 1));
where char is, in fact, an integer!!!
Admin
As far as javascript goes, it's like all the other "Hey, let's bash a particular language just because I don't like it" rubbish that happens on here. Javascipt has a massively bad reputation because absolutely any halfwit with a webbrowser can try to write some kind of app in javascript, so there's a huge amount of rubbish out there. If you're sensible and follow good programming techniques, there's absolutely nothing wrong with Javascript.
Admin
You don't need to study maths to see why it's slow. Some common sense should be enough. Never made algorithmic analysis. I rather measured the time it takes to do an action. Gives you better insight than a given theory. And for n = 50 to 100 it should still not be sooo slow. Since "Echtes Erdferkel" likes to critisize people (though in most cases he is right) I'll throw in my critics, too. The guy said "When I got to the multiline, free text fields to describe past experiences". This can be far more than just 50 chars. OTH if it uppercases after every key stroke (i.e. OnChange) than it might still be annoying.
Admin
Thx for your help and for proofing that TRWTF is in the comments.
Admin
____...
Uppercased that for you
Admin
The real WTF is that string B is shorter than string A.
Admin
So, unless this "validation" function gets called after every keypress, I still cannot really see how this would take over a second on any modern computer?
It's still an O(N) solution, so its performance can hardly be that terrible; the time it takes to run increases linearly with the length of the string it validates, and I cannot imagine that it takes, say, 0.05 seconds per indexOf call on a string of some 70 characters. Not even in Javascript.
(clearly not using whatever the built-in 'uppercase' function is called in Javascript is still a nice WTF, but oh hey..)
Admin
You are entirely correct. If anything, it would be O(M*N) where M is the length of the constant string; hence is a constant; hence reducing this to O(N), as you stated.
It may still be O(N^2) for the reason posted by someone else: if string concatenation is actually O(N) rather than O(1). This may apparently be the case for some sucky javascript interpreters.
Even so, N^2 is still not that terrible and I don't think it would explain a second of delay on converting a 10-20 character string.
Admin
Are you serious? Isn't it obvious? Uppercasing is very resource intensive. Best done on the client machine, and store the result as early as possible so you don't have to waste time ahem re-inventing the wheel.
Duh.
Admin
Admin
See
http://blogs.msdn.com/jscript/archive/2007/10/17/performance-issues-with-string-concatenation-in-jscript.aspx
for the performance of early implementations of javascript string concatenation. 11.2 seconds for 30 thousand short string appends on a 2007-vintage PC is really kind of amazingly bad.
That plus the wtf-code isn't quite enough to generate a multi-seconeds lag by itself, but multiply it by some comparable idiocy elsewhere in the code and you'd get there.
Admin
There was this textarea I once encountered that would update a counter of the space you had left to bleed your heart in as you typed. It was kind of slow at doing this, though - so much so that after writing a few paragraphs, I had to wait for several minutes for the it to type them out.
I immediately thought there must be some inane O(n) implementation in either the event listener, the character counter or the counter updater. Nope - they were all done using proper language functions, like .length.
Nevertheless, it was very slow, and this was firefox 2 (which does have a crummy interpreter). I pretty much gave up on interactive javascript then and there.
Admin
If you can't figure out the runtime of an algorithm, good luck when you get into anything complex. You just might implement something that's O(2^n) and then have to throw it all in the trash when it can't handle real-world data.
The problem I have in mind doesn't need any math beyond addition but it's still O(2^n) with n approaching 100. Obviously out of the question, some approximation of the right answer is going to have to be implemented in the real world.
Admin
To make string comparisons faster of course. ;)
Admin
Admin
ok how you du her?