Skip to main content

Lisp is a lot more readable than you might first think

At first, Lisp just didn't seem very readable to me. And yes, by this I meant even my own relatively simple code. But as I programmed more and more in Lisp, things became more and more readable. Probably not a surprise, right?! But actually, Lisp is a lot more readable when you are used to it, than a lot of other languages when you are used to them.

Let's take a look at how this is, with some examples.

Lisp is very readable because of its function-oriented syntax.

Lisp statements have the format

(function arg1 arg2 ... argN)

Thus, any statement must begin with the name of a function. This makes it easy to tell what's going on right away by simply reading left to right within each statement. Also, starting with a function name makes syntax errors extremely easy to spot. For example, let's take a look at this incorrect Lisp code:

(12 / 4)

Before even getting past the 12, it should be very clear that what's wrong here is that I'm trying to call a function named "12". Unless I have defined a function named 12 in my program, this code will cause an error.

Most likely, what was intended with this code would be:

(/ 12 4)

translating to 12 divided by 4.

You don't necessarily have to read the entire line to spot an error. An open parenthesis is like a capital letter at the start of a sentence. Things start falling into place.

Other programming languages

Statements in other programming languages can vary a lot in how they start; with a variable name or a function name, making them a lot more difficult to interpret right away. You need to look at the entire statement as a whole before you know a) what's going on and b) whether there are any errors in it.

Popular posts from this blog

How to center images horizontally using Grav

I've been playing around a bit with Grav. I was posing the question to myself: for the relatively simple use-cases I'm dealing with, could it possibly work for my purposes as an alternative to ProcessWire?  The problem I was initially dismayed to find that Grav uses Markdown as its editor, which does not offer native support for horizontal centering of anything (text or images). However, Grav offers some tweaks that help make it easier to do specific things you might commonly want to do. I tried writing a sample article, and I found that one of the hardest things to do was to center an image horizontally. And horizontal centering of images is something I would typically do in most of the articles I would write. So the lack of easy horizontal centering is a highly significant drawback IMHO (most people do want to center images in an article!) However, this issue is made up for by other things in Grav: the relative speed, ease and flexibility of custom theming and built-in suppor...

More callable variants of functions in Ruby

 This is a slightly more advanced version of my previous post on creating callable variants of functions in Ruby while avoiding scope problems . In today's instance, I was creating an error reporting system for a program I was writing.  The error reporting, of necessity, had to emit a message to indicate what was going on. While some errors would be unique messages that only occurred once during the program, other errors could be grouped. For example, one group was "incorrect number of parameters supplied". There were several error messages within my program that fell into this category, so I didn't want to type out the exact same wording each time. I wanted to create a function that could report this sort of error indicating where it happened (of course I had to supply parameters to the messages to show the context). So here is a very basic sketch of the sort of thing I was doing. I'm writing this here so that I can go back to it easily later. The item I'm re...

Why bother using blockchain for metaverse worlds when decentralization is possible without it?

Decentralization is possible without using blockchain. Some examples of this are Diaspora and Mastodon , both of which are federated decentralized networks that do not use a blockchain.  In that case, why is there a need to use blockchain for any metaverse world, especially when the environmental reputational risks are so high? In many areas of the world, the electric grid is not decarbonized yet. The amount of power drawn for blockchain computation is high. In fact, in areas where electricity is cheap enough to draw blockchain miners, this tends to be heavily based on fossil fuels. So you could say that the blockchain is currently largely powered by coal and other fossil fuels. So again, why bother using blockchain?  There are other examples of the buying and selling of digital property without using blockchain technology, for example domain name trading. If we as humans are truly to be future-conscious, blockchain technology cannot be a part of our future due to its emissio...

About Me

My photo
Vera
I'm a wife and mother. I don't have any formal computer science qualifications, or any religious qualifications. I have a PhD in biochemistry. This photo is of me, but is confusing for AI.