4 ms·
I've yet to find a programming language that makes I/O redirection, piping, and process substitution[1] as easy as Bash does. Process substitution is where the
by heavyset_go 7y ago
I've yet to find a programming language that makes I/O redirection, piping, and process substitution[1] as easy as Bash does. Process substitution is where the shell really shines, in my opinion.
Bash, and Bash-like shells, are literally everywhere. I have to be wary about what Python 3 features I use, and if there will even be a Python interpreter available. My OpenWRT router has a Bash shell, but I don't care to install and maintain other interpreters or runtimes on an embedded platform.
Even job management and parallelism are easier in Bash and GNU Parallel.
[1] https://www.tldp.org/LDP/abs/html/process-sub.html https://www.tldp.org/LDP/abs/html/process-sub.html
- Pxtl 7y agoPowerShell, mostly because PowerShell was designed as a mashup of Bash and C#.... And it's kind of a trainwreck in a lot of ways. It really feels like piping and easy process invocation and compile-time directory awareness wouldn't be massively onerous to add to an existing full-featured programming language so you wouldn't have to sacrifice a good type system and powerful syntax when you want to do scripty things.
- edgyquant 7y agoRight. Powershell is a shell though not a programming language.
- plapetomain 7y agoThat is false. Why do you think it is not a programming language?
- chrisfinazzo 7y agoAs I understand it, PowerShell came about because porting the standard Linux/Unix utilities to Windows didn't work out. PowerShell meets both requirements as it's tuned for the Windows environment, but can still play nicely with the rest of the world. Of course, now that WSL is a thing, it's a real question why someone would want to use PS unless they had no other options. https://www.heavybit.com/library/podcasts/to-be-continuous/ep-37-the-man-behind-windows-powershell/ https://www.heavybit.com/library/podcasts/to-be-continuous/e...
- sjy 7y agoPowerShell has real data structures (arrays and hash tables), built-in functional programming tools (Select-Object, ForEach-Object, Where-Object), GUI cmdlets (Out-GridView) and direct access to .NET libraries. It’s a viable tool for many complex tasks where on Unix, you’d need to reach for Python rather than a shell.
- vips7L 7y ago>Of course, now that WSL is a thing, it's a real question why someone would want to use PS unless they had no other options. I use it because I only have to learn one tool, and not a ton of different ones with different UX. The 'language' is sane, at least to me, as it's object oriented doesn't revolve around parsing strings.
- heavyset_go 7y agoSome of the features of PowerShell seem really enticing, and I wish they would make their way over to Unix-like shells. Unfortunately, I don't know how much utility I'd get out of PowerShell on Linux, so I haven't tried it. edit: your comment inspired me so I installed PowerShell via Snap and am going to give it a go on Linux.
- Pxtl 7y agoTo me PowerShell mixes easy access to command-line tools and higher-order object-oriented map/filter style functions. The mix between Unix-style piping from command-line tools and modern object-y mapping and filtering can feel like a dream. That's the good part. The bad part is that it's easily one of the wartiest languages I've ever used, especially as a young language it's really got an inexcusable amount of legacy problems. A colleague of mine (who also uses it heavily) says "two Googles per line". Just to get sane parameter and variable checking you have to throw up a bunch of attributes and set a bunch of flags. Be sure to set up strict mode, use cmdletbinding on your parameter blocks, and set ErrorActionPreference to "stop" in every script you write. That and the quality of many of the first-party official PowerShell modules is appallingly low by Microsoft standards. The good side is that the .NET framework is accessible so whenever the PowerShell module is failing you, you can drop down into leveraging raw c#-style assemblies, which are much higher quality but they speak PowerShell with a very thick accent. But I'm using it on Windows, YMMV on Linux. I'm infatuated with the concept, but the implementation leaves a lot to be desired.
- IshKebab 7y agoI don't know about process substitution, but Dart makes connecting processes together pretty easy and you can do way more fancy things than Bash let's you do, in a clean fast language with basically no gotchas. Check out dshell: https://pub.dev/packages/dshell https://pub.dev/packages/dshell
- heavyset_go 7y agoPretty cool, thanks for pointing it out. I have some experience with Dart via Flutter development, so I'll give this a go when I have some time.
- heavenlyblue 7y agoAnd now we have 3 languages...
- boring_twenties 7y agoIf your OpenWRT router has a bash shell, then you optionally installed it from packages. The default shell is Busybox, which is a minimal shell that supports few if any "bashisms." In other words, you certainly do have to be wary about what shell features you use.
- ilyash 7y ago> I've yet to find a programming language that makes I/O redirection, piping, and process substitution[1] as easy as Bash does. Next Generation Shell - mostly there. If something of the above is missing - it's a bug and you are welcome to open an issue. I'm the author. https://github.com/ngs-lang/ngs https://github.com/ngs-lang/ngs
- heavyset_go 7y agoI like this a lot. Definitely very cool, and I plan on giving it a shot when I have some time. Just curious, but how would one do process substitution with NGS?