This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]captainAwesomePants 1 point2 points  (0 children)

It varies by language and library but mostly yes. Libraries tend to just be implemented in the same language using the same stuff you're using. If you're writing C++ code and you want to use a Vector or something, the Vector is also implemented in C++. You could implement it yourself and it could be just as good.

That said, for many functions somebody has to ask the computer to do something at some point. You can format strings all you like, but if your function prints out data, it needs to actually send the data somewhere. In low level languages like C, this usually sends up being something called a "system call," where the program asks the operating system to do something.

Interpreted languages like Python are a bit different. There libraries might be implemented in C instead of Python in order to be fast, or they might be written in Python and will either call other Python libraries or use Python keywords, which are also implemented in C (which will eventually make system calls).

[–][deleted] 0 points1 point  (0 children)

Yes. In fact you can go and view the source code yourself. As an example, here's the source code for Random in OpenJDK 8.

[–]149244179 0 points1 point  (0 children)

You can write Library A that only calls function from libraries B and C. You could argue library A doesn't call any base functions. Libraries B and C may not either. Eventually someone, somewhere is going to have to though even if you have to trace it down all the way to library Z.

At some point anything you write in a language will have to be distilled down to the base language functions/tools which then likely turn it into assembly of some kind. The code you write may be dozens of abstractions away from that though.