Home Explore Blog CI



nushell

3rd chunk of `contributor-book/philosophy_0_80.md`
be9f39b40cb024bf18b34d29ce21b59f07129aafcdac92ba0000000100000e73
Use a switch flag when:

- You need to allow the user to change the default action of the command

### Comments

Commands should be commented to describe their function and usage. This documentation should also cover parameters and their use.

## Core categories

The core language and standard library needs to cover the following categories to support common use cases for Nushell:

- Filesystem
- Operating system
- Manipulating the environment
- Parsing string data into structured data
- Formatting structured data as standard string formats (CSV and JSON)
- Querying, filtering, and manipulating structured data
- Network connectivity
  - note: Network support is fundamental because with it users can easily acquire and install Nushell extensions
- Basic formats (exact list to be determined by common use cases)
- Basic date support

The following categories should be moved to plugins:

- Database connectivity
- Dataframe support
- Hash functionality
- Uncommon format support
- Experimental commands
- Supplemental random number support (eg `random dice`)
- Supplemental math support from `math`
- Supplemental binary data functionality from `bytes`
- Advanced date support

We should select commands to be in the core categories which meet the common use cases for Nushell. Commands that are in the core categories that are uncommon use cases should move to optional extensions.

## Language design

Rather than describe the whole of the language here, this section describes the changes expected to come as part of 0.80 and how they differ from the 0.60 series.

### More shell functionality

Being a shell-focused language means incorporating more of the expected shell-features into the language. These include:

Redirection (with common variations):

```bash
cat foo.txt > bar.txt
cat foo.txt >> bar.txt
cat foo.txt 2> bar.txt
```

Note: as of 0.72, these are currently:

```nu
cat foo.txt out> bar.txt
cat foo.txt err> bar.txt
```

(note: no operator support for append currently)

Equivalent functionality for Bash logic operators:

```bash
cat foo.txt && cat bar.txt
cat foo.txt || cat bar.txt
```

Note: as of 0.72, these are currently:

```nu
cat foo.txt; cat bar.txt
try { cat foo.txt } catch { cat bar.txt }
```

We don't have plans to support the full bash language.

### Limited mutation

In 0.80, there will be a limited form of mutation that works with the local command.

```nu
mut x = 100
$x = 200
print $x
```

This will help with some patterns where people wanted to calculate something in a loop but didn't have an easy way to do so previously.

### Splitting closures and blocks

Connected to mutation is the idea that blocks and closures will be separate concepts in 0.80. In the 0.60 series, these were largely both treated on under the same concept as "blocks".

In the future, a block will not be a first-class value. Instead, it will be expected to be run by the command you give it to and not passed into the pipeline. This allows blocks to work with mutable variables.

Closures retain the capabilities of 0.60 and can be used as first-class values, but can't mutate variables.

Block example:

```nu
for x in 1..100 {
  print $x
}
```

Closure example:

```nu
ls | each { |x| $x.name + "foo" }
```

## Extensions

We will need to design and implement an easy-to-use extension mechanism that allows people to extend Nushell with additional functionality. This will be important both for helping shrink the core Nushell down but also to make it easy for contributors to create and share their own extensions.

The extension mechanism will need a standard form by 1.0. For 0.80, we should have our best guess at a complete solution that meets the design goals.

Title: Core Categories, Language Design, and Extensions in Nushell
Summary
This section outlines the core categories that Nushell's standard library should cover, including filesystem, OS, environment manipulation, data parsing/formatting, querying, network connectivity, basic formats, and date support. It also lists categories better suited for plugins, such as database connectivity, dataframe support, and advanced data/math/date functionality. The discussion extends to language design changes in version 0.80, introducing more shell-like features like redirection and logic operators, as well as limited mutation capabilities. Finally, it emphasizes the importance of designing an easy-to-use extension mechanism to allow users to expand Nushell's functionality and shrink the core.