lemme learn ya a thing or two.

what is lisp?

Lisp (also written as LISP) is a massive family of programming languages made in 1958, centered around high-level list structures, and is the second-oldest programming language ever made. Lisp - short for "LISt Processor" - is a general-purpose dynamic type language, with dialects still in use today. Common LISP, Clojure, Franz LISP, Scheme, and Racket are among the more popular dialects still in use. No two dialects are exactly alike, but the concepts are the same for the most part. In this series, I'll be teaching you how to make your own Lisp, and center it around a "functional", general-purpose style.


about this tutorial series

For those seeking knowledge regarding bettering their programming skills, learning how C works, and/or learning more about functional programming, then this is the series for you. Even if you haven't programmed anything before, then this is for you. Learning how to make your own Lisp is a rite of passage for many great programmers, computer scientists, and specialists alike. If you aren't even a programmer in your field, it's still recommended that you give this a try. By the end of this tutorial, I hope you learn something, and I sincerely hope you'll put more thought into how you program outside of this series.


stuff needed

  • a child-like sense of wonder [optional]
  • text editor
  • C compiler of choice (I'll be using Clang)


putting together a basic prompt

Before we even get into syntax, parsing, etc. we'll need a prompt. Every dialect of Lisp (and most programming languages) uses one as a sort of baseline for things.


If you've ever worked in a shell on a command line (Powershell, Command Prompt, Bash, BASIC, Zsh, Fish, etc.), then you'll know what a prompt is. If you don't already, it'll immediately become familiar once ran. Go ahead and open your text editor, and let's get lubed up and ready to go balls-deep into this.


First, we'll need to include our standard I/O and standard library C headers. I'll be working within my Gentoo LiGNUx setup for this, so for those of you on Windows, please refer to your compiler instructions for extra headers you may need.



Now let's go ahead and define our buffer for our user input. This basically defines the limits for how much text/data can be entered at a time, so make sure it's memory-friendly (don't go overboard, but this is a pretty minimal program).



Alright, so let's go ahead with our main function. We're also going to add the argc and argv variables, as we're basing the program on user input. As a refresher, argc means "argument count" and argv means "argument values".


Let's also make sure the user knows the Lisp name, version, and if needed - how to escape the program. For escape, we'll just be a little lazy and say the normal EXIT shortcut for most shells, Ctrl+C. We'll also want it looking nice and tidy, so we'll start by clearing the existing shell buffer & formatting our text with C escape sequences.



Now let's add our centerpiece - the loop. Essentially, we'll have a constant loop operating for a user to place their input, press return, and receive an output based on the output, and get a prompt again.



Of course, name your Lisp whatever you'd like. Compile & run.



Cool, it runs! Now go ahead and type something in, press enter, and enjoy the rejection.



Perfect. The reason it tells you that is due to a lack of language entirely! It'll throw that whenever there's something like a typo, something undefined, or when there's literally nothing to process.


Go ahead and experiment with the prompt's code. Get comfortable with it, and seeing what specific lines do to affect the program as a whole. Tomorrow, we'll go ahead and go ahead and make the language itself!




tutorials on whatever, daily. doesn't have to be tech-related, but it mostly is.