Enyert Vinas

Posted on 2nd August 2022

Five amazing opportunities that Clojure brings

news-paper Clojure | News |

After writing a few articles about Clojure and working with this stack for a while, I have had a lot of opportunities to do some experiments, use different tools and libraries from the Clojure community, bring some of my ideas to code, and participate in interesting projects.

All these different experiences were extremely important because they brought to me valuable opportunities to learn and have fun in the process.

For this reason, I want to share these experiences with you and perhaps give you new ideas to do some discovery and extend the domain of Clojure to even more use cases.

First opportunity: Functional Programming

This is the obvious but one of the most important. Contrary to the opinion of some people, Functional Programming (FP) provides an easy way to get solutions for real problems.

The power to compose functions in many different ways and use them as first-class citizens is invaluable because it almost forces us to think about separating the problems into small pieces and using them to provide an elegant solution to complex problems.

Clojure is a Functional Programming language, so it provides these features and many others to our hands. So if you want to have some fun and learn the language, don’t hesitate to install it on your pc and get your hands dirty!

Second opportunity: Interaction with JVM and even other languages!

The JVM(Java Virtual Machine) is a managed runtime environment used to run Java classes on multiple platforms. We can see it as an abstraction of an underlying machine regardless of the operating system on which our program is running.

Given the fact that Java is one of the most used programming languages, it is a big plus to have the capacity to interoperate with Java libraries and tools.

The interoperation with Java is not difficult at all, you can find more information here. But Java is not the only language that can be used from Clojure. We have many projects dedicated to providing interoperation with other programming languages such as ClojureDart for Dart, libpython-clj for Python, and many others.

Here I want to present my experience with ClojureDart in this post. This contains a basic sample using the interop between Dart and Clojure. In this opportunity we even used Flutter, and the sample worked beautifully on web and mobile devices.

I think this opportunity is super important because it shows that Clojure is always open to interacting with other technologies so the domain of our favorite language gets bigger.

Third opportunity: A different perspective on data

If you have been dreaming about data as a code miracle, then learning Clojure will be a wonderful experience.

In Clojure, everything is considered data and, can be treated as data. Even the Clojure compiler is a data-programable engine that takes Clojure data as input, and returns Clojure data as the result of the compilation process.

To mention another scenario, let’s talk about ClojureScriptClojureScript is a compiler that takes Clojure code and targets JavaScript.

If you come from Javascript and have used React, then you probably know that state management can be hard to understand. And the different implementations and be tricky to implement.

For these programmers, I recommend trying ClojureScript and re-frame. You will be amazed at how easy can be to state management with this stack.

I want to point out that data is always the core of any business, so if you use a data-centric language it is always a good way to start.

Fourth opportunity: Game Programming (one of my hobbies)

Game programming is one of my favorite hobbies so I have been trying different game engines such as Unity, GodotlibGDXpygame, and so on. Also, I have participated in various game jams and published a couple of games on itch.

Having said this, the next logical question is: “Why don’t try to use Clojure to do some game development?”. Well, I tried it and it was a great experience as well. Let’s see uncover why. 

First of all, I know certain limits of the language and understand the preference for other technologies more focused on game development. However, my curiosity is always mandatory so I started my research and tried some different approaches that I would like to share with you.

I started my journey with ArcadiaGodot. For this one is required to install and configure Godot with Mono support. I have to say that this was the most simple approach and I enjoyed the way to interact with Godot provided by ArcadiaGodot. Leading with signals as first-class citizens were amazing and the experience to use Clojure for the game rules was great as well.

The second option that I tried is play-cljc. This is a more Clojure’ish tool and the sample that I created ran on my windows machine but it wasn’t possible in my Mac M1(100% compatibility issues).

Finally, I tried Flame Engine. This is a 2D game engine made on top of Flutter. I tried this one because my previous experience with ClojureDart and Flutter.

This worked for me for every platform I tried, but for using Flame Engine is required the implementation of some abstract behaviors, so doing this with ClojureDart required a lot of research from my side.

With this opportunity, I discovered that even my hobbies can be covered with Clojure which is a way to enjoy and sometimes learn new Clojure concepts in the process.

Fifth opportunity and wrapping up: The Community

I think this opportunity is the most important because in technology we always have something to learn. Even when we are teaching other people, we learn in the process. So, sharing knowledge and experience with other people is always vital if you want to adopt, learn and improve your experience with technology topics.

I can share a few places to enjoy the Clojure community but I am sure there will be more. This factor depends on the particular use case of every clojurist. Anyways, I am listing the following ones:

  • Clojurians Slack. A lot of people are here with different knowledge and experience levels.
  • Clojuverse. This is a repository of interesting topics where you can participate by asking questions, providing answers, etc.
  • Lambda Island. Here you can find a lot of screencasts to learn about specific topics related to [Clojure].
  • Flexiana Blog. Flexiana is the company publishing this post and I am part of the developers of the team. We are always eager to share knowledge and talk about technology, so don’t hesitate to contact us.

As I mentioned before this opportunity is the most valuable, so I invite you to learn Clojure, create new projects, participate in forums, assist in conferences, share your adventures with our favorite language and find more wonderful opportunities to learn.

I hope you enjoyed the reading and happy hacking!