Software > Software

What's the point of a library?


What's the point of a library?

I'll assume you mean a software library.

Instead of writing a function to do a particular task every time you write it once and then reused it each time it is needed. When you buy/download a compiler it usually has a number of functions "built-in". These are in libraries.

could you give me an example so i could better understand the concept

Think of a regular library. Whats it there for? So that you can go and look up information on a certain topic and not have to go out and do research someone else has already done.

So lets say you want to use a servo. Do you just hook it up to your mcu and and it knows what to do with it already? No.
Do you go and write all that detailed code that tells the mcu exactly what to do? No.
You use the library in which someone has already written the hard code and all you have to do is simple commands. You tell your compiler you want to use the servo library to do so and so with said servo. What really happens is when you compile your code, the compiler goes to the servo library and retrieves all that extra info it needs and throws it into the program to control that servo that someone has already written.
Hopefully that explains it.

Have you ever taken a programming class? If not, look up Stanford University's Programming Methodology Class on Youtube. Start on class 1 and work your way through.  It is Java but it will give you a good base for further learning and the teacher is pretty interesting. You can also get the class schedule and example from Stanford's Website. Its all free!!

And a preemptive, "Where is that?"

Lecture 1 | Programming Methodology (Stanford)


[0] Message Index

Go to full version