Choosing a Computer Language

One of my favorite books is Gödel, Escher, and Bach: An Eternal Golden Braid by Douglas R. Hofstadter. It is a book about self reference in mathematics, art, and music. It is also about the challenge of creating a General Artificial Intelligence, although I don’t think Hofstadter ever explicitly says that. I had read portions of it several times before I managed to make it all the way through it from start to finish. That was partially because I was impatient and easily distracted but mostly because it was such rich fare. I would read a chapter or two and have to go think about it for a while and absorb it.

One of the things I learned from the book was Gödel’s theorem. Paraphrased it says that a sufficiently complex formal system can either be consistent or complete. I took that to mean a given programming language, which by definition is internally consistent, can not express all programs. This convinced me that there would never be a computer language that would be so good that we wouldn’t need any other.

Since then I have spent a lot of time learning new computer languages. I have tried to understand what kinds of processes they expressed well and what lay beyond their ability to express. Consequently when I sit down to start a new programming project, the first question that I ask is which language should I implement it in?

Some people will tell you that all sufficiently complex languages can be expressed as a Turing machine. This quality of a language is known in Computer Science as one that is Turing complete. The problem with such an assertion is that the Turing machine is so primitive that no one would ever write a complex modern application using only the operations provided by a Turing machine. Instead, they would write it in terms of more complex abstractions built on top of the Turing machine. It is these more complex abstractions that run afoul of Gödel’s theorem, i.e. being sufficiently complex.

This brings me to the point I was going to make about choosing a language. I often find that I can try to fit a square peg in a round hole by choosing a language that I am familiar with but that doesn’t support the abstractions of the domain that I am trying to model. Or, I can learn a language more suited to the domain. Or, I can use a language that is good at extension to support new domains.

Lisp is a language that falls into the latter category. From it’s conception it has lent itself to the creation of so called Domain Specific Languages (DSL). This is usually attributed to its simple syntax, the fact that Lisp programs are represented in the same fashion as Lisp data (a feature know as homoiconicity), and the availability of a macro facility that makes it easy to create new idioms within the language. The latter aspect, Lisp’s macro facility is at the heart of its extensibility. It is also one of the harder aspects of the language to master.

So, I find myself waffling between Java, a language that I have lots of experience with but that is very verbose and labor intensive to write, and one of the various dialects of Lisp that are much more concise, support incremental development, and have macro facilities that allow me to adapt them to the domain of my app.

One might think the choice would be obvious but it isn’t. Java has a very attractive aspect that it offers. There are libraries available to do just about anything you might imagine written in Java. This means that when you are writing an application in Java, you often find yourself spending your time first looking for a library that provides some functionality you require and then writing code to adapt that library to the rest of your application.

But wait, there is another way. Java compiles to an intermediate byte code that is implemented by the runtime on all the machines that run Java. This byte code interpreter is often referred to as the Java Virtual Machine (JVM). Other languages can be written so that they compile to byte code that runs on the JVM. These other languages then can make use of all the Java libraries that are available to native Java programs. Clojure, a modern implementation of Lisp, is one such language.

Now you must be thinking, “So what’s the issue here? Obviously Clojure is the language of choice here.” And you would be echoing what I keep trying to tell myself. The problem is, that Clojure is a very opinionated language. And while I agree with most of those opinions, the predominant one being the immutability of most data structures, the bad habits of my earlier career in programming make it difficult for me to embrace immutability and develop my apps in Clojure.

More precisely, when I am doing the exploratory part of developing my app, I spend a lot of time coming to terms with Clojure’s well intentioned restrictions. When I reach my frustration limit, I find myself going back to Common Lisp, the first Lisp that I learned, and trying to use it to prototype my ideas with the intent of porting my code back to Clojure when it is sufficiently mature.

Common Lisp has its own problems, chief among them, it is so big. I often find myself implementing some piece of functionality only to discover that there is a native implementation of the same functionality in the core implementation of Common Lisp. Not only that but there are a number (not quite as many as with Java but still quite a few) of libraries that also have better thought out and tested implementations of the functionality that I have produced on my own.

This sounds like a case of an embarrassment of riches and in fact it is. But it produces a kind of cognitive inertia that makes it difficult to get a project off the ground in the first place. I have managed to overcome that inertia to some extent and have found a collection of appropriate libraries to get me started on my latest app using Common Lisp.

Whether I wil be tempted to back port it to Clojure depends on how well it performs in Common Lisp. Steel Banks Common Lisp (SBCL) has a facility for compiling Lisp apps to native executables. That may end up being the way that I eventually ship the completed app and will make it so that I don’t need to put the effort into backporting.

If you’ve made it this far, thanks for listening. I hope I’ve expressed the issues that I’ve been struggling with clearly enough.

Stay safe in these dangerous times. Wash your hands, maintain social distance, stay home as much as you can, and wear a mask if you do go out. Tell your loved ones that you love them. I’ll talk to you again next week.

