If you want to make a programming language, learn LISP

I see a lot of you like to make programming languages.
Most do it ins python, some in C. Let me tell you something ā€¦

Learn LISP. It is the best for this type of work. There is a saying that every language converge to LISP eventually, because this is what LISP excel at.

Look at silly example:

;; Define a few commands
(defun print-command () (print "Hello World"))
(defun add-command (a b) (+ a b))
(defun repeat-command (n f) (dotimes (i n) (funcall f)))

;; Define a function to execute commands
(defun execute-command (cmd &rest args)
  (cond
    ((eq cmd 'print) (apply #'print-command args))
    ((eq cmd 'add) (apply #'add-command args))
    ((eq cmd 'repeat) (apply #'repeat-command args))
    (t (error "Unknown command: ~S" cmd))))

;; Example usage
(execute-command 'print)
(execute-command 'add 1 2)
(execute-command 'repeat 3 #'(lambda () (execute-command 'print)))

It is easy to define commands and even execution behaviour. It is probably not as readable as python, but it makes it easier and it is compiled.
I have not used LISP since my UNI days, and people here doing languages are inspiring me to look at it again without the hate if aunt student forced to learn it :slight_smile:

4 Likes

Iā€™m not familiar with the Lisp dialects, which Lisp is this?

so you know LISP? nice!

LISP looks like python but with some extra parentheses and some orders mixed up

Not really. LISP is different language, but all imperative languages have commonalities in terms of types, control and so on.