0

Programs do not exist in a vacuum. Almost everything they do requires other programs to function. Even the simple "Hello World" program, a staple in programming language tutorials, requires some way to print the text to a console. This is where libraries come in. Libraries are reusable pieces of code that can be called from an application and used many times. The libraries that programmers generally know are the standard libraries for a programming language and operating system libraries.

Standard libraries are those defined by the programming language specification. For   example , when doing a hello world  program  in  C , you would include stdio.h. This provides the printf() function, which allows text to be printed to the console. stdio.h also provides various other functions for input and output, all of which are defined in the C specification.

Some languages have larger standard libraries than others. Generally, higher-level languages have more extensive libraries.  C++  and Java both have large data structure libraries that are not replicated in  C . As another  example , Java has a Swing library, a cross-platform graphics library for easily creating GUIs that is not replicated in  C  or C++.

The second class of libraries often used by programmers is operating system libraries. As the name implies, they are built into the operating system, and generally provide access to OS tools, such as current information about the computer and the user.

The final set of libraries is third-party ones. These are often ignored by programmers, but they can be extremely powerful. For  example , take LibAV. This library performs audio and video encoding. There are many obscure AV formats, and writing code for them can be complex. But with LibAV, you just add the library to your application and use its functions, letting you work on the code specific to your application.

An important thing to remember with libraries is copyright issues. LibAV is distributed under the GNU GPL or GNU LGPL depending on the version. These licenses have different requirements. The GPL, for  example , requires you to license your entire application under the GPL, making it open-source and free software. The LGPL does not. Using a library without following the license is copyright infringement.

A final fact to remember about libraries is that they have often been in development for a long time. If you decide to write a piece of code, it might have bugs, but this is less likely in libraries, as previous users of the library have already tested it and caught many bugs.

Using libraries can make writing code a lot easier. Instead of having to write everything yourself, you can reuse what people have already written, making for more efficient coding.





Source by Bill Hollins

Post a Comment

 
Top