Categories
Books JavaScript

Douglas Crockford’s Good Parts of JavaScript

Recovered from the Wayback Machine.

My editor at O’Reilly sent me a copy of Douglas Crockford’s JavaScript: The Good Parts, which I found to be both interesting and useful. The volume is slim, 153 pages in all, but packed full of information about JavaScript—the good parts and the bad.

I found myself nodding more than once, raising my eyebrow a couple of times, and chuckling a time or two, especially when reading about the equality operators, those “evil twins” of JavaScript, according to Crockford.

The book is not intended for neophyte developers, or even those new to JavaScript. It does, however, give you insight into the mind of a very experienced JavaScript developer. Such insight can provide the information necessary to take you from being familiar with JavaScript to being experienced with JavaScript. In particular, the book’s fourth chapter on Functions is, by itself, worth the price of the book.

Crockford writes clearly and without pretension, which I found refreshing. His aim is to clarify, but without pandering. He doesn’t hold you by the hand, and don’t expect him to explain every last bit of the subjects introduced. However, reading through his material is a nice confirmation as to whether your understanding of JavaScript is comprehensive, or if you’re missing out on some of the bits. I particularly liked his chapter on regular expressions, because I suck at regular expressions.

You’ll also be served a hefty dose of Crockford’s opinions on the JavaScript language, which is no bad thing. I didn’t necessarily agree with all of his opinions, such as avoiding the use of new, but I liked reading the opinions because they help me question my own use of the JavaScript language: is this necessary? Could this be improved? Why am I doing this?

I don’t usually have opinions, good or bad, about components of a language. I either like the language, and learn to adapt to the awkward pieces; or I don’t like the language at all. I like JavaScript, so I tend to like all of JavaScript, even the grungy parts. If there’s one thing I consider to be a “bad” part of JavaScript, it is the experts in JavaScript who tell us not to do this or that, but either give no reason for their opinion, or the reason they give borders on the obtuse and cryptic—assuming that we, of course, know exactly what they’re talking about (if we’re worth anything as programmers, goes the implication).

Reading Crockford laying out his opinion as to what he considers “bad” in JavaScript, and why, in clear, unambiguous terms—with examples—is like a breath of fresh air. His doing so is also worth the price of the book (leaving me to wonder whether I should, in all fairness, pay twice). I can only hope other experts, in whatever language, follow his lead.

My only quibble with the book is one paragraph in the chapter on Objects, and that’s because I’m still puzzled by what I read. Crockford writes:

The simple types of JavaScript are numbers, strings, booleans (true and false), null, and undefined. All other values are objects. Numbers, strings, and booleans are object-like in that they have methods, but they are immutable. Objects in JavaScript are mutable keyed collections.

My understanding of immutable objects is that these are objects, not some form of pseudo-object, or second class object. If I had been a tech reviewer for this book, I would have asked for additional clarification of this paragraph in the text.

Other than this relatively minor quibble, though, I really enjoyed this book. It is a nice read, and invaluable for any JavaScript developer.

Categories
Technology

Mac Pro

update

Well, I’m officially dead in the water. I did create a firewire bootable image on one of my external hard drives, and had it running once. Now, however, when I go to start the machine, pushing the Option key does nothing. Trying to safe boot or single boot does nothing. Trying to boot off an install disc does nothing, and I can’t get the disc out. All roads lead to kernel panic.

Though the RAM tested as good, I have to assume it isn’t good if I can’t even get to state of being able to pick which disc to boot from. Regardless, there’s nothing I can do now until I take it into a genius bar, but since I can’t afford to replace RAM or hard drive or whatever other expensive item the Apple people will recommend, it will just have to sit for the nonce. Perhaps it will use this quiet time to meditate on the evilness of its ways.

Thanks, though, for all who tried to help. Found out some new and useful ideas for the future.


I have a question for those of you who understand the Mac quirks.

I have the last of the G4 Powerbooks with Leopard installed. I haven’t had problems with the computer until just recently, when it seemed to start running a little more sluggishly. Today, when I rebooted, I got a kernel panic. I tried resetting the PRAM and even the PMU, but couldn’t get past the kernal panic. Finally, I booted in Single User mode, and ran fsck to repair the disk.

The first time through, it said files had been changed, so I ran it again. The second time it came back with an OK message, and I typed in reboot.

I was able to get into the machine and run the disc utility to repair the permissions and everything seemed fine. However, when I rebooted again, I got the same kernel panic, and had to run fsck again. This time, I only had to run it once.

I’ve since rebooted the machine twice and it seems fine. One difference between this set of reboots and the previous, in addition to running Disc Utility, is that I also cleaned out some old files and went from 17GB of free space to 23GB.

I am worried that something might be about to go on the machine. Have any of you run into this situation, and do you have guesses as to what the problem might be? I really can’t afford another new computer, and need to keep this one going.

Categories
XHTML/HTML

HTML and XHTML and bears, oh my!

James Bennett writes on why HTML is the markup for him. There really isn’t anything to agree or disagree with, because he’s expressing his personal preferences. To him, the fact that you can co-mingle different vocabularies, such as XHTML, SVG, RDF, and MathML, isn’t enough to overcome the draconian error handling (there’s that term again, death to the term). Fair enough: XHTML isn’t for everyone.

One point of clarification, though: HTML5 isn’t just HTML, it’s also XHTML5. I know that the specification is misleadingly named, and seems to implicitly promise a path away from XHTML in the future, but I’d hate that those who prefer HTML would close that road for the rest of us; somehow helping to remove the option of using XHTML for those who have worked through the XML error handling in order to reach the advantages of a truly open page markup.

Working through the XML processing becomes less of a challenge as time goes on, as tools undertake the “burden” of ensuring proper markup so that we don’t have to be so encumbered. I’ve found the htmLawed Drupal plug-in to be wonderfully adapted to solving so many of the problems I’ve had with character encoding in the past. As for generating proper markup in the post, I can either manage the markup myself, which typically consists of paragraph and hypertext links, with an occasional image or SVG document; or I can have the filtered HTML option handle the markup, as it seems to respect and not munge SVG documents.

As for site design, every Drupal theme I’ve adapted so far has validated as strict XHTML. Makes my job pretty easy.

The point isn’t that HTML is better than XHTML, or that XHTML is better than HTML. The point is we all have our preferences, and we should expect browsers to properly handle both—now and in the future.

(via Simon)

Categories
Browsers

Urges

Recovered from the Wayback Machine.

I have this insanely perverse urge not to download Firefox until Wednesday. To get up in the dead of night, tip-toe to my machine and hit the download button when the date is safely the 18th; cackling in glee at the thought that I, I, am the sole hold out–the traitor, the ingrate, the rebel.

What will happen, instead, is I’ll forget about it and sometime later tonight when I’m online, reading or writing or both, the automate update wizard will pop up and tell me there’s a new version of Firefox. I’ll click the button for the upgrade, and probably won’t think twice about it.

My moment of rebellion will have passed, immersed in other things.

Categories
SVG

Robert: Applying SVG effects to HTML

A couple of people have kindly pointed out Robert O’Callahan’s wonderful exploration Applying SVG Effects to HTML.

I’ve held off on posting about it, as I wanted to create a longer writing trying out Robert’s work. However, I didn’t want to put off sharing this effort any longer. I’ll have more on this mix of HTML and SVG at a later time. In the meantime, if you’re a fan of SVG, you’ll want to check out Robert’s work.