Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Janet loves Raylib

A topic by greenfork created Oct 12, 2021 Views: 455 Replies: 8
Viewing posts 1 to 4
(1 edit)

This is the ultimate way to program games. In my opinion.

I'm just starting but so far Janet looks good and Raylib is a good library to start although not so start-and-go attitude.

Janet: https://janet-lang.org/

Raylib: https://www.raylib.com/

Bindings: https://github.com/janet-lang/jaylib

Submitted(+1)

I’ve been using Janet/Raylib for my submission, and it’s been pretty decent so far.

For someone who never touched Janet, which its features are the best for gamedev? Which language can you compare it with? Also is it Lisp-1 or Lisp-2?

(+1)

It's Lisp-1. If you are interested in comparison with other lisps, the most other popular Lisp-1 I believe is Scheme. Compared to Scheme it is a lot more concise. And has polymorphic functions which work on several collections unlike in Scheme, where you have to always use the correct one, e.g. array-length, string-length.

A lot of inspiration is taken from Clojure with polymorphism and data-structures as function calls, for example, ({:a 1} :a) will print 1 since it is an access for the :a key.

It is also a compiled language, you have an option for native compilation. So unlike Clojure which is dependent on Java or Fennel which is Lua, you get both interpreted side for interactive development and compiled side for speed.

For gamedev you get cool macros as with most lisps. Then there's a good interop with C, much nicer then what you get with Fennel/Lua, you can probably inspect C code for jaylib bindings to get a taste of it.

That sounds tasty :) Will definitely give it a go (I’m a big fan of Fennel myself, even had a couple of jam submissions written in it). Although I can’t quite imagine a language more concise than Scheme, since (in my opinion) it is incredibly slick and well-designed. Still, I get your point about polymorphic collections. Thanks for your thoughts!

(+1)

I think I should elaborate a bit on the "concise" part. I don't mean that the design of the core is smaller than that of the Scheme. Although Janet was designed to be an embedded extension language as one of its use cases, I don't think its core is much smaller than Scheme, I would say it is comparable and roughly on a similar level.

But the writing is more concise in my subjective opinion. For example, you don't need extra parens for each `cond` condition, it just counts how many there are and every odd sexp is a condition, every even sexp is a corresponding action. Hash tables, arrays - very short notation for access and write. And records/objects - in Scheme it's like a tea ceremony with million rules and extensions, in Janet it's just a hash table. Many things are borrowed from Common Lisp as well (the good ones).

Submitted(+1)

I don’t have another lisp to properly compare Janet to. I believe it’s a Lisp-1, but I don’t know for sure.

For me, the thing I’ve liked best about Janet is that it is expression oriented, like many Lisps. It does have access to imperative features.

What I probably like best about Janet that seems kinda neat, at least compared to ohter languages I use, is that it makes it very easy to create packed executables without any external packers. In fact, if Jaylib had access to the Raylib functions for loading Sounds/Music/Textures from memory, instead of from files, I could have made my entry contained entirely inside a single executable.

That’s an interesting feature for sure. Thanks for sharing!

Submitted(+1)

For Janet, that functionality is built into the tooling. It basically just runs the top-level statements, and then marshals the resulting image, and then bundles that into the executable that gets compiled. It does mean that you can’t, for example, have any Raylib types as top-level variables if you want to take advantage of that, unless you spend some time writing marshal/unmarshal functions for them.

For Sparkworks, I ended up saving the files into the executable, writing them out to disk, and loading the relevant resources from disk, and then deleting the files (except the music file), so that I didn’t have to bundle assets outside of the executable.

I like fat EXEs for situations like this.