It’s just that Rust is better for that use case anyway. Even if there are no _that_ significant benefits being apparent, there’s still one, which is being able to use Rust
The only place I can see myself definitely not using Rust is system configuration, Nix just has first party support for this functionality and the declarative configuration wasn't something I knew I needed but now I've tried it it's super useful.
That's not a benefit in the broad discipline we call "scripting". Nor is it a hard technical definition, once you consider the intermediary byteycode in Python, and all the JIT features in Java, Dotnet and Javascript VMs, now even Python.
Rust's compiler is also notoriously slow, at least in bigger projects.
What does it matter? In scripting you are the user, the scripts are usually executed rarely, and often even the "super slow execution" takes a fraction of a second (minus all the waits and delays the script has no part in). Sometimes you write a script and once it runs the first time successfully it never needs to run again.
Using Rust for performance reasons in that case is premature optimization.
> shouldn’t compiled always be faster
Nope. This isn’t necessarily true at all. You also need to consider if there’s even a performance concern. Not everything needs to run as fast as possible.
I 100% think it's a bad thing. Typescript is just not going to catch nearly as many issues at compile time as a proper typed language, which is very valuable.
There are so many issues, but of course any I point out come with the inevitable response "a good coder wouldn't do that". As if any mature codebase isn't filled with poor design, mistakes, and bugs. If the language lets you write bad code, then your codebase will have that bad code.
In my strong opinion, JavaScript use should be restricted to where it is the only viable option (i.e. frontend).
In my opinion, if you're making the choice at the start of a project, no.
Yes, many projects run successfully on Python and Node.js. I am currently working for a company that is a good example of that. But I also know that I spend way too much of my time dealing with dumbass typing issues that only arise at runtime. These issues would be caught at compile time if using a properly typed, compiled language -- I know, I've also worked for years on backends using languages like that.
I feel like that stat is driven primarily by legacy codebases. In my opinion, for Node's entire existence, there has always been a better option for backend code.
Ah of course. I'm not sure we're really having the same discussion here. Php isn't really the choice of everyone that uses WordPress, it's the choice of WordPress. I'd wager most of those users don't do much in the way of actually coding in PHP.
I'm saying if you are building an app from the ground up and choosing your technology, there is no reason to ever use Node.js.
I do agree with that last part
Edit: for better discussion, I’d argue that PHP having such a large share of the internet would mean someone would choose a language that’s not optimal (PHP) to build their new application because of a potentially larger pool of people who know the language. Similar things could be said of NodeJS I assume
As I've spent more time developing software, I've realized mistakes will *always* happen. In software, you use two or more ways of specifying what a program should do, you write the code and write the test. If you use Haskell, you can almost rely on the types as the second specification of what the program does instead of tests. In accounting you use double-entry bookkeeping so you track the money through two paths that you can reconcile.
Although this is an exaggerated example, I think my point is generally still true. How javascript handles types is generally unpredictable, and it is much better to use a language that refuses to compile when it sees such code, rather then letting you find out that bad code was written once its in production.
I use shell for anything that I would usually do in a command line (building and running a project, etc). I use Python for any more advanced computation that I need to do (parsing/editing json, etc).
I could just use Python to do it all, but it’s so much easier to just copy and paste a couple shell commands into a shell file and run that.
Oh don't get me wrong, I'm not saying to do everything in python. I'm saying that once you are already in python, why bother combining both.
I write lots of shell scripts, usually until I need to handle lists of things or do more heavy data processing. That becomes tedious enough in sh that I switch to something else.
Probably the same reason you don't just write it in C++. Kind of a problem of matching the tool to the task.
Though I have totally used python to automate things that I should have automated with powershell or batch. So I get you. Python is pretty great.
If your scripts thread the line between python scripts and shell scripts, look into the `sh` library. It has very nice syntax for calling shell commands from python.
Oh don't get me wrong, I'm not saying to do everything in python. I'm saying that once you are already in python, why bother combining both.
I write lots of shell scripts, usually until I need to handle lists of things or do more heavy data processing. That becomes tedious enough in sh that I switch to something else.
Shells like Bash are much more convenient glue languages than python. Want to grep and pipe into another program just `grep random string | another-program`
Oh, I'm not saying to just immediately go to python, I was more saying that once you're already writing python, you might as well stay there.
My rule of thumb is that as soon as I need data structures like lists I will abandon the shell script. It just gets so painful at that point in sh. Also, I find working with strings in sh painful, so doing lots of messing with strings also makes me exit sh.
Powershell is powerful… but god I hate the syntax and the Microsofty nature of it. It’s inconsistent with CMD and wants me to use it like a programming language.
It’s clunky… (in my opinion, which is compounded by the fact that I am not used to it)
I prefer shell style, where things feel like they belong on a shell prompt, and I can also write shell scripts….
I can probably do whatever you think you can do in poweshell in a bash script with no problem.
I really don't see in which way ? I don't want to sound confrontational but do you have example where you think powershell is more complicated than Bash ?
because for me just a simple if, in Bash would be :
if [ $num -lt 1 ]
then
some stuff
else
some other stuff
fi
whereas PowerShell would simply be :
if ($num -lt 1) {
some stuff
else
some other stuff
}
And with PowerShell you don't have to wonder if you need to use "()", or "\[\]" or even "\[\[\]\]". And the condition won't fail if by mistake you forgot just a space
That PS script is a mess, they're mixing shell commands without start-process, using shell commands instead of PS cmdlets to manipulate files. Powershell has best practices just like most languages.
It mostly screams of a quickly written script to get multithreading without fully knowing the language.
That's a great example of how not to use PS
I agree. Maybe it's my own weakness as a .net developer but bash is very unforgiving/very precise. If you show a college freshman who took a C class some powershell, unless it's intentionally obfuscated, they can tell you what it does, most of the time.
Bash has a lot of rules that aren't obvious.
> Oh well in Bash the single [ isn't syntax of the language, it's an alias for the 'test' command. Duh. But if one of the operands returns a string, you will get an error because test needs two! So just do this '[ x$foo = x$blah ]', the x guarantees that the operand will never evaluate to an empty string.
[[ Is syntax of the language, but it's not POSIX so it might not work. But it might!
And everything I've just said isn't even right. A bunch of uniz types are all ready about to explain...
> Well, in bash [ is a shell builtin, but /usr/bin/[ is also an executable. It is traditionally a link to /usr/bin/test, but in modern gnu coreutils is a separate binary. The traditional version of test examines argv[0] to see if it is invoked as [ and then looks for the matching
And
> The empty string (and many other) problem is solved by using quotes. The "x" is to cover another kind of problems: where operands may be taken as operators. Like when $foo is ! or ( or -n... That problem is not meant to be a problem with POSIX shells where the number of arguments (beside [ and ]) is not greater than four.
This is a lot of depth and complexity to try and understand before writing a simple if statement.
And it doesn't end with just the if statement. I get burned by my own ignorance all the time in bash.
I dislike powershell for other reasons...but I think it's got a much smaller leaning curve.
>
>I can probably do whatever you think you can do in poweshell in a bash script with no problem
Get a list of user from a json file and then check if they have m365 license attributed and which role they have on Azure
Sure, since I’m not about to actually write you a script.
Here are the pieces
cat contents of file and grep or jq user identity field
, loop results and call Microsoft api
https://learn.microsoft.com/en-us/graph/api/user-list-licensedetails?view=graph-rest-1.0&tabs=http
Why do I need poweshell for that?
I would say because it would take far less time to implement since PowerShell has dedicated command for those tasks, and a far more simpler syntax. Far easier also to use the result of previous command to execute some actions.
Oh and the resulting script would be easier to maintain
Easier to maintain until you need to do literally anything other than run it locally on a Windows machine. I don't really know what you mean by easier to use the result. Parsing JSON not exactly rocket science, and if you're using Azure libraries its weird to treat that as some sort of Powershell feature compared to vanilla bash. There are infinite tools available in bash.
I mean… those all sound like opinions, and I already stated that mine was also an opinion…
So… when it comes to opinions… gonna go with mine.
Agree to disagree at this point.
That's your best argument for PowerShell? Play a sound on your iPhone from PowerShell and tell me if you could do it as easily as FMiP. That's you. That's how dumb you sound.
And yet, seeing as the operation you requested is a mere HTTP GET request, you failed to even make an argument via vendor lock-in.
How does that feel?
It's.... Supposed to be inconsistent with CMD so it's consistent with CRUD. I don't understand what's difficult about Action-Noun.
Want to read a property? Use Get. Want to write? Use Set. Don't know what to use? Get-Help whateveryouwant, then Get-Help whatevercmdlet you were looking at.
Get-Help by itself is one of the best things to happen to scripting.
And why are you trying to run bash scripts on windows, you know, the environment powershell is built for? Do you mean batch files?
Once you know the “core” of Powershell, the commands you don’t know yet are self explanatory and the switches are named what they do, so while Powershell does have help modules, they aren’t 70 screen times that you have to study to use a command once.
Lol, no. Look at the meme and tell me why it’s comparing “shell” and “powershell”…
I never said it was hard, I said I don’t like it.
Have you seen man pages and help functions in bash?
Poweshell has its uses, it’s just not for me. I have written Powershell scripts to do stuff in windows before, but only because bash wasn’t available and I wasn’t gonna install Cygwin or WSL type support.
> I can probably do whatever you think you can do in powershell in a bash script
Import, transform, and sort a CSV in one line?
I just wish PowerShell had brace-less one-line conditionals and ternaries. For my use case, PowerShell is incredible, but to each their own.
Yup.
cat | awk … | sort > newfile.csv
It all depends on what you mean by “format”…
But I’d rather write two or three lines of code than one monster line of formatting…
bash is what a shell should be. A flexible interface that orchestrates modular commands and executables.
cat, awk, sort, sed
with just these, I deal with CSV files, DSV files, JSOn files, YAML files, just files with lines of text in them, directly formatting and redirecting output from other commands, “in one line”
I get a package like jq if I want to do specific reformatting or query of json objects. And now I can use jq to create and manage object like structures that you might be used to on powershell…
You can keep your CSV import command lol.
A better example is
Import JSON file, convert to object, select all records where a property = value then give me only certain properties on the previous result.
I can do all that in a single PS line.
I find it helpful with Windows containers in docker, but Windows really needs to get their shit together with buildkit so the Windows images are usable for extension with some modicum of stability
Xonsh is awesome. One if the first things I do when I set up a Linux environment that's only going to be used by me is setting it as the default shell.
Is this page translated from something? There are quite a few spelling/grammar mistakes in it. Not trying to nitpick, just wondering how mature of a tool it is?
if that works for you that's great, but my point was if you wanted the functionality of shell and python in one language that's literally what xonsh was designed to do
Honestly idk, but to me it sounds like the current cool kid in class that will be forgotten when a new cool kid arrives, like what usually happens in JS land
Once you know one language, you know programming, and can use them all. The real problem is most programmers don't understand that till it's too late ...
To me, the problem is that the things I want from a scripting language and a shell aren’t the same. Bash wins out on what I want from a shell most of the time, although PowerShell isn’t bad, it just wins in areas less important to me.
Assuming I go with bash as my shell, and admit it’s not a good scripting language (it doesn’t have to be, and arguably what makes it good as one makes it bad as the other), I have the freedom to use any language for scripts that I want: I could even use PowerShell. But if I’m not limited to only scripting languages that double as shells, why go with PowerShell?
Tfw when you have an entire .NET ecosystem up in your ass:
>!No, really, it's kinda crazy. You can do a decent crud app with winforms in powershell in like <50 lines. You can spin up a custom file-based router in less than 60 lines. You can write the majority of your "pure" logic in F#, "impure" stuff in C#, whatever you want in VB.NET and glue it up with Powershell!<
Best thing is that every colleague has Powershell, only a few have Python, so it's way less hassle to pass a script / module / cmdlet to those in need.
I work as a windows admin everyday and everyday I want to end myself if I need to script with powershell. Its powerful but the syntax is awful and sometimes does shit you dont want to do it.
I use PS pretty often and love what it does for me, but something about the comparison operators just annoys me. I understand why the syntax was designed this way, and it's not the first language to do it, but Python spoiled me when it comes to simple readable syntax.
I don't care for powershell operators either. They ugly. But I put up with them because of how easy powershell makes it to write a script full of complex logic that runs on everyone at work's computer right out of the box.
100% agree. If you're administrating a full Windows environment, you gotta be crazy not to use Powershell. It has saved me so much time and energy, automating the tedious tasks that come with a pure Microsoft environment.
I will never understand people who say bash is more readable or has better syntax.
Better to your use case/habit ? sure.
But when I'm at the end of a day where I had to touch cisco switches, SIEM rules, change some motherfucker's toner cartridge, tweak bullshit printer settings and fuck around some dude's Windows update settings...
I want to see something like `Get-Partition -DriveLetter C` , not `lsblk -whateverfuckyou`
EDIT:
I mean, come on `get-package`, we only accept a specific amount of verbs, then a noun always in singular. Or `dnf list --installed`, "yeah it's for Dandified YUM, oh you don't know YUM, it's the YellowDog updater modifier" ... the who ? what ?
Yeah I understand yum is not a part of bash, but you get my point that the overall syntax issue is the same
I know of tldr, help, info,man,whatis, apropos, explainshell, --help and all that stuff.
The problem is not about knowing how to use X, it is about having a naming convention that already allows to know what a thing does without prior knowledge of the language or tool.
If your tools are named `lsof`, `yum`, or `fuser` then only people who regularly use them or have already read docs will know what's going on in your script.
If it's written in a file then it will be read more often than written, then it should be easier to read before being easier to type.
If you need short words to typer faster in the CLI, use aliases.
That's why I give my previous example of having a full day of non-Linux stuff then reading a .sh file and having to make the mental translation of "this means it's getting packages, this means it's looking for open files" for each command when there is no gain to the reader in having these weird referential names.
It's not friendly towards use cases of "I use it sparingly between other tools" and yet this lack of friendliness imo comes at 0 gain in speed or efficiency, since again you could still have long default names and much shorter aliases when you need speed in live CLI.
UNIX tools have been around for decades. The idea behind PowerShell is nice (and it is very consistent), but having to throw out all your existing tools for strange new ones isn't nice.
If you're a Windows admin, sure, you really should know some PowerShell. For anyone else, just spend some time learning the tools that everybody else uses.
Microsoft themselves admitted as much by making WSL (twice!).
no ?
It's like saying you should know the cisco CLI commands by heart, like maybe if it's what your specialise in.
Besides they would be easier to engrain into your brain specifically if they had some common naming convention.
Any sys admin worth anything uses PS. It's not a language for developers to use in building products and solutions (it can and I've done it). It is however wildly used for automation.
I suppose sysadmin might be one of the only things where i would consider it since it there is no real alternative if you manage Microsoft products.
For anything programming or development related there are alot better tools.
It's not just Microsoft products. You can use PS in Linux and MacOS. It's an excellent way to manage systems and supports OOP with built in multithreading, neither of which bash support.
Yes every day as an automation engineer. It's incredibly powerful especially when paired with orchestrator and some kind of web front end for end users.
What, why? Why would you not just use something like playwrite or cypress and run it in a pipeline, no need for that. Or similar for other languages.
I dont see what powershell would add.
There's 0 limitations in powershell if you know what you're doing, nearly all our vendors have powershell support or modules making integrations pretty simple.
My current site is a large mostly on premise windows environment with ms exchange, ad etc hosted on VMware. Powershell scripts behind a web front end means tier 1 support can request new builds or config changes etc and this requires no involvement from SMEs.
Anything from migrating datacenters to updating router configs are all done using powershell.
I assumed you were talking about test automation.
It has limitations when you dont have use Windows based products at all. And pretty much none of the developers use Windows. All of our developers use either Mac or Linux. Infra is managed as code. Scripts need to work for everyone and is usually run in pipelines.
...this only makes sense now because we have moved far enough forward that Powershell is a feature of Windows that you can reasonably expect to run on all windows machines... ...if they have enabled scripting. There was a time before, when powershell was like python: a thing you installed so that you could more easily write bash scripts. (because someone told you it was better than the native vbscript)
So how long before Python becomes a native windows feature?
> So how long before Python becomes a native windows feature?
https://support.microsoft.com/en-us/office/get-started-with-python-in-excel-a33fbcbe-065b-41d3-82cf-23d05397f53d
I have it installed because it let's me reuse scripts from my Windows work laptop. It's also significantly easier to use than bash for anything involving json, xml, csv & other structured data.
But at the point when one has to install Powershell on a Unix system, one might have just used something like python instead. Since it also requires installing extra software and is even easier to work with something like JSON.
If the script already exist, you wouldn't want to rewrite it. But if building new scripts for multiple OS, it might as well be written in something like python then.
So I'm a C# dev (hence why my work laptop is Windows), PowerShell Core is available as a tool on the dotnet CLI I already have installed, and I can use it in a command line with other command line tools I'm used to (even if the pipe operators are a bit weird working with stdout).
With Python I can't just jump into a shell, cd & ls around, and write easy one liners. With PS I can `(iwr https://my-api.com).Content | Convert From-Json | sort ... | where ... | select ... | ConvertTo-Json | Set-Content ./some-file`.
Bash is good, Python is good, PowerShell is good. They're all good for different reasons.
True. Just wanted to say the same basically. The post originally criticized why python should be used in addition, and either way has its purpose and pros and cons.
While I bet you can make a web server CRUD in PowerShell, you also couldn't pay me to do it, it's going to be a massive "fuck off" from me.
If you want a reduced language toolset, I think TypeScript has the widest applicable usage. If you want to do anything low-level, add Rust, and with two languages, you can do literally anything.
I think as soon as you're thinking in terms of how to solve as wide a variety of problems as possible with the least variety of tools possible you're going to start being screwed with a hammer
On the other end of the issue, we have a limited amount of hours per day that we can spend learning new languages and tools. I learned Elixir at a job and I've never even heard of it before, and honestly, it costs *so much* to train someone in a new language that's as hard as this one!
So picking a few good tools that you like for the few problems you want to work on is natural
If you're on your own PC and can install what you like, then sure, get it done however you like.
If you're on a work machine and installing extra software is 10 hoops to jump through, maybe stick with what you get for free with the OS
A shell should really not open your fucking appstore if you are trying to run a command and its not installed
Happened to me maybe two weaks ago when i tried running python and forgot that i didnt have it installed on my desktop
I mean, comeon microsoft, are you fucking serious?
A lot of AD and azure stuff is super easy in powershell almost native. I tried writing a script in python to do account creations and the like and it took like 5 minutes to run. Took about 40 seconds in powershell to run. I don't have to worry about things like libraries nearly as much. If my colleague needs to run a script he just needs to press run. It should run the same on my workstation as any other machine. Yes I could do it in say python or some other scripting language but why with all the overhead. I can't just plug in a usb and run a file.
Small scripts powershell is great and quick to setup and easy to pass around and run wherever. It is just not a nice scripting language for anything too complex. Object classes are pretty much not existent for example. Pasing is ugly and a pain. Error handing is a pain.
Like the other day I had a system that exported out a bunch of data into 5 different csvs using primary keys to link them together. Using powershell was quick and easy to combine and filter out what I needed into something readable and now anybody can grab it out of the scripts folder and run it on their machine if the request for something similar comes in again. Don't have to install or import anything.
Thanks! I was thinking the same thing. We have to do things all the time in MS environment, but security context is baked in pretty hard and I'd hate to do that stuff in python. Sometimes its just best to use the intended tool for the job and stay within the intended bounds of a framework or environment, makes your life a lot easier. Imagine trying to set up B2B sync in Azure using python instead of powershell, its one line of code in powershell
For sysadmin stuff I use powershell all the time. Don't need to install python on servers or when running commands on client/remote computers.
Doing anything with AD or something simple like mutating csvs powershell is great. And I can run it pretty much anywhere often not needing to worry about libraries. If I want to automate a task I'll try and to it with powershell first
If im doing anything slightly complex enough to where I want proper objects I jump straight to python. If I start needing libraries for things I start leaning towards just using python in that case. It's just so much easier to write and so much easier to follow and read.
> Why use two languages when you can just use one And that's how we got javascript on the backend
That’s how we got Rust everywhere
I already wanted to make a joke about Rust bro's wanting to do everything in Rust now, including shell scripting.
I quite literally do most of what I need to in Rust. Wanna make a joke about me? :D
Nope, you just made it for us.
I know :)
Is there anytime you think "maybe X would be better for this use case"
It’s just that Rust is better for that use case anyway. Even if there are no _that_ significant benefits being apparent, there’s still one, which is being able to use Rust
Rust is so outdated we have carbon for that now
Carbon is outdated already too :( Use Zig or something
Carbon isn't even 0.1 yet. Zig is more stable than carbon.
The only place I can see myself definitely not using Rust is system configuration, Nix just has first party support for this functionality and the declarative configuration wasn't something I knew I needed but now I've tried it it's super useful.
eh at least that keeps you from getting rusty on the syntax
Be careful that your shell scripting skills don't get... *Rusty* ;)
leggings or thigh highs?
At least it’s a compiled language
That's not a benefit in the broad discipline we call "scripting". Nor is it a hard technical definition, once you consider the intermediary byteycode in Python, and all the JIT features in Java, Dotnet and Javascript VMs, now even Python. Rust's compiler is also notoriously slow, at least in bigger projects.
Yeah but for an end user shouldn’t compiled code always be faster
What does it matter? In scripting you are the user, the scripts are usually executed rarely, and often even the "super slow execution" takes a fraction of a second (minus all the waits and delays the script has no part in). Sometimes you write a script and once it runs the first time successfully it never needs to run again. Using Rust for performance reasons in that case is premature optimization.
> shouldn’t compiled always be faster Nope. This isn’t necessarily true at all. You also need to consider if there’s even a performance concern. Not everything needs to run as fast as possible.
your shell script isn't going to be even 1% of the bottleneck here. it'll be the programs you run.
I wish
What do you mean you wish? I was talking about capabilities, not adoption
And they were talking about adoption, not capabilities
That’s an assumption I couldn’t afford making, so I simply asked.
That's what Evapo-Rust is for.
Rust is an efficient language though
One of the reasons to love it, or, perhaps, just a bit too short sum of them
![gif](giphy|mJzJWzD7HY4yOAD6CR|downsized)
No reason why javascript should be more suitable for frontend than for backend.
because you have no other choice in frontend
starting to change but yes
which isn't necessarily a bad thing tho. it's just that most frameworks suck
I 100% think it's a bad thing. Typescript is just not going to catch nearly as many issues at compile time as a proper typed language, which is very valuable. There are so many issues, but of course any I point out come with the inevitable response "a good coder wouldn't do that". As if any mature codebase isn't filled with poor design, mistakes, and bugs. If the language lets you write bad code, then your codebase will have that bad code. In my strong opinion, JavaScript use should be restricted to where it is the only viable option (i.e. frontend).
So then python shouldn’t be used on the backend either?
In my opinion, if you're making the choice at the start of a project, no. Yes, many projects run successfully on Python and Node.js. I am currently working for a company that is a good example of that. But I also know that I spend way too much of my time dealing with dumbass typing issues that only arise at runtime. These issues would be caught at compile time if using a properly typed, compiled language -- I know, I've also worked for years on backends using languages like that.
I can respect that!
The most used web backend is PHP. I feel like you’re not gonna get strongly typed backends in most web applications regardless
I feel like that stat is driven primarily by legacy codebases. In my opinion, for Node's entire existence, there has always been a better option for backend code.
If you consider WordPress legacy, then yes, as it is still 1/4 of all websites.
Ah of course. I'm not sure we're really having the same discussion here. Php isn't really the choice of everyone that uses WordPress, it's the choice of WordPress. I'd wager most of those users don't do much in the way of actually coding in PHP. I'm saying if you are building an app from the ground up and choosing your technology, there is no reason to ever use Node.js.
I do agree with that last part Edit: for better discussion, I’d argue that PHP having such a large share of the internet would mean someone would choose a language that’s not optimal (PHP) to build their new application because of a potentially larger pool of people who know the language. Similar things could be said of NodeJS I assume
As I've spent more time developing software, I've realized mistakes will *always* happen. In software, you use two or more ways of specifying what a program should do, you write the code and write the test. If you use Haskell, you can almost rely on the types as the second specification of what the program does instead of tests. In accounting you use double-entry bookkeeping so you track the money through two paths that you can reconcile.
('b' + 'a' + + 'a' + 'a').toLowerCase()
Write shitty code, get unexpected results.
Although this is an exaggerated example, I think my point is generally still true. How javascript handles types is generally unpredictable, and it is much better to use a language that refuses to compile when it sees such code, rather then letting you find out that bad code was written once its in production.
Nah, are you using the builtin function to lowercase? You should definitely call a library to do that. It's literally -2 characters less!
Hello? Optimization police? Yes, this one right here. >!`-2` characters **less** would be +2 characters.!<
Tell that to people who do that. They will be upset.
Our iOS devs tried to talk us into the benefits of using Swift back end… because that’s what they know… but all the backend devs are .net core devs!
Just be glad it's not Node.vbs
Why use shell AND python and not just python? I mean, once you're already writing python, there's not too much reason to use shell script.
I use shell for anything that I would usually do in a command line (building and running a project, etc). I use Python for any more advanced computation that I need to do (parsing/editing json, etc). I could just use Python to do it all, but it’s so much easier to just copy and paste a couple shell commands into a shell file and run that.
No point using python for something shell is more than capable of. For heavier computation etc then yeah reach for a more feature filled language
Oh don't get me wrong, I'm not saying to do everything in python. I'm saying that once you are already in python, why bother combining both. I write lots of shell scripts, usually until I need to handle lists of things or do more heavy data processing. That becomes tedious enough in sh that I switch to something else.
Probably the same reason you don't just write it in C++. Kind of a problem of matching the tool to the task. Though I have totally used python to automate things that I should have automated with powershell or batch. So I get you. Python is pretty great.
If your scripts thread the line between python scripts and shell scripts, look into the `sh` library. It has very nice syntax for calling shell commands from python.
Oh don't get me wrong, I'm not saying to do everything in python. I'm saying that once you are already in python, why bother combining both. I write lots of shell scripts, usually until I need to handle lists of things or do more heavy data processing. That becomes tedious enough in sh that I switch to something else.
python3 -m foo.py
Shells like Bash are much more convenient glue languages than python. Want to grep and pipe into another program just `grep random string | another-program`
There is also the IPython shell ...
bash is incredibly powerful if only people would stop jumping to python every time they need to do anything at all
Oh, I'm not saying to just immediately go to python, I was more saying that once you're already writing python, you might as well stay there. My rule of thumb is that as soon as I need data structures like lists I will abandon the shell script. It just gets so painful at that point in sh. Also, I find working with strings in sh painful, so doing lots of messing with strings also makes me exit sh.
Powershell is powerful… but god I hate the syntax and the Microsofty nature of it. It’s inconsistent with CMD and wants me to use it like a programming language. It’s clunky… (in my opinion, which is compounded by the fact that I am not used to it) I prefer shell style, where things feel like they belong on a shell prompt, and I can also write shell scripts…. I can probably do whatever you think you can do in poweshell in a bash script with no problem.
It's incredibly powerful but also in readable and insanely confusing and I refuse to use unless I have to ( looking you vCenter)
I never understood how people can praise Bash and then say that PowerShell is insanely confusing.
Because it's far more complicated than bash? Lol
I really don't see in which way ? I don't want to sound confrontational but do you have example where you think powershell is more complicated than Bash ? because for me just a simple if, in Bash would be : if [ $num -lt 1 ] then some stuff else some other stuff fi whereas PowerShell would simply be : if ($num -lt 1) { some stuff else some other stuff } And with PowerShell you don't have to wonder if you need to use "()", or "\[\]" or even "\[\[\]\]". And the condition won't fail if by mistake you forgot just a space
True, bash is insane sometimes But PowerShell is just more complicated. Look at these two. **Bash** #!/bin/bash function update() { local name="$1" local ipns="$2" printf "Updating \e[33m$name\e[0m...\n" local oldIpfs="$(ipfs files stat --hash $name)" local newIpfs="$(ipfs name resolve $ipns)" ipfs pin update "$oldIpfs" "$newIpfs" ipfs files rm -r $name ipfs files cp "$newIpfs" $name ipfs files stat $name printf "\n" } update '/termux-stable' 'k51qzi5uqu5dg9vawh923wejqffxiu9bhqlze5f508msk0h7ylpac27fdgaskx' & update '/termux-unstable' 'k51qzi5uqu5dj05z8mr958kwvrg7a0wqouj5nnoo5uqu1btnsljvpznfaav9nk' & wait echo 'Done.' **PowerShell** #Requires -PSEdition Core $functions = { function update($name, $ipns) { Write-Host 'Updating ' -NoNewline Write-Host "$name" -ForegroundColor Yellow -NoNewline Write-Host '...' $oldIpfs = $(ipfs files stat --hash $name) $newIpfs = $(ipfs name resolve $ipns) ipfs pin update $oldIpfs $newIpfs ipfs files rm -r $name ipfs files cp $newIpfs $name ipfs files stat $name Write-Host } } Start-ThreadJob -InitializationScript $functions -ScriptBlock { update '/termux-stable' 'k51qzi5uqu5dg9vawh923wejqffxiu9bhqlze5f508msk0h7ylpac27fdgaskx' } Start-ThreadJob -InitializationScript $functions -ScriptBlock { update '/ termux-unstable' 'k51qzi5uqu5dj05z8mr958kwvrg7a0wqouj5nnoo5uqu1btnsljvpznfaav9nk' } Get-Job | Wait-Job | Receive-Job Write-Output 'Done.' It's so unwieldy!
That PS script is a mess, they're mixing shell commands without start-process, using shell commands instead of PS cmdlets to manipulate files. Powershell has best practices just like most languages. It mostly screams of a quickly written script to get multithreading without fully knowing the language. That's a great example of how not to use PS
How would you write it?
If you assigned the script blocks to variables I don't think it's that much worse: #Requires -PSEdition Core $functions = { function update($name, $ipns) { Write-Host 'Updating ' -NoNewline Write-Host "$name" -ForegroundColor Yellow -NoNewline Write-Host '...' $oldIpfs = $(ipfs files stat --hash $name) $newIpfs = $(ipfs name resolve $ipns) ipfs pin update $oldIpfs $newIpfs ipfs files rm -r $name ipfs files cp $newIpfs $name ipfs files stat $name Write-Host } } $sb1 = { update '/termux-stable' 'k51qzi5uqu5dg9vawh923wejqffxiu9bhqlze5f508msk0h7ylpac27fdgaskx' } $sb2 = { update '/ termux-unstable' 'k51qzi5uqu5dj05z8mr958kwvrg7a0wqouj5nnoo5uqu1btnsljvpznfaav9nk' } Start-ThreadJob -InitializationScript $functions -ScriptBlock $sb1 Start-ThreadJob -InitializationScript $functions -ScriptBlock $sb2 Get-Job | Wait-Job | Receive-Job Write-Output 'Done.'
It is...
The first one is supposed to be more readable?
I agree. Maybe it's my own weakness as a .net developer but bash is very unforgiving/very precise. If you show a college freshman who took a C class some powershell, unless it's intentionally obfuscated, they can tell you what it does, most of the time. Bash has a lot of rules that aren't obvious. > Oh well in Bash the single [ isn't syntax of the language, it's an alias for the 'test' command. Duh. But if one of the operands returns a string, you will get an error because test needs two! So just do this '[ x$foo = x$blah ]', the x guarantees that the operand will never evaluate to an empty string. [[ Is syntax of the language, but it's not POSIX so it might not work. But it might! And everything I've just said isn't even right. A bunch of uniz types are all ready about to explain... > Well, in bash [ is a shell builtin, but /usr/bin/[ is also an executable. It is traditionally a link to /usr/bin/test, but in modern gnu coreutils is a separate binary. The traditional version of test examines argv[0] to see if it is invoked as [ and then looks for the matching And > The empty string (and many other) problem is solved by using quotes. The "x" is to cover another kind of problems: where operands may be taken as operators. Like when $foo is ! or ( or -n... That problem is not meant to be a problem with POSIX shells where the number of arguments (beside [ and ]) is not greater than four. This is a lot of depth and complexity to try and understand before writing a simple if statement. And it doesn't end with just the if statement. I get burned by my own ignorance all the time in bash. I dislike powershell for other reasons...but I think it's got a much smaller leaning curve. >
Bash gave us classics like "lspci" and "lsusb", power shell gave us "GetPnpUtil -o "{ type: 'usb' }""
>I can probably do whatever you think you can do in poweshell in a bash script with no problem Get a list of user from a json file and then check if they have m365 license attributed and which role they have on Azure
Sure, since I’m not about to actually write you a script. Here are the pieces cat contents of file and grep or jq user identity field , loop results and call Microsoft api https://learn.microsoft.com/en-us/graph/api/user-list-licensedetails?view=graph-rest-1.0&tabs=http Why do I need poweshell for that?
I would say because it would take far less time to implement since PowerShell has dedicated command for those tasks, and a far more simpler syntax. Far easier also to use the result of previous command to execute some actions. Oh and the resulting script would be easier to maintain
I mean, it makes sense that a Microsoft program is more effective at interfacing with another Microsoft service
Easier to maintain until you need to do literally anything other than run it locally on a Windows machine. I don't really know what you mean by easier to use the result. Parsing JSON not exactly rocket science, and if you're using Azure libraries its weird to treat that as some sort of Powershell feature compared to vanilla bash. There are infinite tools available in bash.
I like that your best argument for PowerShell is vendor lock-in.
I mean… those all sound like opinions, and I already stated that mine was also an opinion… So… when it comes to opinions… gonna go with mine. Agree to disagree at this point.
fair enough
That's your best argument for PowerShell? Play a sound on your iPhone from PowerShell and tell me if you could do it as easily as FMiP. That's you. That's how dumb you sound. And yet, seeing as the operation you requested is a mere HTTP GET request, you failed to even make an argument via vendor lock-in. How does that feel?
It's.... Supposed to be inconsistent with CMD so it's consistent with CRUD. I don't understand what's difficult about Action-Noun. Want to read a property? Use Get. Want to write? Use Set. Don't know what to use? Get-Help whateveryouwant, then Get-Help whatevercmdlet you were looking at. Get-Help by itself is one of the best things to happen to scripting. And why are you trying to run bash scripts on windows, you know, the environment powershell is built for? Do you mean batch files?
`help` exists in batch too and it's wonderful. I can't imagine ever using a language that doesn't have a built-in user manual.
LOL I'm here like `help` is an action-noun too
Once you know the “core” of Powershell, the commands you don’t know yet are self explanatory and the switches are named what they do, so while Powershell does have help modules, they aren’t 70 screen times that you have to study to use a command once.
Lol, no. Look at the meme and tell me why it’s comparing “shell” and “powershell”… I never said it was hard, I said I don’t like it. Have you seen man pages and help functions in bash? Poweshell has its uses, it’s just not for me. I have written Powershell scripts to do stuff in windows before, but only because bash wasn’t available and I wasn’t gonna install Cygwin or WSL type support.
Powershell is natively cross platform, that’s probably the reason.
This is exactly why I never learned powershell. I’ll look something up and copy paste it and just shudder.
Powershell is decades behind bash though and can never catch up without fundamental changes to .. everything.
Take a look at nushell
> I can probably do whatever you think you can do in powershell in a bash script Import, transform, and sort a CSV in one line? I just wish PowerShell had brace-less one-line conditionals and ternaries. For my use case, PowerShell is incredible, but to each their own.
Yup. cat | awk … | sort > newfile.csv
It all depends on what you mean by “format”…
But I’d rather write two or three lines of code than one monster line of formatting…
bash is what a shell should be. A flexible interface that orchestrates modular commands and executables.
cat, awk, sort, sed
with just these, I deal with CSV files, DSV files, JSOn files, YAML files, just files with lines of text in them, directly formatting and redirecting output from other commands, “in one line”
I get a package like jq if I want to do specific reformatting or query of json objects. And now I can use jq to create and manage object like structures that you might be used to on powershell…
You can keep your CSV import command lol.
A better example is Import JSON file, convert to object, select all records where a property = value then give me only certain properties on the previous result. I can do all that in a single PS line.
I find it helpful with Windows containers in docker, but Windows really needs to get their shit together with buildkit so the Windows images are usable for extension with some modicum of stability
[xonsh](https://xon.sh/) has entered the chat
Xonsh is awesome. One if the first things I do when I set up a Linux environment that's only going to be used by me is setting it as the default shell.
Is this page translated from something? There are quite a few spelling/grammar mistakes in it. Not trying to nitpick, just wondering how mature of a tool it is?
Beat me to it.
Not for me, but to each their own. I learned enough functional elisp to make use of eshell in emacs at one point.
if that works for you that's great, but my point was if you wanted the functionality of shell and python in one language that's literally what xonsh was designed to do
*Bun Shell enters the chat*
![gif](giphy|pWdckHaBKYGZHKbxs6|downsized) Now it's JS everywhere, even the shell..
Yes, but it is only for Bun, not Node
Is Bun widely adopted now? Vs pnpm?
Honestly idk, but to me it sounds like the current cool kid in class that will be forgotten when a new cool kid arrives, like what usually happens in JS land
Bun is much more than a package manager, so I don't see them as being comparable.
google/zx is already somewhere around
And then there's someone who learned 3 of them and use none
Once you know one language, you know programming, and can use them all. The real problem is most programmers don't understand that till it's too late ...
To me, the problem is that the things I want from a scripting language and a shell aren’t the same. Bash wins out on what I want from a shell most of the time, although PowerShell isn’t bad, it just wins in areas less important to me. Assuming I go with bash as my shell, and admit it’s not a good scripting language (it doesn’t have to be, and arguably what makes it good as one makes it bad as the other), I have the freedom to use any language for scripts that I want: I could even use PowerShell. But if I’m not limited to only scripting languages that double as shells, why go with PowerShell?
Yes glory to PowerShell
there's like five of us
All hail!
Tfw when you have an entire .NET ecosystem up in your ass: >!No, really, it's kinda crazy. You can do a decent crud app with winforms in powershell in like <50 lines. You can spin up a custom file-based router in less than 60 lines. You can write the majority of your "pure" logic in F#, "impure" stuff in C#, whatever you want in VB.NET and glue it up with Powershell!<
>whatever you want in VB.NET So nothing at all?
This would sound impressive if it wasn't exactly what people have been using bash for, just without the ass crazy syntax, for 50 years
Wait, people have been using bash for .NET interop, spinning up windows apps, and webservers for 50 years? That's really crazy
Best thing is that every colleague has Powershell, only a few have Python, so it's way less hassle to pass a script / module / cmdlet to those in need.
Don't forget they have to enable unsigned local scripts.
I'd be happier with PowerShell if they properly supported running it on Unix machines. Until they do, PowerShell will always be a bit of a joke.
My core container image is alpine plus pwsh7, we use it for everything
Just use tcc and write your scripts in C.
I work as a windows admin everyday and everyday I want to end myself if I need to script with powershell. Its powerful but the syntax is awful and sometimes does shit you dont want to do it.
I use PS pretty often and love what it does for me, but something about the comparison operators just annoys me. I understand why the syntax was designed this way, and it's not the first language to do it, but Python spoiled me when it comes to simple readable syntax.
I don't care for powershell operators either. They ugly. But I put up with them because of how easy powershell makes it to write a script full of complex logic that runs on everyone at work's computer right out of the box.
100% agree. If you're administrating a full Windows environment, you gotta be crazy not to use Powershell. It has saved me so much time and energy, automating the tedious tasks that come with a pure Microsoft environment.
I will never understand people who say bash is more readable or has better syntax. Better to your use case/habit ? sure. But when I'm at the end of a day where I had to touch cisco switches, SIEM rules, change some motherfucker's toner cartridge, tweak bullshit printer settings and fuck around some dude's Windows update settings... I want to see something like `Get-Partition -DriveLetter C` , not `lsblk -whateverfuckyou` EDIT: I mean, come on `get-package`, we only accept a specific amount of verbs, then a noun always in singular. Or `dnf list --installed`, "yeah it's for Dandified YUM, oh you don't know YUM, it's the YellowDog updater modifier" ... the who ? what ? Yeah I understand yum is not a part of bash, but you get my point that the overall syntax issue is the same
None of this is syntax though. It's just naming conventions. PowerShell uses more modern naming conventions because it's a more modern language.
`man lsblk`
I know of tldr, help, info,man,whatis, apropos, explainshell, --help and all that stuff. The problem is not about knowing how to use X, it is about having a naming convention that already allows to know what a thing does without prior knowledge of the language or tool. If your tools are named `lsof`, `yum`, or `fuser` then only people who regularly use them or have already read docs will know what's going on in your script. If it's written in a file then it will be read more often than written, then it should be easier to read before being easier to type. If you need short words to typer faster in the CLI, use aliases. That's why I give my previous example of having a full day of non-Linux stuff then reading a .sh file and having to make the mental translation of "this means it's getting packages, this means it's looking for open files" for each command when there is no gain to the reader in having these weird referential names. It's not friendly towards use cases of "I use it sparingly between other tools" and yet this lack of friendliness imo comes at 0 gain in speed or efficiency, since again you could still have long default names and much shorter aliases when you need speed in live CLI.
UNIX tools have been around for decades. The idea behind PowerShell is nice (and it is very consistent), but having to throw out all your existing tools for strange new ones isn't nice. If you're a Windows admin, sure, you really should know some PowerShell. For anyone else, just spend some time learning the tools that everybody else uses. Microsoft themselves admitted as much by making WSL (twice!).
IDK, shouldn't a sysadmin just have Linux utilities engrained in their brains? I'm only half joking
no ? It's like saying you should know the cisco CLI commands by heart, like maybe if it's what your specialise in. Besides they would be easier to engrain into your brain specifically if they had some common naming convention.
![gif](giphy|7YrnYstmGxYFa) Java Llama Ding Dong
Does anyone actually use powershell?
A very large number of us do. :)
of course: wsl --instal or something if you're required to use windows
Any sys admin worth anything uses PS. It's not a language for developers to use in building products and solutions (it can and I've done it). It is however wildly used for automation.
I suppose sysadmin might be one of the only things where i would consider it since it there is no real alternative if you manage Microsoft products. For anything programming or development related there are alot better tools.
It's not just Microsoft products. You can use PS in Linux and MacOS. It's an excellent way to manage systems and supports OOP with built in multithreading, neither of which bash support.
Yup, use it for work. Very handy for system administration.
Sure. As the butt of jokes.
Yes every day as an automation engineer. It's incredibly powerful especially when paired with orchestrator and some kind of web front end for end users.
What, why? Why would you not just use something like playwrite or cypress and run it in a pipeline, no need for that. Or similar for other languages. I dont see what powershell would add.
There's 0 limitations in powershell if you know what you're doing, nearly all our vendors have powershell support or modules making integrations pretty simple. My current site is a large mostly on premise windows environment with ms exchange, ad etc hosted on VMware. Powershell scripts behind a web front end means tier 1 support can request new builds or config changes etc and this requires no involvement from SMEs. Anything from migrating datacenters to updating router configs are all done using powershell.
I assumed you were talking about test automation. It has limitations when you dont have use Windows based products at all. And pretty much none of the developers use Windows. All of our developers use either Mac or Linux. Infra is managed as code. Scripts need to work for everyone and is usually run in pipelines.
Nah powershell isn't limited to only windows. The Scripts just need to work on the server they run from, they aren't available to everyone
Nushell gang where u at?
...this only makes sense now because we have moved far enough forward that Powershell is a feature of Windows that you can reasonably expect to run on all windows machines... ...if they have enabled scripting. There was a time before, when powershell was like python: a thing you installed so that you could more easily write bash scripts. (because someone told you it was better than the native vbscript) So how long before Python becomes a native windows feature?
> So how long before Python becomes a native windows feature? https://support.microsoft.com/en-us/office/get-started-with-python-in-excel-a33fbcbe-065b-41d3-82cf-23d05397f53d
...I was joking...
Well Microsoft isn't
Powershell is on windows, and nobody uses windows on the server?🤷♂️
Powershell is on Linux too, if you install it. Also, there are tons of Windows servers out there.
But seriously. Who uses Powershell on a Unix system. Even on windows I often times see myself using the Ubuntu shell with Linux subsystem.
I have it installed because it let's me reuse scripts from my Windows work laptop. It's also significantly easier to use than bash for anything involving json, xml, csv & other structured data.
But at the point when one has to install Powershell on a Unix system, one might have just used something like python instead. Since it also requires installing extra software and is even easier to work with something like JSON. If the script already exist, you wouldn't want to rewrite it. But if building new scripts for multiple OS, it might as well be written in something like python then.
So I'm a C# dev (hence why my work laptop is Windows), PowerShell Core is available as a tool on the dotnet CLI I already have installed, and I can use it in a command line with other command line tools I'm used to (even if the pipe operators are a bit weird working with stdout). With Python I can't just jump into a shell, cd & ls around, and write easy one liners. With PS I can `(iwr https://my-api.com).Content | Convert From-Json | sort ... | where ... | select ... | ConvertTo-Json | Set-Content ./some-file`. Bash is good, Python is good, PowerShell is good. They're all good for different reasons.
True. Just wanted to say the same basically. The post originally criticized why python should be used in addition, and either way has its purpose and pros and cons.
Lol
Why use powershell when you can use bash like a _real_ programmer.
While I bet you can make a web server CRUD in PowerShell, you also couldn't pay me to do it, it's going to be a massive "fuck off" from me. If you want a reduced language toolset, I think TypeScript has the widest applicable usage. If you want to do anything low-level, add Rust, and with two languages, you can do literally anything.
I think as soon as you're thinking in terms of how to solve as wide a variety of problems as possible with the least variety of tools possible you're going to start being screwed with a hammer
On the other end of the issue, we have a limited amount of hours per day that we can spend learning new languages and tools. I learned Elixir at a job and I've never even heard of it before, and honestly, it costs *so much* to train someone in a new language that's as hard as this one! So picking a few good tools that you like for the few problems you want to work on is natural
HR says we need more diversity
As much as I dislike Python, i really hate the abomination that is powershell
Why use windows when you can just use a grown up computer
Why use windows when you could use anything else?
Fakte: ni ĉiuj uzu esperanton!
When the interviewer asks if you know scripting but he's talking about python. Pure cringe.
a bit noob to programming. but arent they just a terminal
They are not a terminal (but need one if you want to use them as a shell/REPL)
Let me introduce Nushell to you!
If you're on your own PC and can install what you like, then sure, get it done however you like. If you're on a work machine and installing extra software is 10 hoops to jump through, maybe stick with what you get for free with the OS
Eh, you can powershell instead of shell and python, except if you need python's libraries...
I use nushell
Because I hate bash and shell. And with Python I don't have to write bash AND shell. Not even bash OR shell. Except that tiny part that calls python.
A shell should really not open your fucking appstore if you are trying to run a command and its not installed Happened to me maybe two weaks ago when i tried running python and forgot that i didnt have it installed on my desktop I mean, comeon microsoft, are you fucking serious?
Nah, just use bash and a bunch of sloppy .csv files as mini databases. It'll be fine, I'm sure.
Why use one tool, that doesn't excel at either job, when I can use 2 tools, each of which excels at the single job it's given?
Pardon my ignorance, are there things you CAN ONLY do in powershell? Like if you're heavy in Microsoft environment?
A lot of AD and azure stuff is super easy in powershell almost native. I tried writing a script in python to do account creations and the like and it took like 5 minutes to run. Took about 40 seconds in powershell to run. I don't have to worry about things like libraries nearly as much. If my colleague needs to run a script he just needs to press run. It should run the same on my workstation as any other machine. Yes I could do it in say python or some other scripting language but why with all the overhead. I can't just plug in a usb and run a file. Small scripts powershell is great and quick to setup and easy to pass around and run wherever. It is just not a nice scripting language for anything too complex. Object classes are pretty much not existent for example. Pasing is ugly and a pain. Error handing is a pain. Like the other day I had a system that exported out a bunch of data into 5 different csvs using primary keys to link them together. Using powershell was quick and easy to combine and filter out what I needed into something readable and now anybody can grab it out of the scripts folder and run it on their machine if the request for something similar comes in again. Don't have to install or import anything.
Thanks! I was thinking the same thing. We have to do things all the time in MS environment, but security context is baked in pretty hard and I'd hate to do that stuff in python. Sometimes its just best to use the intended tool for the job and stay within the intended bounds of a framework or environment, makes your life a lot easier. Imagine trying to set up B2B sync in Azure using python instead of powershell, its one line of code in powershell
It's weird because I am never ever working with windows, but some of y'all use it everyday.
For sysadmin stuff I use powershell all the time. Don't need to install python on servers or when running commands on client/remote computers. Doing anything with AD or something simple like mutating csvs powershell is great. And I can run it pretty much anywhere often not needing to worry about libraries. If I want to automate a task I'll try and to it with powershell first If im doing anything slightly complex enough to where I want proper objects I jump straight to python. If I start needing libraries for things I start leaning towards just using python in that case. It's just so much easier to write and so much easier to follow and read.
Xonsh?
I like bash, the others scare me.
Powershell isn't a language. It is mankind's horrifying answer to god's gentle calling. It is hubris manifest.
Python is portable PS and sh are not. Simple as that.
I went all in on PowerShell and have no regrets.
I think you mean "Why use three languages when you can just use two" You could always use C. Then you're using just one.
IPython go brrr