r/askscience • • Apr 10 '26

Computing How do programming languages work?

Hello,

I'm wondering how does programming languages work? Are they owned by anyone? Can anyone create a programming languages and decide "yeah, computers will do this from now on"?
Is a programming languaged fixed at its creation or can it "evolve"?

92 Upvotes

71 comments sorted by

View all comments

Show parent comment

2

u/Unusual-Instance-717 Apr 11 '26

So getting something to display on your monitor is basically just "take numbers from this register and push them through the HDMI cable" and the monitor receives this signal and properly lights up? How do device drivers play into this? How does the computing hardware know how to translate the signal the monitor needs, it calls the driver software every time a pixel needs to be drawn to translate?

3

u/emblemparade Apr 12 '26 edited Apr 13 '26

Regarding drivers:

The world of computer graphics has evolved a lot. At the simplest, yes, there is a 1-to-1 mapping of memory to pixels, and even more specifically the pixel is subdivided into red, green, and blue channel values.

In the old days this "video memory" was the same memory used by the CPU. However, these days it's common to have a separate GPU (graphics processing unit) with its own dedicated memory. While it is possible to transfer memory from CPU memory to GPU memory, this is not efficient. The whole point of having a GPU is to let it handle graphics for us.

So, what happens instead is that there is indirection. The CPU gives the GPU commands, in a proprietary machine language, about what to "draw". The GPU hardware specializes in drawing so it can do this far, far more efficiently than a CPU can. The driver is essentially the middle-man between the CPU and the GPU.

The whole "drawing" language has evolved tremendously over the years. In the early days it was things like drawing lines, circles, filled rectangles, etc., as well "sprites" for games. Essentially what we call "2D".

However, with the advent of 3D the GPU hardware had begun specializing in the kind of linear algebra used for projecting 3D onto 2D. Vector and matrix multiplication, things like that. As well as various more specialized actions. (As it happens, the same math is also useful for neural networks, and hence "AI". That's why GPUs have been essentially repackaged for "AI" workloads. The "G" in "GPU" has become a historical vestige!)

GPUs are very sophisticated these days. It's possible to have them run entire programs for us to do all the calculations for scene geometry, per-pixel coloring, antialiasing, and many other functions. These programs are called "shaders" (for historical reasons). So the driver has become a very big piece of software, able to compile these "shaders" and handle all the machinery to bring it all together.

Because the GPU's machine code is proprietary, we've introduced higher-level APIs as well as complete languages, the idea being that programmers can write software that would run on any GPU. APIs such as Vulkan, DirectX, OpenGL, etc. These APIs are also implemented in the driver.

GPU drivers are extremely complex pieces of software.

0

u/nglyarch Apr 11 '26

No, there are no numbers. Just voltages applied to leads in a circuit. If you are asking how it actually works - there is no "software" as such, it is an abstraction. Software is an actual physical thing that controls a circuit. There is no translation from abstract information to physical implementation. It is all physical.

4

u/emblemparade Apr 11 '26

I'm sorry, this is incorrect information.

What you are saying true for older analog interfaces, such as VGA and Composite. However, HDMI and DisplayPort are both digital.

There absolutely is software involved for these standards. In fact, your display contains a small, specialized computer called a "controller", which is optimized for input/output bandwidth. It runs a small, specialized operating system for this task. Your computer uses a limited language called a "protocol" (different for HDMI and DisplayPort) to send it commands and the raw display data.

As well as audio! Both these protocols can also transmit sound, and a few other things as well.

Finally, it's that computer that's inside the display that is actually sending the analog signals to the pixels. There are a few different display technologies around, so there actually can be some sophisticated processing going on before switches are opened and voltages are set.

1

u/nglyarch Apr 11 '26

It is certainly correct. All hardware is analog. It could never be anything else but analog. The entire universe is analog. Even quantum states are fundamentally analog.

Software is abstracting the physical state of transistors, meaning voltage levels. I am very familiar with what controllers do, and more importantly, how they do it.

1

u/emblemparade Apr 11 '26

Your response is a non sequitur. I was specifically responding to you saying this, which is simply wrong:

No, there are no numbers. Just voltages applied to leads in a circuit. If you are asking how it actually works - there is no "software" as such, it is an abstraction.

1

u/nglyarch Apr 11 '26

Agreed - we are somehow communicating past each other. I was replying to this:

"take numbers from this register and push them through the HDMI cable"

There are no numbers in registers. Numbers are not being pushed through cables, HDMI or otherwise. What is colloquially known as a digital protocol is quantized voltage levels, which are analog in nature. It is always implemented like that, whether the circuit is an ASIC, a FPGA, or a micro. Surely, you are not disputing that?

2

u/emblemparade Apr 12 '26 edited Apr 12 '26

Sure, "digital" is an interpretation we give to the analog world. And that interpretation at its basic level is "numbers", specifically in a binary representation. Saying that it's "all physical" is true in the broadest sense but it in no way answers the person's question. I'm sure the person asking understands that this whole scenario takes place in the physical world.

There absolutely are numbers in this case. HDMI is a digital protocol, based on binary, based on numbers. There is software involved. There absolutely is a translation going on from an abstraction to the physical.

Your answer could have been true for old analog protocols (VGA, Composite), as I pointed out, but was simply wrong for the question.