Thursday, August 31, 2006
Wednesday, August 30, 2006
Tuesday, August 29, 2006
Language Log: Bogosity
Bogosity is apparently a CMU coinage. I was at CMU in the mid-1980s. The terms "bogosity" and "bogometer" were much in use, but "microLenat" was not current.
As for reference to a gradual student named Reid, I have to wonder whether that person was Brian Reid, the author of Scribe.
As for reference to a gradual student named Reid, I have to wonder whether that person was Brian Reid, the author of Scribe.
Monday, August 28, 2006
Javascript: innerHTML vs. DOM
There's some debate about whether Javascript code should be using the DOM or innerHTML. My take is that browsers are designed to parse HTML and we should not reinvent the wheel, because it will only be buggier and
slower. Thus, I feel that the presumption ought to be that innerHTML be used before the HTML is parsed, and DOM afterwards.
slower. Thus, I feel that the presumption ought to be that innerHTML be used before the HTML is parsed, and DOM afterwards.
Sunday, August 27, 2006
Wednesday, August 23, 2006
Crockford on Prototypal Inheritance
Douglas Crockford has put up this intriguing page on Prototypal Inheritance in JavaScript:
It makes sense that since JavaScript is a prototype-based OOP language, its prototyping support should be exploited directly, not used to simulate something we are more used to (here, class-based OOP).
Five years ago I wrote Classical Inheritance in JavaScript. It showed that JavaScript is a class-free, prototypal language, and that it has sufficient expressive power to simulate a classical system. My programming style has evolved since then, as any good programmer's should. I have learned to fully embrace prototypalism, and have liberated myself from the confines of the classical model.
. . .
Fortunately, it is easy to create an operator that implements true prototypal inheritance. It is a standard feature in my toolkit, and I highly recommend it for yours.
function object(o) {
function F() {}
F.prototype = o;
return new F();
}
The object function untangles JavaScript's constructor pattern, achieving true prototypal inheritance. It takes an old object as a parameter and returns an empty new object that inherits from the old one. If we attempt to obtain a member from the new object, and it lacks that key, then the old object will supply the member. Objects inherit from objects. What could be more object oriented than that?
It makes sense that since JavaScript is a prototype-based OOP language, its prototyping support should be exploited directly, not used to simulate something we are more used to (here, class-based OOP).
ur-, "proto-"
The versatile German prefix ur- (also er- for verbs) derives from Germanic *uz- and is related to English out-. For more, see the AHD entry for PIE *ud-.
nehmen, to take
The productive German verb nehmen, "to take," has largely been supplanted in English by the verb take. Nevertheless, cognates of nehmen have survived into English.
The most direct cognate is the archaic verb nim (nimmed), which means "to steal." More common in modern English is the adjective numb, based on the former past participle plus an unetymological -b, with the general idea of "taken of one's senses." A related word is nimble.
The most direct cognate is the archaic verb nim (nimmed), which means "to steal." More common in modern English is the adjective numb, based on the former past participle plus an unetymological -b, with the general idea of "taken of one's senses." A related word is nimble.
Thursday, August 17, 2006
Wednesday, August 16, 2006
JavaScript
Lately, I've been keeping current with my programming skill by learning JavaScript. Douglas Crockford aptly called JavaScript, The World's Most Misunderstood Programming Language. Here's how Crockford put it:
I got to fall in love with Lisp at CMU, and now with JavaScript I have a powerful, Lisp-like language that comes free on my browser. Also interesting is that JavaScript is a prototype-based object-oriented language.
Nevertheless, grokking this language takes experience, and one of the purposes of this blog is to document some of the lessons learned from the school of hard knocks.
JavaScript's C-like syntax, including curly braces and the clunky for statement, makes it appear to be an ordinary procedural language. This is misleading because JavaScript has more in common with functional languages like Lisp or Scheme than with C or Java. It has arrays instead of lists and objects instead of property lists. Functions are first class. It has closures. You get lambdas without having to balance all those parens.
I got to fall in love with Lisp at CMU, and now with JavaScript I have a powerful, Lisp-like language that comes free on my browser. Also interesting is that JavaScript is a prototype-based object-oriented language.
Nevertheless, grokking this language takes experience, and one of the purposes of this blog is to document some of the lessons learned from the school of hard knocks.
Why a Subsidiary Blog?
My main blog is Hypotyposeis, so why am I starting another blog?
Well, I like to blog when I'm learning new things, but not everything I figure out quite fits the scope of the main blog, especially in the areas of law, high tech, and modern languages. Hence, this blog.
Well, I like to blog when I'm learning new things, but not everything I figure out quite fits the scope of the main blog, especially in the areas of law, high tech, and modern languages. Hence, this blog.
Subscribe to:
Posts (Atom)