Clojure and Defold - questions and the lecture

That Clojure topic is nicely spread around the forums, twitters, youtube and the Slack. This topic tries to put some summary and organise things a bit.

Have questions? Fire away!

FAQ

  1. Defold editor is built using Clojure, but as of today you cannot write scripts in Clojure or extend the editor. The team is designing best approaches to Editor extensions, so stay tuned for more!
  2. Here’s a blogpost explaining why Clojure, why not Clojure and alike.
  3. We use JavaFX for the UI. We don’t use a Clojure wrapper.
  4. We maintain open development of the Defold editor on github.
  5. Defold engine and editor are closed source, but we’re doing our best to open more and more of what we’re allowed to.

Introduction to Clojure in 4 lectures by @mats.gisselson

The 4 lectures were delivered at King for internal purposes, but then we published those for you all to enjoy. P.S. we’re hiring Clojure fans :wink:

5 Likes

Some longer answers to people on the internets. Just assembling things in one place

What do you use to render UI? Is it JavaFX or some custom toolkit?
We use JavaFX for the UI. We don’t use a Clojure wrapper, just some helper functions. The views are mostly FXML and styled using CSS. The way we update the UI varies between views, but a lot of the time we simply replace a subtree with a new set of JavaFX nodes produced from a graph output. The scene view is OpenGL so it can preview shaders, etc. The console and code editor views are JavaFX canvas views where we redraw the entire view whenever something changes. We don’t keep any state in the JavaFX nodes, everything is derived from the graph.

In theory, is there a way to use Clojure(Script?) instead of Lua in Defold?
In theory I think you could put the JVM or a JS runtime in a native extension and glue with Lua. But it will not be pretty or particularly useful since the execution will be contained.

Do you plan to write a follow-up with more details on how you use Clojure for the editor? E.g. which libraries, how is the editor designed, how do you test it etc.
We did not plan, but if there’s interest we’ll try to talk the team it. Once there’s enough interest we’ll put ourselves into making a video on it.

4 Likes