Sunday, November 18, 2007

Writing and Coding, Part 2: Self-Discovery

One reason people create things, art generally, but I'm arguing here that creation in itself of anything is an act of self-discovery. People say that writing is an act of self-discovery. Journaling is writing for no purpose other than self-discovery. But even writing that is meant for public consumption also often helps the writer learn about herself. Of course, the act of self-discovery—like creativity—is usually messy, and writers rarely let it out in public. I remember that for one class I wrote a lot of personal essays, a form that I really enjoy (hmm, a blog?). I would pick a topic to write on. I'd get started, heading in one direction. About half way through, I'd discover something about myself or about the topic I was writing on. Because of that revelation, the essay would take a sudden turn and head off in another direction. That was good; I counted on it, hoped for it. But it made more work for me, because then I would have to fix the first half, make the whole essay go in the direction the last half did. Part of the essay would be thrown away, but in the end, I'd learned something, and the essay was much better. I've heard about others who draft novels by throwing away the first, the second, and even the third drafts. That astounds me. Knowing how much work goes into a novel, I have trouble imagining throwing a draft away. On the other hand, it would probably make a better final product. I just wonder if more planning up front could take the place of making such drastic edits. So when I write for self-discovery, I don't know where the work is headed, and I have to be willing to cut drastically, even throw out whole drafts. How does this apply to programming? Supposedly, Richard Feynman had written on his chalkboard, "What I cannot create I do not understand." Part of the programming I do is to help me understand problems. I'm not by nature a detailed thinker. I prefer to stay in the clouds, thinking about things in an abstract way. Programming requires me to be specific, however, and to think problems through thoroughly. In solving a problem in code, I learn something about the problem and what it takes to solve it. In learning to solve a problem this way, I often work my way to a solution gradually. I open up a REPL (lisp read-eval-print loop) or Python interactive interpreter. I open up a text editor. I go back and forth between the two, feeling my way to a solution. Working this way is fun, but it is wasteful. As I'm doing it, I may attempt several solutions that have to be thrown away. And often, the code that results is a mess and has to be thrown away anyway. But at that point, I understand the problem and what it takes to solve it, and I can quickly write something much better. That process sounds like what I did with the personal essays. But I am learning something about myself on this? After all, I'm talking about self discovery in this posting, not problem understanding. It can be. I should probably write another post focusing on this assertion, arguing just it, but the act of creating anything teaches us about ourselves, if we're listening. How do we interact with the environment we're changing? How is our approach different than other people's? Why is this problem interesting, not that one?

Friday, November 16, 2007

Writing and Coding, Part 1

When I named this blog, part of the reason I chose this name was because I enjoy both writing and coding, and I wanted to talk about both. I didn't want to start two blogs, however, and later abandon both. I would rather just abandon one. (There are already a few abandoned blogs with my name on them. No sense adding to that number without reason.) The other reason is that I've always thought that there are similarities between the two activities, as well as big differences, and I wanted to explore these. A lot of people have written on these before or presented papers. This is just my take. This is a complicated, many-faceted topic, so it will take me several days to discuss this. Here's the plan:
  • Writing and Coding, Part 2: Self-Discovery
  • Writing and Coding, Part 3: Artistic Expression
  • Writing and Coding, Part 4: Test-Driven Writing
  • Writing and Coding, Part 5: Ambiguity
  • Writing and Coding, Part 6: Conclusion

Thursday, November 15, 2007

Expanding Short Stories

The other day, I mentioned that I was working on a short story I was calling "Voodoo Christmas." As I was fleshing out the concept, I realized a number of things. First, there are a lot of characters. Second, it's not so much about Christmas as it is about the year after Christmas, so there's also a long expanse of time involved. I've even considered it spanning a year. Third, it will just take a while to set up the plot, develop the characters, get things rolling, and tell the tale. Allow me to introduce the novella/novel Voodoo Christmas.

Wednesday, November 14, 2007

Editing Lisp