Practice What You Aspire To

I came to an interesting realization today. I have been writing a journal entry of at least seven hundred and fifty words every day for over ten years. It has helped me to become a better writer. It has helped me develop confidence in myself as a writer. In that time, I have also completed the National Novel Writing Month (NaNoWriMo) challenge of writing fifty thousand words in twenty eight days five times. I have also written a short story for the three annual anthologies published by the Downtown Writers Group of the Huntsville Madison County Library.

With all of that writing, the bulk of it has been the journaling. Writing a journal is not writing fiction. There comes a time when one needs to shift one’s focus to practicing the activity that one aspires to, in my case, writing fiction. That is not to say that I intend to quit journaling. It helps clear my mind and gives me a place to think about important things such as how I’m going to become the fiction writer that I aspire to become. What it does mean is that I need to make time daily to write fiction.

If you want to learn to do something well, you’ve got to practice. Furthermore, you’ve got to be careful that what you practice is what you want to do well. I don’t know why I came to this realization so abruptly. It was accompanied by a couple of well thought out journal entries where I wrote about what my goals were and how I intended to achieve them.

I’m sure that this burst of clarity will be followed by intermittent periods of struggle. The difference will be that I now have an inkling of where I am going and what it will take to get there. My practice will count for more because it will be deliberately tuned to achieving my ultimate goals.

I have to give a tip of the hat to my writing colleague, Laura Winter. She has recently taken the plunge, quit her day job, and embarked on a career as a full time author. She also has a side gig as a life coach. Her writing on her blog and the conversations that we have at our weekly “Write In” meeting have helped me come to terms with my path toward becoming a publishing author.

In as much as honing my authorial skills are a prime focus for me, I have another project that I’m working on. It involves some programming, some community development, and a lot of research. I will be writing about it here as it becomes more clearly defined. I don’t intend to let it obstruct my fiction writing though. In fact, it is a tool to help me keep track of the myriad details involved in writing a novel length piece of fiction.

Many people are saying we should be opening up the economy again. I understand that many people who don’t have jobs where they can work from home are struggling to make ends meet. It is clear to me though, that in spite of pronouncements by politicians, the pandemic is far from over.

Be safe. Wear a mask. Wash your hands. Stay home unless you absolutely have to go out. Maintain social distance when you do go out. Keep your bubble of frequent contacts small. Take care of your self and your loved ones.

Creativity is Hard

I finally came to a conclusion the other day. There is no process that is ever going to make creating easy. The fundamental problem is that whether you sit down and write a detailed outline or you just sit down and start writing prose, you have to imagine the story that you are going to write.

If you go the planning route, you still have to imagine what is going to happen in the story. You may put off some of the details until you start expanding on the outline in the first draft but you are going to have to create them at some point.

If you are a “pantser” (writing by the seat of your pants), you are probably going to wander around while discovering where the story happens and who the characters are. This will result in inevitable sections of the draft being cut from the first draft because they don’t really advance the story very well. Your reader is probably not going to be as interested in all the backstory you wrote while getting to know your protagonist as you are.

That’s not to say it is a total waste of time to do that exploration. If it helps you get a better picture of who that character is, the rest of the story will probably benefit from it. And I have a strict policy of not deleting those scenes entirely when I edit them out. They might come in handy in a different story sometime.

The same problem can arise when you are expanding your well planned outline. You may be writing along and discover that the plot you had planned so meticulously just isn’t working out when you actually write the story. The good thing is that there is less actual writing effort lost when you have to go back and rework your outline. There is still the effort that you put into coming up with the plot to begin with though.

I often write with Scrivener. The thing I like about it is that I can take a snapshot of my work, give it a label, and come back to it any time I like. I might find that the scene that I edited out of the beginning of the story actually has a place in the later part of it.

I talk as if I know what I’m talking about and I do to some extent. But the truth is, I’m still learning. I see myself improving but it is slow, hard work. But taking note of the things that I learn, as I learn them, is a good way to remind myself of them later when I get stuck.

Take care of yourself. Drink plenty of water, get lots of rest, wash your hands frequently, and keep social distance or at least wear a mask.

Tool Building vs. Tool Use: Maintaining Balance

I have been revisiting an idea I had for an application that I imagine I would like to use myself. I realized that I needed to survey the market to see if someone had written an app close enough in function to render my idea redundant. What I discovered was that the scope of the domain was much broader than I had any inkling of. I also discovered that it was largely considered a distraction by professional writers.

What I’m talking about is an app to help with world building. I had also considered that it would be useful as an aid to help prevent continuity lapses on the part of the writer. I have often named a character early in a draft only to refer to them with a different similar name later in the story. I’ve also lost track of what time of day it was in my story only to find that I had jumped from morning back to midnight in a couple of paragraphs.

I’m not really envisioning an outlining tool here. Rather I’m thinking of a loosely structured database, an oracle that can either answer my questions as a writer or remind me that I haven’t made that particular decision yet and offer to store whatever determination I decided was appropriate for future reference.

