Ah, the summer busy season – conferences and black belt testing, with impatient customers and the condo board’s irregularly scheduled crisis to boot. I looked at my todo list for the first time in a few months about a week ago. The weekends have been so full that I’ve only gotten back to a little bit of programming just recently.
I built NJS on top of bunch of libraries, mainly jQuery and a beta version of jQueryUI. jQueryUI is out of beta and looking a little more polished now (complete with interactive theme designer), although I still ran into some difficulties with dialog placement (fixed in edge) and trickier sizing (not yet evaluated in edge)
The first big thing was adding function execution, which led to most of the other features. I knew the basic strategy was to create an object representing the parameters and then browse that, but of course there were details to work out. One minor hitch is that most system functions don’t have declared parameters. Furthermore, since I don’t have much occasion to use them interactively, I’ve made zero-declared-arguments execute without asking for arguments as an interface optimization.
Scratching an Itch
If a function executes in the computer, and no one receives the value, did it really execute? (Depends on whether it’s a pure function or modified mutable state – but that’s almost a different story.) I do need to display a return value somewhere. At first I made up a one element object to browse, though this is somewhat overkill for simple values. Next up, I created a single scratchpad object. Of course, I almost always immediately browse compound objects, so those get automatically opened. I suppose if one is doing more than my short tests, the scratchpad will eventually get crowded, so I may have to add a way to delete properties.
What a Drag
One thing that was difficult to do was executing functions on complex values. One seemly obvious way to do this to enable drag and drop between objects. jQueryUI’s draggable and droppable behaviors made this relatively easy, although it still took a fair bit of tweaking to get the details sorted out. I also ended up going for the behavior which highlighted a hovered target instead of all eligible targets, because the massive screen refresh of the later during a drag operation would cause a screen blank out, at least on the firefox I using.
A difficulty with functions that they can potentially change anything. Even editing a simple value can have remote effects thanks to prototypal inheritance. I’ve finally got some code in place to update things when a value changes. Most of the time this devolves to a global update, and possibly multiple updates per object (where an update is replacing some or all of the DOM representing an object from scratch). It works well enough for my limited purposes.
Looking at some possible exploratory work, I added some functions to my test objects for some basic operations: deriving an object and adding a property. I’ve actually got two versions now; I started with methods on a playground object that operated directly on it, but now I’ve also got some methods which operate on arbitrary objects.
Writing this up was slowed significantly by thinking of new things to try out. Since function are objects, can you derive an object from them (yes, but it behaves funny) Adding system methods (i.e., toString) can also be tricky; I modified my property adding methods take both a name and value, rather than just a name to work around that difficulty.
It may have come together just in time – the JS.chi people just sent out a message saying their other talks canceled on short notice.