Saturday, September 16, 2006

For ages, my newer version of my lame Javascript text adventure game has been getting an error in IE6. (Link goes to old version). Sadly, because I had done a lot of changes testing just on Firefox, and the error message was completely useless ('Error: object expected' with the file stated being the HTML file and the line number being the line at which JS is called) it took me a while to figure it out which change had caused the error.

So I just continued developing for Firefox.

This, of course, means that many more IE nonworkinesses have appeared, and since I don't keep detailed version history, it will be painful to identify them all. But I've finally found the original idiocy.

In Javascript--much like Java, C, C++, and so on--you define a constant by writing const variable_name[ = value];. This works just fine in Firefox and Opera, and probably in most others. But In IE, it doesn't. And when it doesn't work, it doesn't complain 'You wrote "const" on line 42 and I don't know what that means'. Instead, it pretends everything is all right. Suppose you have this in your header:

<script type="text/javascript">
const c = 3;
alert('Testing');
</script>
No error message will occur. Yet should you comment out const c = 3;, the alert will run, so there's no question that IE is doing stuff in the right order here. Same thing if you do
<script type="text/javascript">
function foo()
{
const c = 3;
alert('Testing');
}
</script>
<body onload="foo();">
</body>
No error message. Just silence. Commenting out the const (or doing s/const/var/) will make it work fine.

To get it to report the error, the user has to activate it, as best I can tell. Onclick will get the job done:
<script type="text/javascript">
function foo()
{
const c = 3;
alert('Testing');
}
</script>
<body>
<p onclick="foo();">Get an error message</p>
</body>
And you don't need to call the 'erroneous' function:
<script type="text/javascript">
function foo()
{
const c = 47;
alert(c);
}
function bar()
{
var c = 42;
alert(c);
}
</script>
<body>
<p onclick="bar();">Get an error message</p>
</body>

Basically, if the keyword 'const' appears anywhere in that Javascript, it's all dead, but you won't be informed until you explicitly try to execute it. (Multiple <script> tags will work independently, as will code in an onclick attribute.)

Ramble, ramble, ramble. My point is, someone please tell me how to get constants to work in IE. I don't really need them, but it's generally considered a good practice. Probably slightly faster run-time too, though so minor that it doesn't really matter in this situation.

Anyhow, there will likely be a new version coming out in a few days. Unless I decide otherwise. Or I end up having too much trouble with all the other errors IE6 is--oh, wait, hey! No other errors at first glance! Marvy!

Wednesday, August 30, 2006

When writing papers for school, I always tried to add humorous elements. Writing about philosophy can be serious, but there's always room for a good joke.

And as we all know, a joke directed at the professor grading the paper is the best kind.

At one point, I had a professor who held one very unorthodox view regarding the validity of one of the most basic logical structures. As in, he considers modus ponens invalid in certain situations. No, really, he did. Very well-known, highly-respected philosopher. Someday perhaps I'll write an entry on his argument. Not right now.

The point is, he thought modus ponens wasn't always valid. So after providing a M.P.-based argument in my paper, I commented,

It seems pretty clear that it is perfectly valid, and so the only way to respond to such arguments is to deny one of the premises. (Or to deny Modus Ponens, but only a crazy radical would do that.)
I don't remember my exact grade, but it was an A, as always.

[Insert some point to this post here.]

Tuesday, August 29, 2006

When I was young, when I'd try to write a story, I wouldn't know how to start. I knew 'Once upon a time' was lame. So what to do? I could start out by introducing the character: 'Bob was a lawyer who wanted to be a carpenter.' But that sounded clumsy. The only way to make an opening line like that would be an almost Carrollian commentary discussing Bob with us. Very lighthearted, and very narrator-talking-to-the-reader.

Eventually, I realised the easiest way was to start in the middle of something. 'Bob looked around nervously. This was his first time using a hammer and if he broke his fingers, he didn't want the nearby construction workers to laugh at him.' It worked.

If I was a better writer, I'd do something in between. 'It was a sunny day in middleton. The leaves fluttered in the breeze, and Mrs. Andrews was hanging up laundry to try. Down the street, a construction crew was breaking for lunch.' But the transition over to Bob's stealing a hammer and then smashing his fingers requires magical writing skills only held by brilliant writers.

So I usually stick with the 'jump right in' approach. Bob's holding the hammer. Ambulance needed presently.

But I can only write a few paragraphs of this scene. I then have to jump over to Fred who is in another country but will hopefully tie in sometime later. Fred's an orthopaedic surgeon. Yeah, that's right. Oh what fun he'll be, what with the cutting and sewing and gushing blood!

Two paragraphs later, though, I have to leave this scene to go to another. And it can't be the Bob scene. That one hit a dead end. I have to start yet another.

Perhaps next November my Nanowrimo will consist of 49 000 words of brief, unrelated scenes followed by a three paragraph conclusion that pulls them all together. That, I can do.

Friday, August 04, 2006

From time to time, I'll create a 'hit-and-run website'.

My first one was Mr. Worf's Homepage (which was deleted for unknown reasons, but I've now reposted it at the original location). A link to an parody anti-Trek website was mentioned on alt.tv.star-trek.enterprise, so I wrote a page with a similar style as 'Mr. Worf', and signed the guestbook as him.

Then in 2003, a Foxtrot strip featured Eileen Jacobson complaining about Mandy Berwick who things she's so popular. At the end, Eileen shouts out 'Zero matches on Google, Mandy! Zero!' So I threw together Mandy Berwick's homepage. Sadly, though blog posts and such appeared on Google that very day, my new site didn't for a while. Oh well.

