Top
Best
New

Posted by ravenical 1 day ago

The Case for Nushell (2023)(www.sophiajt.com)
63 points | 61 commentspage 2
b00ty4breakfast 1 day ago|
this is very weird timing, I literally just installed nushell this morning lol. I like it so far but that may just be the novelty effect. I gotta find a syntax file for vim, tho, because moving over my bash aliases and trying to visually parse the config file after 10 lines or so is making me go cross-eyed.
pksebben 1 day ago||
caveat up front: I see that the point here is to talk about a nice, good thing for people to use that is useful, and I don't think that's a bad thing. I am also always looking for ways to upgrade, and I also agree that in a modern context with modern knowledge, we can do better.

However, regarding the posix skepticism - I think OP has missed (or just not mentioned) the actual thing that keeps bash/zsh from being unseated.

Industrial standards are a good thing just because they’re standards. They’re right that a redesign would be superior in terms of raw design, but this is only useful if it’s adopted widely enough so that you don’t have to context switch between two fundamental systems. I spin up a new VM somewhere and it's going to have bash. I use a tool and I expect it to follow a particular convention - having to figure out which I'm reaching for adds an amount of friction that would make most work untenable.

I like zsh but I also want something better. Type safety and robust completions would make me very happy, but if we're going to make the switch we have to do it as an industry - with a set of agreed upon interfaces and standards that are carefully thought out and built on consensus. I don't know if that's possible given the massive complexity of the state of affairs but that's what it would take.

xpe 1 day ago||
A nice coincidence to read this; I was just telling some friends the following (lightly edited):

Nushell is amazing and a total pleasure to use. I cannot yet discern any limit to how much thought has been put into it.

I’m stunned in a good way. I’m writing shell scripts without any pain — actually I much prefer them to Python! With the language-server integration – I use Zed, but I'm sure they exist in VS Code and others too – I can see errors in scripts as I write them! (Including typos in pathnames! Amazing.)

I have to admit Nushell didn’t become my daily driver right away; it took a few years for me to switch fully. I don't know exactly why, but it probably had to do with its lack of POSIX compatibility. I now see this as a necessary break for Nushell to pursue its vision.

About expectations: some people will be delighted immediately and get hooked, but not all. We're all busy and adopting a new tool can feel like a leap of faith. For me, it has been worth it. Nushell has felt like planting a garden that gives back way more than you put into it.

I wrote up a quick gist [1] that shows how nice the experience is to write a new command (i.e. function) in Nushell.

[1]: "Building Argsort with Nushell" https://news.ycombinator.com/item?id=46528644

UltraSane 1 day ago||
If you haven't tried PowerShell I strongly recommend you do. It is really well designed and the way objects are piped between commands is brilliant and very powerful. Combined with property filters you can do SQL like queries. The ConvertTo-JSON lets you export the output of any command to JSON which is amazingly useful. As an example you can dump the entire Active Directory (Assuming you have permissions) by

Get-ADObject -Filter * -Properties * | ConvertTo-JSON > ADObjects.json

And you have access to ALL of the .NET library.

haolez 1 day ago|
Until you have to quote a string that has ampersands in it :)
jborean93 12 hours ago|||
& has no special behaviour in strings, backticks and $ on the other hand do. For example "&Some String&" and '&Some String&' are all the literal value `&Some String&`. Backticks and $ are special in double quoted strings as they are the escape character and variable reference chars respectively.
ZenoArrow 1 day ago|||
You mean like this...

' "Here is an ampersand... &" '

To clarify, in PowerShell there is a difference between text between single quotes (e.g. '$test') and double quotes (e.g. "$test"). Single quote strings are literal strings, so whatever text is contained within them is reproduced as written. Double quote strings are expandable strings, which means that certain text inside the string is evaluated before it is returned. If you have double quotes in a literal string, you'll see double quotes within that string, and the same should be true for ampersands.

haolez 30 minutes ago||
That works in some cases, not others. I'm not saying that PowerShell is bad, but it certainly isn't a masterpiece of design.
adamnemecek 1 day ago||
I started using nushell around April 2024. While it is much better than other shell languages, the lack of proper types is painful.

Shell languages make sense if you believe in the Unix philosophy. For me, the problem with the Unix philosophy is the endless serialization and deserialization as well as lack of proper error handling. So nushell for me is a good answer to an ill-posed question.

The approach I have been taking is a single binary with a billion subcommands and aliasing these. I currently have two of these in Rust, one in Swift. I tried going all Rust but integrating with certain aspects of macOS is just so much simpler in Swift.

Like the recent push to make CLI development suck less (e.g. argument parsing used to be painful but is solved now) has made developing CLI tools a lot less painful.

