And going a little further, the windowing libraries will eventually call through the OS to the graphics hardware driver. The driver code controls the hardware so that the appropriate signals are sent to the monitor for you to see the line. In OP’s old DOS days, the OS was essentially single-process and the running process had much freer reign to access the hardware directly. Now OS’s must coordinate access to hardware to prevent corruption.
And FWIW, most windowing libraries, OS’s, and drivers are written in C/C++.