I've since written three fan sites for people I know. There may be others around, but if so, I don't remember them.

It's a fun thing to do. Advice: Freewebs is probably better than Tripod. Of course, you could use your own host,but then it's less anonymous. Blogger also could be used, but blogs are less cool than normal hit-and-run sites.

Monday, July 31, 2006

Juan Tripp Airline decides business people are both richer and more likely to want to return home on Friday, while the cheaper vacationers are happy flying home on the weekend. So they charge more for the Friday return flights. Bob Vacationer, however, is both cheap and works weekends, so instead of having his lovely consumer-surplus-filled vacation, he has to stay home and watch Monty Python DVDs.
Result: inefficiency/waste caused by price discrimination.

The textbook and Wikipedia articles I've read never seem to mention this--though I'm sure it's covered somewhere in papers and cleverer textbooks. Does competition deal with this somehow? I guess it must not or else we wouldn't have imperfect price discrimination, eh?

Monday, July 24, 2006

If you're hoping for a long, thorough essay covering all sorts of inadequacy and annoyances of Javascript, you're out of luck. I just have one thing to whine about today: lack of interpolation.

I do a lot of stringish stuff in Javascript. Loads. Just recently I was editing this argument: sp + ',' + mp + ',' + dp + ',' + type + ' ' + x + ',' + y + ' (' + done + '/' + total + ')'

That's ugly. Even more than it's ugly, it's a major pain to type out. $sp, $mp, $dp, $type $x $y ($done/$total) is slightly annoying, but almost incomparably better.

sprintf could help, but is still majorly annoying. I want interpolation.

(The biggest Javascript annoyance is, of course, incompatibility, especially when combined with IE's inability to give useful error messages.)

Saturday, July 22, 2006

A cursory run v. a cursory walk. Redundant beats contradictory.

Friday, July 21, 2006

(Potentially relevant link)

Yahoo! Answers is funner than Google Answers because it has points. XP like E2, essentially. Unfortunately, it sucks big time. This is for several reasons, most of which boil down to lack of accountability. If you look at ten random questions, you'll likely find at least that many incorrect answers, and probably a fair number of 'i dont know'/'look it up's. The people posting such answers get two points for it, and lose nothing for being wrong or unhelpful. You can't downvote the person claiming only three countries ban flag desecration or the morons claiming allosaurus or tyrannosaurus rex as the largest meat-eating dinosaurs or claoming infinity is the largest prime number. Only occationally will you find the incorrect answer being chosen as best answer (an exta ten points), but posting an obviously incorrect answer shouldn't gain you any points.

In addition to the idiots giving and voting for incorrect answers, there's a more prevelant problem--though perhaps a less troublesome one: multiple (often ten+) people will post the same (correct) answer to a question. And I don't mean nearly at the same time so perhaps they didn't see the earlier answers. They can be hours apart, and the same one-word answer will be posted again and again. It's essentially spam, but not considered so by Y!A.

A third problem is that there's little to no community cohesion. On E2, I knew the people and they were--for the most part--friendly. On Y!A, people are relatively unknown and more often trolls than anywhere but Usenet.

Y!A's moderation is this: major abuses get deleted and good (and some bad) answers get extra points. But I could probably gain thousands of points a day just by doing what most people do: post the same, one-word, useless answer as everyone else on simple questions. The primary thing Y!A needs to change is moderation. Punish incorrect and repetetive answers instead of rewarding them.

Oh, and while I'm complaining, it's filled with useless/poorly-formed questions. But that's not quite so bad since you don't gain points for posting questions. (Actually, you lose them, but then regain them when you pick the best answer)

Thursday, July 20, 2006

(Potentially relevant link)

A book by Brigid Brophy, Michael Levey, and Charles Osborne.

I haven't read it, but I've read the E2 node a few times. Summary: here're fifty books that have been parodied and rehashed and made tribute to so many times that we recognise any references to them without needing to read them.

Is it true? I don't know. /Hamlet/ is on the list, and you don't need to have read that to be very familiar with it, but I don't recognise many of the titles on the list. I guess its about their being alternate works to which to redirect the references, not there being common knowledge about them.

That's all. I just felt like posting something here, and that's what I came up with. Sorry.

Friday, June 16, 2006

(Potentially relevant link)

My Intro CS textbook--Computer Science: An Overview (6th ed.1) by J. Glenn Brookshear--described, among other things, the GIF image format. According to it, GIF compression consists entirely of limiting images to 256 colours (as opposed to BMPs which aren't compressed). Of course, as someone who wasn't completely clueless, I knew essentially how GIF compression worked and that BMPs can use 8-bit colours, or even 2-bit colours.2

What I didn't know until today was that GIFs can in fact be more than 256 colours. That's amazing. (Note for people like me who have animations deanimated: the true colour GIF at the above link is an animation.)

1 I think 7th ed. was recommended, but those of us who'd bought the used copies had 6th ed. and that was fine too--so long as we noted this one error in this one table we used. I later got a 4th ed.

2 My professor, of course, was fairly clueless. He was in IT, and while he may be a good IT person, his C code would contain lovely keywords like 'If' and 'While', he told us i/5 + i%5 would give us i/5.0, and probably other nutballish things. A nice guy, though, and I believe fairly competent at his job when it doesn't consist of teaching courses outside his area.