# Make a Lisp in Nim

DevFeed: [Make a Lisp in Nim](<https://devfeed.tech/articles/make-a-lisp-in-nim-30824.md>)

Original publisher: [Read original article](<https://hookrace.net/blog/make-a-lisp-in-nim/>)

Published: 2015-03-03T23:00:00Z

Content type: tutorial

Language: en

Sources: [Dennis Felsing](<https://devfeed.tech/sources/dennis-felsing.md>)

Topics: [Nim](<https://devfeed.tech/topics/nim.md>), [Lisp](<https://devfeed.tech/topics/lisp.md>), [Code](<https://devfeed.tech/topics/code.md>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [make](<https://devfeed.tech/topics/make.md>)

Tags: [benchmark](<https://devfeed.tech/tags/benchmark.md>), [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [build](<https://devfeed.tech/tags/build.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [lisp](<https://devfeed.tech/tags/lisp.md>), [nim](<https://devfeed.tech/tags/nim.md>), [programming](<https://devfeed.tech/tags/programming.md>), [writing](<https://devfeed.tech/tags/writing.md>)

## AI overview

The article describes implementing a Lisp interpreter in Nim by following the Make a Lisp guide. It explains how to build, run, and test the implementation, and reports rough benchmark results comparing Nim with several other languages. The author notes that the measurements are not optimized or definitive.

## Source excerpt

I spent the last weekend working through the amazing guide for Make a Lisp, writing a Lisp interpreter in Nim. The final result just made it into the repository. Running the Nim version is pretty simple. You need the Nim compiler from the devel branch and nre which can be installed through nimble. After installing those you can build and run the MAL interpreter: $ cd nim $ make # OR $ nimble build $ ./stepA_mal Mal [nim] user> 12 12 user> (+ 2 3) 5 Running the tests: $ cd .. $ make "test^nim^step1" # A single test $ make "test^nim" # All tests $ make "perf^nim" # All benchmarks There is a nice presentation in MAL about MAL you can read: $ cd nim $ ./stepA_mal ../examples/clojurewest2014.mal And you can run MAL implented in MAL itself using the Nim interpreter: $ ./stepA_mal ../mal/stepA_mal.mal Mal [nim-mal] mal-user> The benchmark results from Joel Martin, the author of MAL, don't look bad for Nim. Edit: Note that these are just rough measurements to see that the Nim implementation is doing fine. Don't judge the other languages for their numbers, which may not have ideal implementations performance-wise. In the short benchmarks Nim is the fastest, in the long benchmark only the JVM can beat it. I didn't really try to optimize and oriented mostly on the Python implementation, which is quite a lot slower as you can see. So it's pretty nice to see idiomatic Nim performing well: perf1 perf2 perf3 macros math macros ms ms iters/sec java 6 24 17969 scala 47 87 15963 nim 1 1 11121 ocaml 1 3 7063 cs 10 11 5414 vb 12 13 4523 rust 2 5 4084 c 1 4 3649 go 1 6 3048 racket 3 10 2461 coffee 5 11 2326 js 6 14 1726 ruby 4 15 1255 haskell 4 14 1163 clojure 11 23 1174 forth 9 29 563 php 13 51 331 python 14 51 304 bash 1673 9000 276 perl 18 69 215 ps 41 332 48 R 116 490 28 miniMAL 779 3448 4 matlab 1688 5844 2 make 3427 28453 0 I also didn't really aim for a low amount of code but rather good readability, but it may still be interesting to look at. I guess Nim's size being so close to