Standard Libraries
Estimated study time: 6 minutes. The built-in toolkit every language ships with, and why you should reach for it first.
A standard library is the collection of modules, functions, and classes that ship with a programming language by default — no extra installation required. It covers everyday needs like file handling, math operations, date/time utilities, networking, and data structures.
Why Standard Libraries Matter
Before writing a custom function for something common — say, parsing a date or reading a file — check the standard library first. It's tested, optimized, documented, and maintained by the language's core team, which almost always beats a hand-rolled version.
Common Categories
- File & I/O — reading/writing files, working with paths.
- Data structures — collections, queues, stacks beyond the language's built-in types.
- Date & time — formatting, time zones, durations.
- Networking — HTTP requests, sockets.
- Math & statistics — beyond basic arithmetic operators.
A Simple Example
import math
import datetime
print(math.sqrt(144)) # 12.0
print(datetime.date.today()) # e.g. 2026-07-18
Standard Library vs Third-Party Package
A standard library comes bundled with the language installation. A third-party package (like one installed via npm or pip) has to be added separately and depends on external maintainers. Standard libraries are generally more stable across versions, while third-party packages often move faster and cover more specialized needs.