Close

Programming in English

graham-trottGraham Trott wrote 08/27/2023 at 12:07 • 2 min read • Like

When I graduated in 1971 and started work, computers were still mostly huge, remote entities behind locked doors and programmed with punched cards. I hated them. So on the time-honoured principle of bashing square pegs into round holes, my first employer put me on a computer project. To save the effort of learning and remembering everything I immediately set about creating shortcuts to make life simpler. This approach served me well and has stayed with me ever since.

Something that always intrigued me was that although we think in English, no matter how powerful computers become we have to translate our thoughts into alien, un-human forms in order for them to understand us. The programming languages we are expected to use - JS, Python and C - are heavily symbolic. To me, a good test is "Can you read it aloud without sounding like an idiot?", to which the answer is always "No". There are exceptions; SQL and Apple's HyperTalk  go a long way to human-readability, but they are not general-purpose programming languages.

So I asked myself "How hard can it be to write a compiler for something that looks like English?". Limiting myself to a syntax similar to a cooking recipe, and with no knowledge of how compilers should be built, I went about the task. I wrote the first version in Java and used it for a number of multimedia projects, then more recently rewrote it, first in JavaScript then in Python. The first of these is a single JS file in the browser HEAD, which compiles scripts very quickly on the fly and runs them. I've built several websites using it and in each case the performance is good, with page load times as low as a second depending on how the code is organized. Since no build tools are required, development and deployment are extremely simple. Similarly with the Python version, which lives on the command line and offers the ability to easily create elaborate shell scripts.

As I'm getting on in years this kind of programming suits me fine. I don't have the mental stamina to learn React, Angular and the like. I can return to one of my scripts years later and still easily figure what it's doing. Instead of being faced with a wall of impenetrable code, I can read it easily to see what's happening. As psuedo-code, its performance will never match that of a fully-engineered system, but for a huge number of projects performance isn't an issue. After all, computers still keep getting faster with every passing year.

An e-book on how to write a language of this kind can be found at https://easyaspie.netlify.app/. There's also a Kindle version available from Amazon.

Like

Discussions