I thought it would be useful for such things as keeping track of who was where when, how far apart these places were from each other, the genealogy of the characters, and the timeline of the story.

This is motivated by the fact that my memory is not as good as it used to be and I don’t expect will be getting better the older I get. I’m by no means senile but I do suffer from that frustrating phenomenon where I know something but the harder I try to bring it to mind the more elusive it becomes. In particular, I have trouble thinking of proper names or other nouns. It is so prevalent that I have started calling it “nounemia”.

The fragile balance that must be struck by such a tool is to allow the writer to easily make note of facts as they are thought of without creating an opportunity to procrastinate. Many writers, myself included, have a tendency to be easily distracted and procrastinate when they are supposed to be writing. It typically happens when I want to look up some detail when I’m writing. Instead of placing a marker in the manuscript so I can come back to it and look the detail up when I finish writing for the day, I open a browser window and make my query of the great oracle Google.

Without exception, one thing leads to another and a query to find out if a 9mm was invented in 1926 ends up with me reading about Babylonian cuneiform writing a half an hour later.

The key to this problem is maintaining a balance. Scheduling time for world building and research and having the discipline to make a note of topics requiring research while you are writing without stopping the flow of words to look up the incidental fact when what you are supposed to be doing is getting the draft of the story down.

When I embarked on my survey of the existing world building tools I discovered that there were a number of things that were similar to the tool that I had in mind but none of them hit the sweet spot that I had imagined. I will continue my search and I’ll enlist the comments of my writer friends as to what, if any, tools they would like to see to help in their world building activity.

But in the final analysis I will build the tool that I want to use with the hope that others will find it useful in their writing. And I will have a second distraction to balance in addition to time spent on world building. That is I will be constantly tweaking my world building program. I will have to balance that with writing the story in the first place.

The Phases of Quarantine

So now we get to the part of quarantine where everyone is starting to get into the swing of the way this new life is going to go. We have gone through the phase where we couldn’t concentrate on our daily tasks from obsessing about the virus and whether our attempts to avoid it were going to be successful. We’ve made it through the first wave of cabin fever where we have discovered that, either we are more disciplined than we had feared, or we discover that when it comes to social distancing we can’t avoid a cheat here and there.

I’ve been pretty good. I have managed to restrict all of my trips to essential ones. We paid for year long free grocery delivery so the only reason I’ve had to go to the grocery is to get prescriptions from the pharmacy. It’s the one item they won’t allow third party shoppers to deliver.

I had to make a trip to Lowes. My toilet seat broke at the hinge where it attaches to the toilet. I bought a sturdier one. I also bought a set screw so that I could reattach the kitchen faucet. While I was there I bought sunflower seeds for the birds and the squirrels. And I had to buy some tomato plants or there won’t be any tomatoes later this summer. While no one of these purchases necessarily constituted an essential trip, taken together I think that they did. They made our lives considerably more pleasant anyway.

And then there is the stage that we are coming into now where it is becoming obvious that we are going to be practicing most of these preventative practices to some degree or another for the foreseeable future. I plan to wear a mask when I go out, stay home as much as I possibly can, and continue to work as long as possible, being thankful that I have a job in the first place.

As for my writing, I’m going to start scheduling my time more carefully so that I can write more while continuing to work full time at my day job. Maybe in a couple of years when the market has recovered and I’ve saved some more, I can start thinking about retiring from the day job and writing full time. Or maybe not. In either case, I will keep working to grow as a writer.

In this latest phase, we are forming into small pods of people whom we are willing to accept into our quarenteam. These are people that we trust to take the virus seriously and isolate from everyone not on our team. It has turned out a lot like the situation that one faces with venereal disease. When you sleep with someone you are sleeping with everyone they have slept with and all the people that those people have slept with, etc. It makes monogamy start to make more sense.

In the same way, when you add exposure to one more person to your team, you inherit exposures of everyone they have been exposed to. It’s actually quite scary, but at this point we have to take calculated risks. We have to have human contact. Zoom and texting and telephone calls can go a long way to treating our need for human company. But the closest friends are different. You have to find a way to see them, keeping social distance, of course. But sitting in the same physical space is important to the mental health of everyone involved.

That’s not to say that you should see them every day. It is a special dispensation that you ration like your last bottle of German sherry that you can’t find anywhere in the area. You use the quarantine experience to sharpen your appreciation for the things in life that it denies to you. You grow closer to the people near to you and try to be kinder than you’ve ever been before.

And in the end, you turn the quarantine into an opportunity to become a better person. As the world seems to fall apart in a chaotic mess around you, you focus inward and contemplate your strengths and weaknesses. You resolve to maintain this self awareness after the chaos starts to resolve into a new stability.

Wash your hands, wear a mask when you go out, stay at home as much as possible, tell those that you love that you love them, and be well.