In which I decide to start hacking in lisp, and that rocks my editing world. The options for editing lisp in Vim are pretty limited. Well, let's be precise. Vim is a pretty good lisp editor, when you compare it with almost anything except emacs. There have been attempts to bring Vim up to emacs' level. There was a project to integrate ECL with Vim. It was part of a larger project, Slim-Vim to write a Vim interface to SLIME, the excellent emacs lisp development system. Unfortunately, Slim-Vim is dead. Both of its primary developers have abandoned it. According to their farewell emails, one now develops lisp using a commercial IDE, and the other uses emacs and SLIME. Generally, the advice for people like me is to suck it up and use emacs. You will be assimilated. Others do still use Vim for lisp, and I still prefer Vim for actually editing lisp. I've done some crazy, complicated things to get it to integrate with a running lisp system. The version of lisp I usually use, SBCL, doesn't include readline in the REPL ("Use SLIME," they say), and using it without command history, etc., is painful. So I would start emacs and SLIME, and I would start Vim. I would open the file in both emacs and Vim. Editing would occur in Vim, then I would refresh the buffer in emacs and feed my changes into SBCL. I know. Suck it up. Use emacs. Eventually, that will be how this story ends. First, I'm going to try Cusp, an Eclipse plug in for lisp development. Aside from being a lot prettier, I'm not sure what it has over emacs+SLIME. What do you use for lisp hacking? (If I get no answers, I'll assume everyone uses emacs.)

Tuesday, November 13, 2007

A Theory of Text Editors

When I started working with LINUX, I used GNU emacs. At the time, I was using some low-end hardware, even for the time. One day, I realized that my morning routine was to boot up, start emacs, and make a cup of coffee while I waited for emacs to wake up in the morning. That was insane. There was a lot I liked about emacs, but I needed something lighter weight. So I switched to Vim, and I still use it for all my editing needs. Vim messes with your brain. Once you've internalized the keystrokes, you're ruined for other editors. In the past, I would sometimes think that I needed to enter the 20th century and try some other editor—Eclipse, jEdit, or something. I'd install whatever it was I planned on using and tweaked it out, but I only used it at most a day, and the entire time I'd be thinking, "I could do this so much more quickly in Vim." Finally, I'd switch back just to make myself shut up. Of course, to really test drive a text editor, you need to give it a few weeks, so I never gave any of these a fair shake. I even tried viper once. This was a mode in emacs that used vi keystrokes and commands. I only used it about thirty minutes. It was too confusing. I remember the emacs keystrokes enough that I couldn't never quite decide whether I should use them or vi. I was less productive with it than I was with emacs by itself. My theory is that there are two levels to text editing: High-level semantics and low level syntax. I'll be abusing both of these terms, so let me explain what I mean by them. If you're editing Java or C# or Python or Lisp, semantics involves the libraries you're using. What properties does a Button have? What arguments does socket.socket take? Which comes first in elt, the index or the sequence? Eventually, if you use the language and its libraries enough, these questions go away. The other level is syntax. This involves editing at the character level: entering text, copying, pasting, moving, search-and-replace. This never goes away. In my experience, most IDEs are great at the semantic level, but poor at the syntactic level. They will answer any questions you have about the libraries and the language, but if you have to a sequence of keystrokes 1000 times, it is painful. Usually possible, but painful. On the other hand, Vim is brain dead at semantic stuff. At the syntactic level, however, once the keystrokes have branded themselves onto your brain, no other editor comes close. It tells you nothing about the objects, methods, or functions that you're using, but if you have to repeat something 1000 times, bang, you're done. So what's the point? Well, this posting actually started out as a discussion of editing lisp. It seems to have gotten derailed though. Lisp will have to wait for tomorrow.

Monday, November 12, 2007

Stalled Novel

Well, my novel's spinning its wheels right now. More precisely, I'm spinning my wheels instead of working on my novel right now. I decided that I needed another wrinkle in the plot. I decided what it was, but I haven't been able to make myself work on it since then. Instead of working on that, I'm taking a break. I've had some ideas for short stories, and I'm working on those. I'm tentatively calling the first one "Voodoo Christmas." Should be fun. I'll let you know if anything comes of it.

Sunday, November 11, 2007

Erlang Nostalgia

A few months ago, I wrote a system for controlling distributed processing using Erlang, but since then, I haven't really done much with Erlang. Finishing up that series of articles on Erlang reminded me of what fun Erlang is. Looking at problems concurrently is interesting and fun, and while I'm not always fond of the language's syntax, I still enjoy hacking in it. I'll have to do more Erlang in the near future. Something else for my to-do list.