r/ProgrammingLanguages • u/ThomasMertes • 29d ago
How programming languages approach graphics
Many general-purpose languages delegate graphics to third-party libraries (like SDL, Raylib, or OpenGL). Seed7 integrates portable 2-D graphics right into its standard library. This IMHO improves portability. I also thought about introducing operators / statements to do graphics, but until now I don't use operators or statements to do graphics.
29
Upvotes
View all comments
3
u/initial-algebra 29d ago
I'm more interested in languages supporting niche features for graphics/UI programming that can't simply be added with a library.
I will always champion for the inclusion of value recursion, which lets you declaratively construct cyclic graphs of objects, as opposed to just acyclic graphs or trees. Cycles come up all the time in UI, basically whenever you have some input element that can affect the output outside of its strict subtree. In the absence of value recursion, you need cycle-breaking tricks like "lifting state up" and mutating it imperatively from event handlers. Consequently, you can't generally encapsulate behaviour, and you are limited to "dumb components" for reuse, with behaviour bubbling up to the top level (e.g. Redux, Elm architecture in the limit). A great example of value recursion for UI is the Haskell library, Reflex-FRP.
Another, far more tricky feature would be support for writing shaders in the same language, enabling type/code reuse and automatic checking for pipeline state and bound resources.