Thank you for your interest in LoanPro. There are more articles in our knowledge center than are currently available to you. To view all content, please log in.

Intro to Clojure Rules

This article explains Clojure for people unfamiliar with the language, and even those with no background in programming.

Written by Jackson Stone

Updated on April 20th, 2023

Table of Contents

What is Clojure?

Clojure (pronounced like 'closure') is a programming language. Clojure is a means of expressing ideas so that a computer can easily compute them, but humans can still understand them if they know what they're looking at.

This article will explain the fundamentals of the language, and Writing Clojure Rules will explore how to write more complex rules.

Why Does Clojure Matter for LMS?

Loan Management System (LMS), our main software product, is built to let lenders customize and automate the software to suit their business needs. Many of the tools for customizing and automating the system hinge on Clojure.

Clojure in LMS, for instance, lets users:

I'm a programmer. Can you tell me a little more technical info about why you use Clojure?

We use Clojure for two reasons. First, Clojure already existed, and there are plenty of online resources that can teach you all the nuts and bolts of the language. We recommend starting with clojure.org, its official website. That website can tell you the second reason we use Clojure: It compiles to Java, so it runs fast and efficiently on our servers without the need for a custom-built compiler. (And if you're not a programmer but decided to read this anyway, a compiler reads a high-level programming language and turns it into something your computer can understand.)

 
 

Basic Syntax

When describing human languages, syntax refers to the basic underlying grammar rules that everyone follows: We say the book instead of book the. With computer or programming languages, syntax refers to the same basic principles, the underlying rules of the language.

A Clojure formula's syntax hinges on operands, operators, and a whole bunch of parentheses.

An operand is a number, value, or variable.

An operator indicates an action performed on the operands.

For instance:

English Standard Math Clojure
What is one plus two? 1 + 2 = (+ 1 2)

In the Clojure formula (+ 1 2) above, we have two operands, 1 and 2, and one operator, +, all enclosed in a set of parentheses. The operator always comes first, and tells you what you'll be doing to each of the operands that follow. With English, we might write this as a command: Add one and two. When we're adding more than two operands, we still only need one operator.

With this next example, you might see how Clojure is more efficient than standard math notation. Our earlier examples of (+ 1 2) and (1 + 2) look about the same, but the difference is more noticeable on larger equations.

Standard Math Clojure
1 + 2 + 4 + 5 + 5 + 6 = (+ 1 2 4 5 5 6)
((3 + 6 + 10 + 18) * (5 - 3 - 2 - 1) * (10 * 5 * 5 * 4 * 2)) = (* (+ 3 6 10 18) (- 5 3 2 1) (* 10 5 5 4 2))

Taking a closer look at that example, you'll notice how Clojure deals with multilayered equations. With a standard math equation, we might write (15 + 22) * (35 - 65), where parentheses show us that we should solve the two smaller questions before multiplying them together. Clojure similarly uses parentheses to show the order each operation should be performed in. This equation would be written (* (+ 15 22) (- 35 65)). Clojure works from the inside out: We first solve the two inner problems, then multiply them together.

Next Steps

Learning new ways to do math is certainly interesting, but none of the rules we've seen here would really be useful in LMS. Clojure becomes a valuable automation tool when we introduce more complex elements. Now that you understand the basic syntax, you can dive into Writing Clojure Rules and see how it can make your life easier in LMS.

Have Questions?

Contact Us