Fork me on GitHub
Joshua Suskalo15:11:13 This is still pre-alpha, but it's useful in its current state and I'm building stuff in my game engine with it. I'd love for others to check it out. It's a way to write shader code in Clojure (and I'll probably update it to work in CLJS too in future) for OpenGL, OpenGL ES, and technically WebGL, although as I said, it doesn't quite work in CLJS yet. It supports a good subset of the Clojure syntax, basically only lacking if expressions and lambdas, but that's because the compilation technique is a very naive recursive descent expression translator, and both of those features would require manipulation of the parsed AST before emitting the GLSL code.

❤️ 2
Joshua Suskalo15:11:19

It has some significant advantages over writing in GLSL because it includes namespaced identifiers and built-in dependency tracking, so you never need to worry about whether or not some library function you write for your shaders is being included (so no need for #include directives or anything), and the shader code is just inside your regular Clojure namespaces, living along side normal code.

Joshua Suskalo15:11:36

Oh and it supports macros.

Noah Bogart15:11:38

is there any way to have conditional expressions?

Joshua Suskalo15:11:53

Oh absolutely, it has if statements and cond statements, but they're statements, not expressions.

Joshua Suskalo15:11:07

Sorry, mistook your meaning. When I was looking last time I didn't find the ternary operator, but it's in there, but it's more limited than what you'd get out of proper clojure-style if expressions.

Noah Bogart15:11:08

my apologies, i interpreted your lacking if expressions to mean you can’t have conditionals in the clojure side

Joshua Suskalo15:11:19

definitely can have conditionals.

Noah Bogart15:11:31

okay, cool. this is very very cool

Joshua Suskalo15:11:56

I might just throw in a ternary operator on the ? symbol since that's the normal syntax for it and that way it's clear that it's not as powerful as if

Joshua Suskalo16:11:37

There we go, now there's a ternary operator

Joshua Suskalo16:11:45

Thanks! Yeah, I put in a reasonable amount of work on it. I really want to be working on a "v2" of the prototype that's a compiler that actually has intermediate steps between parsing (the clojure reader) and code generation (this library) that allows more complex things like type inference, monomorphization of generic functions and hof, defunctionalization, and more. But for now this does everything I need to make games because I'm perfectly comfortable having the sub-language be less powerful than Clojure for now.

Joshua Suskalo16:11:23

although in theory all those extra compilation steps could be done by sufficiently advanced macros on top of my code generation functions.