CIE AS & A Level Computer Science, section 5.1 (Operating systems)
Program libraries
A program library is a collection of pre-written, tested code (functions and routines) that programmers can reuse in their own programs instead of writing the code again.
Software under development is often constructed using existing code from program libraries. For example, a library for maths, graphics or file handling.
Benefits to the developer
- Saves time: the code already exists.
- The code has been thoroughly tested, so it is more reliable.
- Programs are shorter and easier to understand.
- Libraries are often maintained and updated by experts.
Dynamic Link Library (DLL) files
A DLL is a library file whose routines are loaded at run time (when the program runs) rather than being copied into the program when it is compiled.
| Benefits of DLLs | Notes |
|---|---|
| Several programs can share one copy, saving memory and disk space | |
| The program file is smaller | |
| A DLL can be updated without recompiling the programs that use it | |
| Libraries are loaded only when needed |
A drawback is that if the DLL is missing or the wrong version, the program may fail to run.
Common mistake: saying a library is "a program that runs on its own". It is a collection of routines that other programs call. Also, DLLs are linked when the program runs, not copied into the program when it is built.
Exam tip: give the benefit in terms of time saved, reliability and reuse. For DLLs, mention sharing, a smaller program and updates without recompiling.
Check yourself
What is a program library?
A collection of pre-written, tested routines that programmers can reuse.
Give one benefit of using a library routine.
It saves development time, or the code has been tested, so it is more reliable.
What is a DLL?
A dynamic link library: a library file whose routines are loaded when the program runs and can be shared by several programs.