-1

Some libraries claim not to be linked to an OS specifically, or the standard libraries of a language available on several OS which are by their nature in this case.

Do they still use the API of the OS on which they are ultimately running?

  • There's no such thing as "the OS programming language". – Ben Voigt Jul 27 '19 at 05:26
  • @BenVoigt All right, what about the rest? –  Jul 27 '19 at 05:28
  • 1
    That "Ask a Question" button, it really does mean One Question. But my answer about windows can be generalized to all the other topics. For example, file access... all file access must ultimately use the OS, but a language or library can layer on top of that with buffering, encoding and decoding of objects. etc. Even though the OS may provide an API for object encoding, the language doesn't have to use that, because the byte-wise file access API is complete (you can use it to access a file in any format) – Ben Voigt Jul 27 '19 at 05:32
  • So the feeling of "Write once run anywhere" actually hides the use of a library specific to each host OS? –  Jul 27 '19 at 05:50
  • For sockets, we definitely need the Winsock API and provider DLLs. The low-level implementation of sockets via afd.sys IOCTLs is undocumented. Python couldn't bypass Winsock even if it wanted to. – Eryk Sun Jul 27 '19 at 09:46
  • @eryksun: An application (or the framework it is built with) certainly can bypass Winsock because the lower-level networking APIs are complete. Consider Wireshark for an example. But I doubt Python does so. – Ben Voigt Jul 27 '19 at 13:29
  • @BenVoigt, I was just referring to bypassing the Winsock user-mode libraries (ws2_32.dll, mswsock.dll, msafd.dll) to access the kernel interface (afd.sys) directly via `NtDeviceIoControlFile`. I suppose a framework could access NDIS and Bluetooth drivers directly to roll its own sockets implementation from scratch. It sounds extremely difficult to me, but it's way outside of my wheelhouse, so I don't know how difficult it would be for an experienced systems-level networking engineer. – Eryk Sun Jul 27 '19 at 13:57
  • Python definitely does not do anything like that. It sticks to cross-platform sockets functions as much as possible and uses Winsock-specific functions as little as possible, for startup, shutdown, duplicating a socket to another process, and low-level socket control -- `WSAStartup`, `WSACleanup`, `WSASocketW`, `WSADuplicateSocketW`, and `WSAIoctl`. – Eryk Sun Jul 27 '19 at 13:59

2 Answers2

2

A main window always needs to use the OS API, otherwise you will have no space on the screen and not receive any input events.

Inside that top-level window, however, it is perfectly possible for a library to custom-draw all its widgets (such as buttons, menus, checkboxes, textboxes) instead of using the OS-provided widgets.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • But even widgets still use the OS API? What about other features such as file playback? Is Python Node.js for Windows actually using the same API? –  Jul 27 '19 at 05:01
0

According to the post below it would seem so, however I understood that it would be possible to bypass the OS for example to directly use sockets directly without using the OS.

How a program become independent of OS?