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

Logic puzzles help develop reasoning skills useful for programming, computer science, and anything you might do.

Find perfect and fun gifts for your loved ones that teach STEAM concepts and skills.

From light-up bow-ties to conductive thread, you’ll be the life of the party with this STEAM-inspired gear.

A free online test service reveals how much personal data your web browser is giving away.

Add more tools to your command line arsenal, including running mini-scripts and making backup copies.

Use switches to take your robotic creations to the next level.

An old classic with a electronic twist, featuring JavaScript and micro:bit.

Create the American flag in SketchUp using this detailed tutorial.

From lasers to supernovas, Berboucha is making science communication a priority.

Code can always be improved. Check out these tips to make you the best programmer you can be!

It’s a programming language unlike any you’ve seen before. Check out this symbolic system designed for mathematical calculations.

New, improved, faster, and sleeker - it’s Scratch 3, your new favourite block language!

Learn about the brilliant algorithm behind all of your GPS devices.

It’s free, comprehensive, and available on-the-go. This cool app helps you master Python faster than ever before.

Open up whole new worlds to explore through these interesting, diverse add-ons.

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

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