Was reading the Joel on Software book, that I bought myself for Christmas, the other day, the one with the ridiculously long title - Joel on Software: And on Diverse and Occasionally Related Matters That Will Prove of Interest to Software Developers, Designers, and Managers, and to Those Who, Whether by Good Fortune or Ill Luck, Work with Them in Some Capacity - that is.
Anyway, to get back to what I was about to say, I was reading the book and eventually found myself readingto chapter forty two, How Microsoft Lost The API War, where he makes a few very good points, if you havn’t read it you should (it’s also avalible online).
Seems like I got carried away again, however I can assure you that I’ll get to the point, eventually… Near the end (page 310 in the book) he lists a few things that can’t be done well in a web application:
1. Create a fast drawing program
2. Build a real-time spell checker with wavy red underlines
3. Warn users that they are going to lose their work if they hit the close box of the browser
4. Update a small part of the display based on a change that the user makes without a full roundtrip to the server
5. Create a fast keyboard-driven interface that doesn’t require the mouse
6. Let people continue working when they are not connected to the Internet
Number one is quite tricky, and probably one can’t be created thats fast enough to be usable, at least at the time being (the SVG support in Mozilla looks promising).
Number two on the other hand, spell checking as you type, immediately caught my attention, that should certianly be possible with todays technology, so I fired upo my favorite editor and started writing a small test case.
It would be very impractical, and obviously very slow, to implement the dictionary matching at the client side, still a lookup has to be made, in near real time. Since speed would be critical the obvious solution seemed to be XML HTTP or AJAX, for those of you who like that term, as it’s a lot faster than the alternative (see XML HTTP Performance and Caching for details). Having decided on the strategy I started to implement it, and pretty soon it became clear that it would actually work.
I’m currently using a very simple Perl CGI script on the server side, that does the actual spell checking. On the client side I use a rich text component where after each keypress a function is fired that checks if a new word has been typed, and if it has the word is sent to the server for validation. When the response arrives the component is updated to reflect the status of the word (misspelled words have a red underline) and it’s cached, so the server doesn’t have to be queried the next time the same word is entered.
Enough implementation details, see for yourselves:
In still very much a beta but works well. Currently only works in Mozilla (Firefox 1.x) and Internet Explorer 6.0 (32bit). Any, and all, feedback is more than welcome.
Oh, and I’m still trying to figure out whatever or not the chapter number has anything to do with the big questions in life.