How do non c languages interact with operating system?

后端 未结 2 847
醉话见心
醉话见心 2021-01-01 06:15

On linux (for example), we can directly make system calls using the api provided by OS (open/close/read/write) or we can use functions provided by libc (fopen etc) in C.

2条回答
  •  旧时难觅i
    2021-01-01 06:39

    In other languages this is usually (always?) achieved with a wrapper around the native function calls. In reality, it looks something like this. LanguageX -> Wrapper -> Native Code(C/C++)

    Sometimes this wrapper takes the form of an entire framework, such as in JNI for java. which also works great for Groovy scripts.

    With some languages you can load native DLLs directly into your application in a way similar to C/C++. This is true in the the case of Python using ctypes.

    Other times, native calls aren't needed at all and the same result can be produced directly using your language of choice. Cross-platform GUI toolkits are one small example where native OS calls can be replaced completely. Such as with GTK or QT

    Hope that clears things up a bit :) Let me know if you'd like any other language-specific details.

提交回复
热议问题