Apparently It Doesn’t Exist
I didn’t get any recommendations for equation graphing, so I went searching. I pretty much exhausted the dataflow languages without success. Most of them are textual languages, and of the few with a graphical component, none of the screenshots showed intermediate values.
The most promising thing I found was a very old video of ThingLab. It didn’t show intermediate values either, but it was otherwise the closest to what I was looking for. It was too late to check that out. When I came back to it today, I managed to get it running, only to find the mathematical system wasn’t in the image. I’d have to re-implement it myself, and learning enough SmallTalk to get it working would be a rather monumental detour from detour.
It did point me at constraint systems. Another promising avenue was UniCalc. It just so happens that I recently found a DOS emulator. UniCalc will show all variable values, though obviously not in graphics. The demo version allows a very limited set of variables however, and without the graphics it wasn’t worth pursuing.
How Hard Could It Be?
Actually, not that hard at all, although it involved some of the terrible, wonderful things (I suspect most people call them hacks.) An idea had been growing on me that it would be possible to use operator overloading to create a sort of mathematical DSL. I had a proof of concept working Thursday night after my last post.
What’s in a Name?
I could build an abstract syntax tree with the operator overloading trick, but they were all anonymous objects. Surely, in a dynamic language like Ruby, it’s possible to retrieve the object names?
Actually, it is, although it involves a little eval black magic to get from names to values. I thought for a bit that the the ability to retrieve bindings would help, but Ruby’s Binding class is utterly impoverished; the only thing you can do is pass it to eval. Bindings did become useful in abstracting the name capture into a method, however.
Wheres the PORC?
Taken together, these tricks let you define a system of equations with Plain Old Ruby Code like this:
delta = un_to - un_position timeDelta = ms_rev * delta big = timeDelta > threashold
There are some catches of course. You can sometimes use a bare number, but often it needs to be wrapped in a term object, such as when you want it named, or need to use one of the specialized operators which generates a compound term.
A day after I started, I had it generating a dot file for Graphviz. Everything since then has been tweaking, reverent awe of the shiny, a martial arts seminar, and errands. I’ve got a few changes in the graph that aren’t in the program yet. I released Disk Clock 1.0.4 and 1.7 before I started getting too crazy with the refactoring.
One thing I’ve consistently forgotten to do is write down the stuff I think about so I don’t forget it. Perhaps as a consequence, not too much has happened yet. The one significant change I’m looking at so far is tapping the threshold value before the timeMultiplier gets applied to delay; since the size of the update should already be getting scaled, it was kind of getting the multiplier twice. The big question is whether I in fact need to translate everything to time at all. The multiplier effect was one barrier. The other is the fact that some bounds get placed on the time value to keep things at sane values. I suppose I could translate the times back to revolutions. Other than that, it’s mostly been naming some anonymous intermediate values and deciding that ‘resolution’ was a better name than calcUnit. Another name I’m toying with is ‘timel’, as in time-element, in the same sense as to pixel (picture-element).