www.BrettDaniel.com

Untitled

Those readers of the geekish persuasion may have had a good laugh while reading this post about the scripting language I've been developing at work. "Why is he using regular expressions," they probably chortled to themselves, "when he could accomplish the same thing by parsing out the script into a tree structure and evaluating it recursively? It would be easier to modify, a lot more scalable, less prone to unexpected bugs, and far more elegant!"

Well, my dear geeky readers, because I'm still working more or less on an experimental, proof-of-concept basis, I was able to accomplish just that over the past few days. By doing so, I've given the language room to expand from the five initial functions I mentioned to dozens and possibly more. This was the plan from the beginning, but a tree structure handles it in a far better manner than was required with regular expressions. Instead of having the language processor go out and search for functions to evaluate (an expensive process, to be sure), "function nodes" and the related "operator nodes" call backend functions only when encountered in the final script evaluation. The process is nearly the same when the evaluation encounters "data nodes" which simply return a value. In this case, a nodal structure provides another benefit: all the data is represented internally. This means the language processor doesn't have to parse values out of a string every time it needs them.

These and other benefits all add up to far more efficient script evaluation. Just a handful of initial tests indicate that this new implementation runs at least twice as fast as the old version. While I haven't yet reached a point where I can test it heavily, I expect it will fare even better with more complex scripts.

It's from doing stuff like this that makes me enjoy being in computer science. By the end of the summer, I will have written a scripting language. How cool is that?