beanz Magazine

Clojure (or Common Lisp)

A language from the Lisp family with simple syntax and a new approach to writing code.

The language we’ll be talking about this issue, Clojure (said as “closure”), ties together a couple of ideas we’ve introduced in prior issues.

Two issues ago we talked about Kotlin, a language that ran on the Java Virtual Machine (JVM). Languages built on top of the JVM have a couple of advantages. The first big one is that it helps the language run on any platform where Java can. That effectively means everything except iOS devices. The second one is that languages that use the JVM get access to all the library code that comes standard with Java, which is not a small amount of pre-written code you get to use.

The other idea we’ve mentioned is macros, which we briefly introduced when talking about Julia. Macros are, essentially, code-that-writes-code. A language that has macros allows you to expand the language with things like new control flow constructs, radically different syntax, or even big features like object oriented programming.

Clojure, as you might have guessed, is a language that runs on the JVM and has macros.

Clojure is a part of the Lisp family, a very old and storied family of programming language that go back to the 1950s! The Lisps include a number of languages still in use today such as Common Lisp, Scheme, Racket, Emacs Lisp, Pico Lisp, and of course Clojure. Even Julia could be considered a part of the Lisp family, though it looks fairly different.

One of the things that basically all the Lisps have in common is a very simple syntax, which makes them both easy to learn and makes it easier to write macros. This usually means Lisps have prefix syntax with lots and lots of parentheses. For example, in most Lisps adding two numbers looks like (+ 2 3) instead of 2 + 3. If you remember from the last time when we talked about Julia, there’s a cute way you can estimate pi by using random number generation.

Become a subscriber and get access to the rest of this article. Plus all our magazine articles.

Stories also include numerous links to help parents, kids, and teachers learn more. Get access today at just $15 per year for online magazine only or $29.99/year for print + online ($35/year outside US)!

Subscribe Today!

Also In The April 2018 Issue

Who chooses new emojis? And what’s coming in the next batch?

Build your own voice-controlled digital assistant with a Raspberry Pi and an analog speaker.

Using Scratch and some simple vector math, create your own Boids algorithm to simulate the flight of birds.

6 hands-on STEM camps and clubs to join this summer.

With these new high-tech cards, public transit is easier than ever.

Slice digital photos into pieces and have fun pasting them back together.

Meet the cute little bot that’s helping scientists understand the courtship of frogs.

Dive into the nitty-gritty of game-making with this popular Python library.

Learn about the Native soldiers and the creative cypher code that helped win WWII.

Our cars aren’t quite driving themselves, but they can help us park and avoid collisions.

Make your games even more exciting with custom user-created content!

A clever teacher uses our favourite round robot to bring books to life.

Learn how to search through blobs of text with speed, accuracy, and elegance… like a ninja!

Links from the bottom of all the April 2018 articles, collected in one place for you to print, share, or bookmark.

Interesting stories about computer science, software programming, and technology for April 2018.