nialv7 1 day ago||
serialization/deserialization will always be needed unless you got all your programs working with the same ABI. it's just that in nushell's case you aren't serialize to human readable text.
UltraSane 1 day ago||
endless serialization and deserialization is what makes me hate Bash and love PowerShell which solves this issue by piping full objects between commands and the ConvertTo-JSON command.
Natfan 1 day ago||
i've never used nushell, but i've always felt that people have been sleeping on PowerShell.

yes, it was _originally_ only for Windows, but PowerShell 6+ uses .NET Core, which is OS independent. this means that a few helper functions like GeneratePassword[0] are gone, but it's _mostly_ at parity with .NET.

the Verb-Noun structure can be confusing at first, but once you know the approved verbs[1], you can usually guess your way through command discovery, which is not something i can say for most POSIX tools (useradd and adduser do different things!!)

it's also object oriented by design, with default aliases like ?[2] and %[3], querying structured data is a breeze.

- want to check a CSV? Import-CSV[4].

- want to call a REST/SOAP endpoint? Invoke-RestMethod[5] has you covered.

- DNS queries? Resolve-DnsName[6]

as it's built on top of .NET, you get the whole CLR[7] at your fingertips! you can make a TCP client[8] in PowerShell, or even just write C# directly in your terminal[9] and execute it the same way.

such a flexible and useful language, even if it is a little slow and owned by micro$oft. but it _is_ open source[10]!

---

[0]: https://learn.microsoft.com/dotnet/api/system.web.security.m...

[1]: https://learn.microsoft.com/powershell/scripting/developer/c...

[2]: https://learn.microsoft.com/powershell/module/microsoft.powe...

[3]: https://learn.microsoft.com/powershell/module/microsoft.powe...

[4]: https://learn.microsoft.com/powershell/module/microsoft.powe...

[5]: https://learn.microsoft.com/powershell/module/microsoft.powe...

[6]: https://learn.microsoft.com/powershell/module/dnsclient/reso...

[7]: https://learn.microsoft.com/dotnet/standard/clr

[8]: https://learn.microsoft.com/dotnet/api/system.net.sockets.tc...

[9]: https://devblogs.microsoft.com/scripting/weekend-scripter-ru...

[10]: https://github.com/PowerShell/PowerShell

b40d-48b2-979e 1 day ago||
As a prior contributor to PowerShell, I think part of this obscurity reason is how they neglected their community. This was evident in their merged PR history only containing commits from Microsoft developers.

I use nushell now, and its community is fantastic. It may face breaking changes every so often, but it has a much faster execution speed and more features if you're not tied into the .NET ecosystem.

adzm 1 day ago|||
Powershell is pretty great, though I am constantly bit by issues with filenames having [ or ] in them and end up having to pass -LiteralPath to everything, which is frustrating and a constant source of bugs in any other scripts that do not do that.
hulitu 1 day ago||
> The truth is, in 2023 if someone asked us to design a system, we wouldn't design POSIX.

You can design anything you want (see GTK for an example of moving target). But if you want anyone to use it, better stick to standards.

sunshine-o 1 day ago||
Nushell is a fantastic project.

Something I came to appreciate is that the 50MB binary is really battery included. You will be able to deal with JSON, XML, SQLite DBs, HTTP requests and more. I personally do not need anything else.

Now, no matter how much you get excited about it, do not write too much production code with it as it still change and break often between releases.

Aerbil313 1 day ago||
Do not let the "shell" in the name fool you. Nu is a full on programming language. I've spent more time with it than pretty much any other lang and if I have to describe it in one sentence, I'd say: It's the most beautiful combination of the ease of Python, strictness and ergonomics of Rust and of course shell capabilities of Bash.

It's really its own kind of thing. It's definitely not just another shell.

I've written very impressive and very complex software in nu. I fully expect it to take off very fast as it nears a stable v1.0. I can't imagine going back to anything else.

ndsipa_pomu 1 day ago|
The example FOR loop in BASH is missing a trick to make it easier to read:

  for i in {1..10}; do
    echo $i
  done
(Though I prefer using printf than echo as it's more capable and POSIX compliant)

I write far too much stuff in BASH, but for me it's just not worth moving to using a different shell due to its ubiquity. There's also the question of "will this still run easily in 20 years". Of course, BASH is a nightmare for bugs and foot-guns unless you make a point of defensive coding (e.g. surround variables with double-quotes and using Shellcheck to point out common errors).

By the way, the article goes on to mention the large number of options to "ls". Don't try to parse the output of "ls" in scripts as there's better ways to do things: https://mywiki.wooledge.org/ParsingLs