Jump to content

Standard library: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Luckas-bot (talk | contribs)
m [r2.5.2] robot Adding: zh:标准库
m Fix capitalization in lists and correct minor typo
Line 2: Line 2:


Depending on the constructs made available by the host language, a standard library may include:
Depending on the constructs made available by the host language, a standard library may include:
*[[subroutine]]s
*[[Subroutine]]s
*[[Macro (computer science)|macro]] definitions
*[[Macro (computer science)|Macro]] definitions
*[[global variable]]s
*[[Global variable]]s
*[[class (computer science)|class]] definitions
*[[class (computer science)|Class]] definitions
*[[template (programming)|template]]s
*[[template (programming)|Template]]s


Most standard libraries include definitions for at least the following commonly used facilities:
Most standard libraries include definitions for at least the following commonly used facilities:
*[[algorithms]] (such as [[sorting algorithms]])
*[[Algorithms]] (such as [[sorting algorithms]])
*[[data structures]] (such [[list (computing)|list]]s, [[tree (data structure)|trees]] and [[hash table]]s)
*[[Data structures]] (such as [[list (computing)|list]]s, [[tree (data structure)|trees]] and [[hash table]]s)
*interaction with the host platform, including input/output and operating system calls
*Interaction with the host platform, including input/output and operating system calls


== Philosophies ==
== Philosophies ==

Revision as of 04:46, 15 March 2011

A standard library for a programming language is the library that is conventionally made available in every implementation of that language. In some cases, the library is described directly in the programming language specification; in other cases, the contents of the standard library are determined by more informal social practices in the programming community.

Depending on the constructs made available by the host language, a standard library may include:

Most standard libraries include definitions for at least the following commonly used facilities:

Philosophies

Philosophies of standard library design vary widely. For example, Bjarne Stroustrup, designer of C++, writes:

What ought to be in the standard C++ library? One ideal is for a programmer to be able to find every interesting, significant, and reasonably general class, function, template, etc., in a library. However, the question here is not, "What ought to be in some library?" but "What ought to be in the standard library?" The answer "Everything!" is a reasonable first approximation to an answer to the former question but not the latter. A standard library is something every implementer must supply so that every programmer can rely on it.[1]

This suggests a relatively small standard library, containing only the constructs that "every programmer" might reasonably require when building a large collection of software. This is the philosophy that is used in the C and C++ standard libraries.

By contrast, Guido van Rossum, designer of Python, has embraced a much more inclusive vision of the standard library; in the Python tutorial, he writes:

Python has a "batteries included" philosophy. This is best seen through the sophisticated and robust capabilities of its larger packages.[2]

Van Rossum goes on to list libraries for processing XML, XML-RPC, email messages, and localization, facilities that the C++ standard library omits. This other philosophy is often found in Scripting languages (as in Python or Ruby) or languages that use a Virtual machine, such as Java or the .NET Framework languages[ambiguous].

Examples of standard libraries

References

  1. ^ Bjarne Stroustrup. The C++ Programming Language. 3rd Ed. Addison-Wesley, 1997
  2. ^ Guido van Rossum. Python Tutorial.