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.

Table of Contents

Introduction

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.

Highlights

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.

In LMS, Clojure 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.

Where Clojure Fits

As we said above, Clojure is the language that powers many of the automatic tools in LMS, like rules applied, trigger-based notifications, agent walkthroughs, and Computation Fields. Clojure lets you take your business's policies and practices and encode them into actual action in the software. If you want to charge off any loan with less than a dollar in payoff, rules applied can make that a reality without any additional human action. If it's your policy that only loans who are less than two months delinquent can change a due date, then a walkthrough validation can prevent users from opening the walkthrough unless the loan meets those criteria.

This Feature Is Not

Let's take a second and clear up some possible misconceptions about Clojure.

  • Most clients don't write their own Clojure rules. If you've got people with the skills to write Clojure rules, you can use all of our automation tools on your own. But most lenders don't devote the time and energy into learning how to code with Clojure. Instead, they enlist the help of our customer success team, who can write rules for them.
  • Clojure isn't magic. It can do a lot, but every system has limitations. Clojure won't be able to solve every automation problem that you can imagine. But between rules applied, event-based and trigger-based notifications, webhooks, and agent walkthroughs, you've got a wide array of tools that can streamline your business operations.

What's Next?

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.


Written by Jackson Stone

Updated on March 28th, 2024

Have Questions?

Contact Us