« Beeminder home

Beeminder Blog

Bee in a witch's workshop

A magic spell is an incantation that, just by being incanted, makes something happen in the physical world. You say “avada kedavra” and someone dies — that sort of thing. Did you know that’s a literal real thing in programming and it’s called a magic string? [1] We use them in Beeminderland occasionally. The source document from which this blog post was generated uses them. That means that I absolutely cannot tell you what those magic strings are in this blog post. If I did it would literally break the blog and you would not be reading these words. Sounds dangerous, you say? Kind of! But it’s pretty ok with a couple ground rules:

  1. Only pick a magic string that can never possibly be uttered accidentally.
  2. Treat magic strings with some reverence and don’t casually type them out if you don’t mean to invoke them.

Like how in the Harry Potter universe people refer to “the killing curse” rather than actually utter “avada kedavra” in casual conversation.

Magic strings done right are, ironically, kind of the opposite of magic in the sense of the Anti-Magic Principle. [2] Namely, they’re a way to have something happen transparently, consistently, and predictably. Never accidentally, opaquely, or silently.

An example in Beeminder (besides the blog post ones we can’t tell you about on the blog) is certain hashtags in datapoint comments. You may know about pessimistic presumptive reports (PPRs) and how they automagically self-destruct when you enter an actual datapoint. Did you know that the mechanism by which they do that is to include the string #SELFDESTRUCT in the datapoint comment? And that you can include that string yourself if, for reasons (HT superuser Alys), you want any particular datapoint to self-destruct when a new datapoint for that day is added?

The worst anti-magic violation in all of Beeminder

Let us pause to tell you about the odometer reset feature. It’s so bad that I (dreev) want to punch my past self in the face for having been the one to come up with it. It’s the feature where, if your datapoint is ever zero we just silently, magically start adding your cumulative total so far to every future datapoint.

(There are mitigating factors: (1) It only applies to goals specifically created as odometer goals and so is not super likely to confuse normal users. (2) It really is exactly what you want to happen most of the time and is super handy for things like beeminding your way through multiple books and being able to always just tell Beeminder the page number you’re on. (3) We did this before we figured out the Anti-Magic Principle. We’d never implement something like that today.)

The way to fix that (coming soon!) is with, drum roll, another magic string in the datapoint comment. In this case the plan is to use #TARE. [3]

The way it would work in the book reading example above is you complete your first book and enter the final page count as your datapoint value on Beeminder:

^ 349 “finished Adventures of Tom Sawyer”

And then you pick out the next book and add a #TARE point like so:

^ 0 “starting Huckleberry Finn #TARE”

This can also work for other more literal odometers. Say a goal tracking your total cycled miles across multiple bikes and bike computers over the course of your life. And things like taring your weight graph so you can weigh in multiple times in one day without getting naked each time. Also nebuminding, where you want to beemind words added to a document but not let words deleted count against you.

We’re not saying a magic string in the datapoint comment is the best implementation of this tare feature, but it’s expedient and a huge step up from the anti-magic violating abomination that is the current odometer reset feature.

Footnotes

[1] See also in-band signaling which is mostly what we mean here. The Wikipedia article on magic strings is mostly about ways magic strings are abused. Possibly this means we should find a different term!

[2] Not the opposite of magic in the sense of “science”.

A mad scientist improves her fairy godmother's magic wand (From the Moste Excellent Webbe Comik, Girl Genius, by Phil and Kaja Foglio, et al.)

[3] Like when you zero a scale. There was some debate in the Beeminder Discord a while back about how common-knowledge the term “tare” is.

Tags: