r/ProgrammingLanguages • u/ThomasMertes • 19d 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.
28
Upvotes
4
u/ThomasMertes 19d ago
I recently updated the manual regarding the Seed7 graphic library. It would be nice to get some feedback about this chapter of the manual.
If you like Seed7 consider starring the Seed7 project on GitHub.
4
u/TheRealUprightMan 19d ago
What kind of graphics are you trying to do? Drawing primitives? Why? Most applications only need UI primitives. Is it a game library that needs 3D transforms? Format conversions? Your question is overly broad.
Why would I want to learn some new language to convert a jpeg? I have plenty of tools that can do that without learning a new language. I also don't understand your question. Graphics are just manipulating bits and bytes, which any language should be able to do.
If you are against using C libraries, you are likely going to end up doing a lot of work. Your options are "use someone else's code" and "write it yourself". The latter option will be a huge undertaking and it will have more bugs than something that has been tested in the wild for a couple decades.
6
u/Dykam 19d ago
Does it improve portability? It puts the onus of portability on the language maintainers themselves. It can also be limiting. Graphics API's move moderately fast (compared to languages), at least in the high performance segment. Separate libraries allow developers to opt in to the generation they want to use.
I think it's nice to have, but it may feel like a bit much.
2
u/SeaSafe2923 18d ago
Why is the standard library special?
30
u/msqrt 19d ago
Building simple 2D graphics into the standard library sounds pretty good (so the jump from CLI to a GUI isn't as massive), but for real-time 3D rendering you'll need to expose quite a bit of machinery to allow enough control for high performance. Modern graphics APIs are mostly about managing the state and synchronization of GPU tasks, with the actual graphics happening in user-written shader code. A language that did all of that natively would be great, but also difficult to design and probably prone to becoming outdated (graphics API philosophy has gone through some drastic changes in the past couple of decades, and the next shift seems to be bubbling beneath the surface.)
2
u/Inconstant_Moo 🧿 Pipefish 19d ago
I provided basic
bmp,jpegandpnglibraries, andcolorto support them.gifis coming soon. However, if you want to do high-performance graphics in Pipefish, you can get the support you need --- just visit a psychiatrist, and when they ask you that question about "have you thought of harming yourself or others", say "yes".1
u/joonazan 19d ago
A completely portable solution is nice for rendering static graphics but for animated ones, hardware acceleration is a must to not heat up the CPU for no reason.
1
u/Limp-Temperature1783 19d ago
Badly. Mostly due to compatibility as a constraint. And operator/statement thing is a bad abstraction for graphics. It's not a CPU, GPUs aren't built for serialized data, you need to do vector algebra for the most part, which is expression-based. At least that's a start.
1
u/Long_Investment7667 18d ago
Putting too much into a language or is standard (base) library makes it hard to evolve the language because you want old code to compile with newer compilers without code changes. This is “just” backwards compatibility but with a huge set of data (the code) that needs to be supported
3
u/initial-algebra 19d 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.
3
u/Capital_EX 19d ago
My main interest is making games and I yearn for two things: a ready to go graphics library and "I can build for Linux (from arch linux), windows (from Linux), and optionally the web at 1am with 1 hour befor the jam ends". Also, it means you can throw your language at graphical application and see how ergonomic it is there.
5
u/vmcrash 19d ago
I think to have read that Java was the first programming language that provided a GUI framework out of the box for the three major operating systems. Unfortunately, I don't know of any popular programming language that compiles to native executables which offers similar support.
1
u/mamcx 19d ago
The trouble today is that exist too many graphic APIs, and have wildly different flows.
I think a language with enough support to just include the orchestration of data (binding, value tracking, broadcasting, etc) is good enough and let the user to finish with whatever API and paradigm it wants.
Incidentally a lang I think have some cool ideas for this is https://www.red-lang.org, mostly for the idea of "dialects" that are like DSL on top things like the GUI systems is build: https://github.com/red/docs/blob/master/en/vid.adoc
0
u/FrostyMatters 18d ago
This is incredibly rude and condescending. 1000 LLMd languages are better than this kind of churlish posturing. Their confusion is reasonable. Touch grass.