Page 1 of 1

what's a library./.

Posted: Sat Apr 08, 2006 12:50 am
by Anonymous
I've been hearing library in programming.. What exactly is the "library"?

Posted: Sat Apr 08, 2006 8:34 am
by {Nathan}
I library is a collection of subroutines that are in an external program and "included" into you program. Because many people need speed-intesive routines for games and QB lacks and speed in graphics, libraries are ofton written to replace QB's graphics routines with faster and more routines.

Posted: Sat Apr 08, 2006 3:06 pm
by moneo
Nathan1993 wrote:I library is a collection of subroutines that are in an external program and "included" into you program. Because many people need speed-intesive routines for games and QB lacks and speed in graphics, libraries are ofton written to replace QB's graphics routines with faster and more routines.
What Nathan1993 said is basically true, except that libraries contain SUB PROGRAMS (SUBS) and FUNCTIONS. These SUBS and FUNCTIONS are not "included" into your source code as are "include files", but are made part of the object modules of your program, which in turn are "linked" to become the executable file of your program. Since they are already in object form before the link process, the library modules can be written in assembly language, a big advantage for doing things that just can't be done in Basic.

Why do I need to use a library?
One reason is so that several programmers can use common or standard subs and functions that someone decided was the best. This someone is probably the project leader, wrote the common/standard subs and functions, and put them on a library for everyone to use.

Another reason is that a programmer may buy a library of functions that would be difficult for him to write himself, like say advanced math routines.
*****

Posted: Sat Apr 08, 2006 6:18 pm
by {Nathan}
Moneo, I was trying to make it easy for him to understand, not be technichial (wow, I suck at spelling...) about it.

Posted: Sat Apr 08, 2006 7:33 pm
by moneo
Nathan1993 wrote:Moneo, I was trying to make it easy for him to understand, not be technichial (wow, I suck at spelling...) about it.
Making it easy to understand is fine, but it also has to have some fundamental facts.
*****

Library

Posted: Mon Apr 10, 2006 1:21 pm
by Zim
To me, in the most general sense, a library is a collection of routines which can include Sub's, Functions, or any other code (such as COMMON block declarations) you may want to include into your program(s) without having to re-write the code, regardless of HOW you do it.

QuickBASIC allows three methods (that I know of) and I've used all three:

1. Include files. You can use Rem $Include to AUTOMATICALLY include addtional source in your source code. Or, you can "include" it by hand. Sometimes I need a subroutine and I know it exists in another program I wrote. I just grab it with cut and paste. My old program (the source file) is then technically a library where the routine is stored for future use.

B. OBJ modules. Write the code and complile it but don't link it (yet). At link time link all the OBJ files together into one .EXE file. This was handy on my old IBM XT with an application that took 5 minutes to compile but only a few seconds to link. A change in one module didn'r require re-compiling the whole darn thing! 'twas faster.

III. Stand-Alone EXE files. Compile and link code into .EXE files so they all look like separate programs. Then use "RUN" or "CHAIN" to cause one program to execute another. (I've used this one to compile code which alternately DOES and does NOT use the math-coprocessor so that I can compare execution speed difference. I used QB v 3.0 for this.)

The idea of a "library" (to me, in the general sense) is no matter how you technically use it, you're written the code in such a way that it can be used again later without re-writing the code all over again.

(oh yes, then there's "Quick Libraries.")