Home Explore Blog CI



nushell

4th chunk of `blog/2020-08-23-year_of_nushell.md`
e3225e589f7d462b224205500abf9f55c3c965b2cfbfe8b50000000100001210
We carry this further, by also representing values common in modern computer usage: URLs, file paths, file sizes, durations, and dates are all examples of built-in data types. By building them in, Nu can have better syntax and type checking with their use.

For example, in Nu it's possible to write `= 1min + 1sec` to create a duration that is one minute one second long. You can also use the file sizes, like being able to filter a directory list by the size of the file `ls | where size > 10kb`.

Nu also can help if you try to mix types that shouldn't. For example, if you had written: `= 1min + 1kb` it seems you didn't mean to add time and file sizes together, and Nu gives you an error if you do:

```
error: Coercion error
  ┌─ shell:1:3
  │
1 │ = 1min + 1kb
  │   ^^^^   --- filesize(in bytes)
  │   │
  │   duration
```

_note: we'll be making this error better in the future_

Data in Nu also isn't just the value, but it's also a set of metadata that comes with the value. For example, if you load data from a file using the `open` command, we track the place that it's loaded along with the data that's loaded. We can see this metadata using the `tags` command:

```
open package.json | tags
───┬─────────────────┬────────────────────────────────────────────────────────────────────────────
 # │      span       │                                    anchor
───┼─────────────────┼────────────────────────────────────────────────────────────────────────────
 0 │ [row end start] │ /home/sophia/Source/servo/tests/wpt/web-platform-tests/webrtc/tools/packag
   │                 │ e.json
───┴─────────────────┴────────────────────────────────────────────────────────────────────────────
```

This extra information allows us to know how to view the contents, and even save you time when you use the `save` command, as it will use the original location by default.

## Keeping it fun

Something we attached to early on was the idea that Nu should be fun. It should be fun to work on, it should be fun to contribute to, and it should be fun to use.

Nu is really about play. You play with your data, you play with the structures that make up your files and filesystem, you play with what web services give back to you. Everything about Nu is made to invite you to explore how things work and how data is put together. As you play, you learn more about Nu works and how to better use it. We firmly believe that learning doesn't have to hurt. At its best, the pleasure of exploration over time yields expertise without punishing you along the way. Humans just get better at something when we love to pick it up day after day, experimenting as we go. With Nu, we can ask questions like "what if I do this?" because the system is built to let us ask the question and answer it ourselves.

Nu takes this one step further. The error reporting system comes from the design of [Rust's error messages](https://blog.rust-lang.org/2016/08/10/Shape-of-errors-to-come.html), with clear messages to help guide you to success.

The goal for Nu is that it won't require you to be a wiz with the commandline or with complex programming practices. Instead, you start where you feel comfortable, and grow a line at a time. With Nu, as your comfort grows, single lines easily grow to multiple lines, and (eventually) to larger programs. You don't need separate styles of thinking when experimenting and another for building your application. In Nu, these are (or will be) one and the same.

## Crossplatform

One of the first decisions we made in making Nu is that it should not only be cross-platform, but should feel as native as possible across platforms. Commands should work the same, regardless of the platform you're on, without any loss of functionality if you switch from one OS to another. This has meant saying "no" a few times when someone offered to a cool feature, only to find out it didn't work well on one of the supported systems. The benefit, though, is that Nu users can move between OSes comfortably.

Title: Nu's Data Types, Metadata, Fun Factor, and Cross-Platform Design
Summary
Nu offers built-in data types like URLs and durations with type checking, preventing errors. Data includes metadata like file origin, accessible via `tags`. Nu aims to be fun and exploratory, with clear error messages inspired by Rust. It encourages gradual learning and growth from simple lines to complex programs. A core principle is cross-platform compatibility, ensuring commands work consistently across different operating systems.