37. If Code Is Data, My Story Is A Database
I wanted to be organized, so as I wrote the screenplay for “Two Knights Defense”, I started putting parentheses around the text and before long my story was encoded as Lisp structures. Nested lists, to be precise.
The next obvious step was to write some scripts to process the structures. And by scripts I mean MCL Common Lisp code. The advantage of having a handy REPL, allowing for rapid development. Treating the story as a simple database, I wrote functions which would, for example, extract all the shots for a given location.
And that gave me my shot list for a given day's shoot. Easy peasy. Though not primarily graphics oriented, I’m still going to call this Lisp Graphics System 4 (LGS-4), as it did render out HTML pages.
As I have mentioned, the actual shoots were very smooth and productive, thanks to a great team.
After a day’s shoot, I would grab frames from the camcorder on my Mac, at a resolution of 640x480 pixels. I’d store the images as numbered files in the correct subfolder for each episode, and run the Photoshop watercolor filter on them as a batch action, resizing them down to 320x240 pixels in the process, which was “web sized” back then.
Finally, some more MCL code I wrote would generate the HTML pages of the graphic novel, with each page being a panel (image) with a dialog caption and navigation buttons. And the episode of the graphic novel was then ready to upload to a web server, for public viewing.
Which I never did…
Like most of my entrepreneurial projects, this one failed to take off. And for the life of me I can’t remember why I didn't follow through. I can only suppose that somehow I became convinced that the project could not succeed and put it aside. I have (to my regret) been very good at convincing myself of that. I do know that I had no business plan (as usual), and was hoping something would happen when I posted the content.
It irks me to no end that I don't have more confidence in myself and my ideas.
Design & Code
I noticed that a scene with a large particle system was running slowly, and became curious as to why.
So I downloaded and ran a profiler on the code, and was shocked — shocked, I say!— to find that 80% of the CPU time was being taken up by the random number generation code.
I decided to implement the above code, which is about the simplest, most naïve code imaginable. It is just a lookup table of random values, but seems at a cursory visual examination (of the resulting particle system) to be adequate to the task at hand.
The scene computation time went from 34 seconds down to 6.5 seconds. Not bad for a half-hour’s work.
Imagining numerical experts clutching at their pearls, I can only say in my defense that proceeding quickly along the path of least resistance has been a core tenet of this project from the start. Doing the “correct thing” can wait until we have a reason to do so.