what's a library./.

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
Anonymous

what's a library./.

Post by Anonymous »

I've been hearing library in programming.. What exactly is the "library"?
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post 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.
Image
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post 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.
*****
Last edited by moneo on Sat Apr 08, 2006 6:37 pm, edited 2 times in total.
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

Moneo, I was trying to make it easy for him to understand, not be technichial (wow, I suck at spelling...) about it.
Image
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post 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.
*****
User avatar
Zim
Veteran
Posts: 98
Joined: Mon Dec 05, 2005 4:31 pm
Location: Wisconsin, USA
Contact:

Library

Post 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.")
--- Zim ---
--- Time flies like an arrow, but fruit flies like a banana ---
Post Reply