
Getting started with OpenGL in Elixir - indatawetrust
https://wtfleming.github.io/2016/01/06/getting-started-opengl-elixir/
======
angersock
If anybody needs it, there are at least two 3D libraries for Elixir--graphmath
and vector.

------
xiaoma
Why? Why would one use Elixir for OpenGL?

~~~
angersock
Here's why I'm interested.

Most modern engines are fighting the fight of how to deal with multiple cores
--how to create microtasks that can be scheduled across worker cores, how to
handle task stealing, how to implement lots of independent actors without
bugs, how to do hot-upgrading of code, how to handle networking, and how to do
all of this with a user staring at any frame-to-frame inconsistency.

Erlang/OTP and Elixir have those problems decently well solved. It makes sense
to cordon off the graphics into just enough C/Rust to get OpenGL up with a
scene graph or whatever, and then leave the rest of the game logic in a better
language.

The idea of being able to just use thirty years of language research on a
pragmatic and simple platform (the Erlang/Elxiir BEAM) is _very_ intriguing.

My next big project in Elixir is probably going to be a proof-of-concept for a
physics engine. With that done, everything else is pretty obvious.

If anything can realistically break the death-grip of C/C++ on the industry,
this might be it.

~~~
felixgallo
As a bona fide erlang head, let me instead suggest that you direct any such
efforts at [http://www.ponylang.org/](http://www.ponylang.org/) \-- in which
you can have the actor model, but do low level programming, with high
performance, while being as safe as Rust and having (in my personal opinion)
better affordances.

~~~
angersock
At the risk of sounding brusque, my brief survey of Ponylang at your link
doesn't really interest me. I don't really care about type correctness and
magic, I don't really need an alternative to Rust, and it still fails to
easily solve the "How do I provide strong isolation between my code and the
rest of the world?"

The fact that the language loudly claims that _" Incorrectness is simply not
allowed. It's pointless to try to get stuff done if you can't guarantee the
result is correct."_ and then talks about FFI to native C code kinda strikes
me as hubris.

Erlang/Elixir is more "Hey, fuck it, here's NIFs, but they have clear
drawbacks which sometimes are outweighed by benefits" and "Here's ports, which
_Do The Right Thing_ if you want to call out to a native application that can
explode and not hurt anything else."

The other useful bits, networking and whatnot, seem way better developed in
the other ecosystem as well.

~~~
felixgallo
You're right on all those points. The reason, which I didn't explain enough,
that I'd suggest you'd look at pony, is that erlang's scheduler and
calculation model are great for routers, but less great when you need to do a
bunch of matrix transforms within a 120Hz frame budget. Pony compiles through
LLVM and has, e.g., native integer types, so is a little closer to the
standard OpenGL user sweet spot, where tons of fast math matters and
everything is pretty strongly typed.

That said, if you get it working on erlang, so much the better, and good luck
whichever way you go, sounds awesome!

~~~
angersock
And thank you for the reference!

Like I said, not quite my use case, but I may find a use for it yet. :)

