partiallydisassembled.net

A blog is born

2006-03-20 23:49:31

Hello silent non-existent audience. Behold this here blog. I knocked up the code for this a few months ago as an experiment with using asynchronous callbacks in a semi-synchronous manner. Instead of providing a callback for every AJAX call: get_items(item_callback, ...); the function is wrapped in an *asynchronous wrapper* that returns a proxy which can then be used immediately in many situations: items = get_items(...); display(items); There is a fair amount of hackery involved in getting it working, and it requires that all participating functions are wrapped; also Javascript does not provide operator overloading, so often simple things like addition or iteration of results need to be moved into separate functions. On the server side, you provide a list of functions that can be called, a la remote procedure call. All the wrapping/unwrapping of data is handled automatically (in PHP for now, but could easily be rewritten for any other platform). Even in its current form it's quite usable, and made building this single-page blog site a snap. The biggest difference is that you can treat all data as Javascript objects, rather than having to do messy conversions between PHP objects and Javascript objects or HTML entities. On the other hand, I'm not sure how much further the current approach can take it. There are many traps to fall into when working with these asynchronous functions, they're not at all easy to debug, and even harder to explain. Probably the best way to go about this is to write a whole new language that compiles down into Javascript. Doing this while preserving line-numbers (so browser debug messages are useful) would be quite a challenge though. Text formatting is courtesy of a PHP port of Markdown, and the XML-DOM interface is DOMIT! (the server I'm running this on doesn't have PHP compiled in with xmldom).

Peter Funk writes:

Hi, I stumbled over your BLog following a link from pyweek.org and saw nothing but a Login button. You wonder why? Call me paranoid, but because a lot of browser security problems in the past where related to java err ecma script, I've installed the famous and valuable NoScript-Plugin in my firefox. Look here for more Information about this (what i think very valuable free piece of software): http://www.noscript.net/whats So IHMO it would be nice, if your HTML could invite visitors with Javascript disabled with some text telling them, that your site doesn't contain any evil javascript and that they will not be harmed if they click on "allow partiallydisassembled.net" in their NoScript-Menu. Regards, Peter.
login