I have problem understanding how are standard libraries for programming languages, other than C, written.
As far as i understand, C standard libraries can be implemented in mixture of C and assembler, where assembler is needed so system calls can be invoked and thus fopen, fscanf ... can be used.
How do the other programming languages accomplish this functionality(working with i/o, files, all other stuff for which system calls are needed) with their standard libary? Do they all allow inlining of assembler like C or is there some other way?
I have read that C and its standard library can be used, for implementing other languages libraries, but i am not sure how this is done.
edit1. Trying to be more specific.
(Language for which standard library is implemented is referred to as new_lang.)
If someone can elaborate how second approach is done(using C runtime) at the object code level and implementation level, because somethings i cant get my head around are:
- Is C runtime invoked using C syntax or new_lang syntax? How do we call ssize_t write(int fd, const void *buf, size_t count) from somewhere within new_lang library?
- What happens if new_lang doesn't have pointers as data types, how is second argument, const void *buf to write passed from new_lang? How does new_lang follow C runtime api if it doesn't have C data types?
- If some function from new_lang library calls C runtime, does it mean that it must obey its abi? Data sizes for types of integer, char, must match in new_lang and C for given platform(and other stuff which is specified by abi, are arguments passed by stack or registers etc.)?
Isn't this little overrestricting, for example what if new_lang needs more bytes to be reserved for char?
I tried to be as general as possible, but i am not sure how to explain the problem without going into a little detail.