Day 6 – Implementing for unknown

As designers and developers we have to accept the fact that whatever we create will used in ways that we did not anticipate. Now what?

While working on SlothCMS there were two moments when I was implementing a compiler1 from one language to another. Both cases had HTML as the target language. In both cases there was a time to decide which control structures will be part of the language.

If  and for  were easy choices because they are predictable how they will be used. If  can be reduced to a question “should this element be here?” and unless someone sets it to always true  state it’s fairly safe.  For  loop is similar because it will behave predictably even though as a compiler developer and a language designer I don’t know how many items an array has. There will always exist an end.

Implementing while  loop is not as predictable or simple. The nature of the loop is that no one knows how many times the insides of it will be executed until it’s done (if it reaches the end). On one hand it’s pretty handy as a future user of the language. On the other it gives me a headache because people will expect that they will be able to use conditions, not just iterable objects.

When I choose to allow conditions I need to spend more time developing how user defined variables work. Priorities aside implementing variables is more time and energy consuming consuming than one would expect.

Other aspects are how much freedom should the user have and how to present errors. Both of these questions require some sleep to figure out.

  1. Definition from Wikipedia: A compiler is a computer program that translates computer code written in one programming language (the source language) into another language (the target language).