# Standard libraries

#### What are Standard Libraries in Computer Programming?

Standard libraries in computer programming are pre-written code organized in packages or libraries that provide developers with common functions and tools, so they don't have to write these from scratch for every new project. They typically include functionalities for data handling, file manipulation, interface with the operating system, and much more. Standard libraries play a crucial role in software development by offering a rich set of features that can help in speeding up the development process and ensuring code reliability and efficiency.

#### How are Standard Libraries Used?

Developers use standard libraries by including them in their programs. This is usually done through an import or include statement at the beginning of a program or file. Once included, developers can make use of its functions, objects, and methods as needed, allowing for more complex operations to be performed with less code written manually.

#### Examples of Standard Libraries

**C++**

C++ Standard Library: It provides a set of common classes and interfaces, encapsulating functionalities like collections, file processing, threading, and algorithms. Examples include:

* **iostream**: For input and output operations.
* **vector and array**: For handling collections of data.
* **thread**: For managing threads.
* **filesystem**: For handling files and directories (C++17 and later).

**C#**

.NET Framework Class Library (FCL): It’s a comprehensive, object-oriented collection of reusable types that you can use to develop applications ranging from traditional command-line or graphical user interface (GUI) applications to applications based on the latest innovations provided by ASP.NET. Examples include:

* **System.IO**: For file and stream reading and writing.
* **System.Collections.Generic**: For using collections like lists, dictionaries.
* **System.Threading**: For threading and synchronization.
* **System.Linq**: For powerful data querying capabilities.

**Python**

Python Standard Library: Known for its comprehensive offering, Python’s standard library includes modules for various functionalities including mathematics, file handling, serialization, and more. Examples include:

* **os and sys**: For interfacing with the operating system.
* **re**: For regular expressions.
* **datetime**: For manipulating dates and times.
* **json, pickle**: For data serialization and deserialization.

Standard libraries significantly enhance the development process across different programming languages by providing tested and optimized solutions for common programming tasks.

#### Example Usage of Standard Libraries in C++

**Reading and Printing to Console:**

```cpp
#include <iostream>
using namespace std;

int main() {
    cout << "Enter your name: ";
    string name;
    cin >> name;
    cout << "Hello, " + name + "!";
    return 0;
}
```

#### Example Usage of Standard Libraries in C\#

**Writing and Reading a File:**

```csharp
using System;
using System.IO;

class Program {
    static void Main() {
        string path = "example.txt";

        // Writing to a file
        File.WriteAllText(path, "Hello, World!");

        // Reading from a file
        string content = File.ReadAllText(path);
        Console.WriteLine(content);
    }
}
```

#### Example Usage of Standard Libraries in Python

**Working with JSON Data:**

```python
import json

# Create a Python dictionary
data = {"name": "John", "age": 30, "city": "New York"}

# Convert dictionary to JSON string
json_str = json.dumps(data)

print(json_str)

# Convert JSON string back to dictionary
data_dict = json.loads(json_str)

print(data_dict)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://university-west.gitbook.io/programming-paradigms/programming-fundamentals/standard-libraries.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
