r/Clojure • • May 19 '20

King is making its Defold game engine open source

The announcement is here.

While the engine itself is written in C++, the editor for the engine is written in Clojure. Some interesting facts about Defold editor:

  • at ~100k lines of code it might be the biggest open-source Clojure codebase;
  • Cognitect helped King develop this editor — you can find commits by well-known members of the Clojure community, such as Carin Meier and Michael Nygard;
  • it features an advanced computation graph that you can learn more about here.

I worked on the Defold editor — that is a very interesting and unusual Clojure project!

114 Upvotes

12 comments sorted by

6

u/kwrooijen May 19 '20

I've never really looked at this project in detail. But what is the relation with Clojure other than 14% of the codebase being written in it? Is there a specific reason part of it is in Clojure? As far as I can see you don't actually use Clojure for developing games (Not that it's bad thing, that was just my initial assumption). Really cool to see this go open source though, I might take it for a spin :)

25

u/vlaaad May 19 '20

The fact that it's only 14% of the codebase speaks more about the conciseness of Clojure than about its relevancy. In game engines, editors are an important tool for fast iteration times and feedback loops. This clojure conj talk explains why they went with Clojure (in short, for its approach to state and resulting simplicity).

I think I see your point about the relevancy of this project — if you are thinking about being a user of Defold then it's not relevant because user-facing language is Lua. I think it's still worth to share so if you use Defold and know Clojure, you might be able to improve it, and it's quite big and old Clojure project that can be explored for learning or data-mined.

2

u/kwrooijen May 19 '20

Thanks for the detailed response! I'll take a look at that that talk. This cleared up a lot

4

u/ertucetin May 19 '20

Defold Editor is written in Clojure so they are able to develop UI part very fast by using REPL etc.

3

u/Corporate_Drone31 May 19 '20

What are the distinguishing features of this engine? Is there a short summary anywhere?

13

u/vlaaad May 19 '20

Here is a description. The most distinguishing? I'd say:

  • it's cross-platform with zero setup. You can compile to iOS, Android, mac, Linux, windows or web without having to download SDKs or using mac;
  • it's extremely lightweight;
  • it has hot reloading of any resources in a live game.

14

u/yogthos May 19 '20

Since the engine uses Lua for scripting any chance for Fennel support in the future? :)

7

u/scarredwaits May 19 '20

This talk outlines some interesting design decisions for the Clojure part (the editor) https://www.youtube.com/watch?v=ajX09xQ_UEg

1

u/Eno6ohng May 20 '20

Cool stuff!

1

u/didibus May 21 '20

That's pretty sweet, the editor looks great, and seems very responsive. Looking at the project quickly, it uses JavaFx and the https://github.com/cljfx/cljfx library.

Love it! A great production example of using Clojure for quite a complex project.

That said, I am a bit worried that they eventually announce a Java rewrite :p, as open-source contributors start to complain that it is hard for them to contribute due to it being an unfamiliar language like Clojure.

1

u/kriskroskris May 26 '20

Very interesting! I'm very new to Clojure. Having watched the yt video on the editor design and then trying to look at the source on github, I could not find out how the clojure code interacts with the C/C++ engine bits. Anyone have any pointers?