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
Show parent comment
7
u/delta_p_delta_x 29d ago
'Raw pointers' aren't necessarily a bad thing. The idea here is less programming language syntax sugar, and more exposing a simpler programming model for GPUs.
Consider CPUs. They are fundamentally still Von Neumann machines, essentially unchanged from the 1960s. A unified memory exposing a list of instructions, and that same list of instructions operating on data in CPU registers and data in memory, and shuffling between the registers and memory if necessary. That's all CPUs boil down to. You can expose any programming language on top of that simple abstraction.
GPUs are complicated because of their much less open development, and because of what they initially were—essentially hardware implementations of the 3D graphics pipeline. They had (still have) 3D graphics-specific hardware intersection calculation, hardware rasterisation, hardware texture mapping units, and in terms of API, all of these have handles that can be individually tuned. Of course, we have shaders as well, but then we have to manually set up buffers and descriptor sets telling the shaders what those buffers all contain. The idea of GPGPU has been shoehorned onto this, and this is still the case.
Why should this be the case? Why can't we expose a more general programming model, and then special-case the video game and 3D graphics use-case? This is what 'modern graphics API' means, and less '
Rust,Box<>,Rc,Arc<>andstd::unique_ptr. Once a sufficiently general and powerful machine model has been exposed, we can write abstractions in any language. Again, see what happened with CPU programming—we moved to RAII, GCs, JIT VMs and interpreters, and more.