Running OpenGL with Clojure vs Kotlin
This is my experience running some trivial code in LWJGL in Clojure and Kotlin
In my last post about my first week at RC, I wrote about my struggle to fit in and find my place while gaining foothold on what I should be working on.
Amidst a melting pot of talented, enthusiastic, and motivated programmers, I decided it was best to wait for my inner calling. Gradually, I remembered my once interest in real-time graphics that had led me into programming. Then consequentially, I stumbled onto Lua and game scripting and the LWJGL engine, most notably used in Minecraft. Since I’ve also been working on a WebVR project, I wanted to dig in. There’s one caveat — I haven’t dabbled in C and Java for quite a while, and I generally prefer not to work with either.
This naturally sent me looking for another JVM language that can play nice with LWJGL. Being at RC gave me an urge to explore and learn, so I decided to try out Clojure, a legendary functional JVM language based on Lisp. Since it’s a JVM-hosted language, I thought it’d be perfect for LWJGL, which is a Java real-time graphic engine.
It turned out that I spent two days unsuccessfully compiling some sample code rewritten in Clojure. Clojure is a super fun language to write in, and arguably very declarative. However, the niche is pretty small, and when it comes to finding resource online it’s quite limiting. For instance, there is only one Maven plugin for Clojure out there currently that everyone is using, and it hadn’t had any activity since mid 2016. If you google something about compiling Clojure in a Java project, you would see the same small set of results.
My having the chance to tried working on code projects others can use was great, but one of my 2017 resolutions was to focus more on building things and not tools. That means being language-agnostic and learn to embrace the pragmatic side of programming.
My decision to move away from Clojure for this project was driven by two things:
- It’s small community and limited support that makes Java interop pretty complicate for newcomers.
- OpenGL, like any hardware code, is procedural. Adding another layer of functional language just to call Java classes’ static methods most of the time doesn’t seem smart.