Society of Robots - Robot Forum

Software => Software => Topic started by: vipulan12 on March 13, 2013, 05:52:38 PM

Title: What's the point of a library?
Post by: vipulan12 on March 13, 2013, 05:52:38 PM
What's the point of a library?
Title: Re: What's the point of a library?
Post by: waltr on March 13, 2013, 07:33:41 PM
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.


Title: Re: What's the point of a library?
Post by: vipulan12 on March 13, 2013, 07:41:14 PM
could you give me an example so i could better understand the concept
thanks
Title: Re: What's the point of a library?
Post by: Azraels on March 13, 2013, 08:16:49 PM
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!!
Title: Re: What's the point of a library?
Post by: Azraels on March 13, 2013, 08:23:25 PM
And a preemptive, "Where is that?"

Lecture 1 | Programming Methodology (Stanford) (http://www.youtube.com/watch?v=KkMDCCdjyW8#)