Archive for March, 2006

A Functional Diversion

Thursday, March 23rd, 2006

Even my friends who aren’t into functional programming find something curously relaxing about this. (And the companion site here.)

I bought foldr.com a year ago when I thought I might do something like Flickr for other types of information. I didn’t realize until last week what I was sitting on. :-)

Update: The use of the infinity symbol sparked a lively discussion on LtU.


Read the rest of this entry »

JavaScript Gradient Roundrects

Thursday, March 23rd, 2006

JavaScript Gradient Roundrects adds gradient roundrects to an HTML page, without images. It uses the WHATWG canvas tag if it’s available. Otherwise it uses a stack of divs, whose heights are adaptively chosen according to the height of the graded element, the color components, and the radius curvature. There’s a demo here.

I also wrote a JavaScript CSS parser that lets you attach gradients to an element without writing code. You do this by including CSS inside a div tag whose class is ‘style’.


Read the rest of this entry »

Inline JavaScript Console

Friday, March 3rd, 2006

Last week for the first time I did some serious browser JavaScript programming. I put the following tools to good use, but ran against limits with each of them:

  • fvLogger is terrific, but doesn’t include an evaluator. You have to reload your page each time you want to query a new value.
  • Rhino is great for pure logic, but you can’t use it with anything that use a browser API. In fact, you can’t use it with anything that uses anything that uses a browser API. This means, for example, that you can’t use it with a library that uses Prototype, without writing some mock objects first.

Read the rest of this entry »

Readable JavaScript Values

Friday, March 3rd, 2006

One problem with JavaScript development is that the string representation of a value doesn’t tell you much about the value. For example, [null], [undefined], and '' all display as the empty string. [1,2}, [[1,2]], and [[1],[2]] all display as 1,2 (and so does "1,2"). And ({a: 1}), ({b: 2}), and new MySwankyNewObject() all display as [object Object].

If you use an IDE for development, this may not be a problem. Probably the IDE has its own string representation; even if it doesn’t, you can generally drill into objects by clicking on them. This doesn’t help those us of who prefer REPL development or printf-style debugging. When you display a debugging value (to the browser status line, to the alert() dialog, or to the Rhino console), you’d like some indication of what it actually is. And JavaScript doesn’t generally tell you, at least when the value is more complex than a string, number, or boolean.


Read the rest of this entry »