5 ms·
Wow all the bash hate. It takes practice and repetition like with most programming languages. I have no problems writing for loops in bash because I do it all t
by loloquwowndueo 4y ago
Wow all the bash hate. It takes practice and repetition like with most programming languages. I have no problems writing for loops in bash because I do it all the time. Similarly if it’s something I don’t use frequently I will feel the syntax is arcane and unintuitive and have to look it up anyway.
It’s fine to prefer one tool over the other but bashing the one you’re less familiar with is unnecessary :)
- HyperSane 4y ago"It takes practice and repetition like with most programming languages. " Except with Bash it really isn't worth it. Learning PowerShell is much better for long scripts.
- redox99 4y agoPowerShell might be better, but it won't be already installed in your typical Linux environment.
- supernovae 4y agodnf install powershell
- loloquwowndueo 4y agoYou can put that in a bash script because guess what - bash is already there ;)
- tolciho 4y ago$ bash /bin/ksh: bash: not found strike one... $ pkglocate powershell | grep \^power $ strike two...
- hulitu 4y agodnf: Bad command or file name :)
- selfhoster11 4y agoThat's not "already installed"
- supernovae 4y agodoes it really matter? no.. absolutely not.
- noncoml 4y agoSome arguments would be nice…
- Supermancho 4y agoDiscussions about syntax devolve rather quickly into arguing about sources, because there are so few studies done and everyone has an opinion (or cause). Bash syntax is horrid and that's enough for me. Just wait a couple decades and languages slowly improve or they die. Sometimes it takes a long time (in comparison to a person's lifespan) and that's ok.
- deleted 4y ago[deleted]
- bscphil 4y agoEven giving an opinion would be something. What's something you like better about PowerShell? I can easily say something I dislike about it: This form `Verb-LongNoun` for function names used in PS is somewhere between alien and maddening. It's difficult to type, difficult to remember, and isn't an obvious improvement over `lowercasename` which is typical of basically every other shell. I guess the idea is that you don't have to worry about naming collisions with programs in your path? That's never been an issue for me when writing shell scripts though, not even once.
- vips7L 4y agoYou don’t have to use Verb-LongNoun. PowerShell will fuzzy match as long as it’s not ambiguous. Verb-L might be enough. If you’re in an interactive shell they’re already aliased to shorter forms like “gal” for Get-Alias or “gci” for Get-ChildItem. I’m not OP but things I like about PowerShell: - Objects instead of text - The entire C# std lib is accessible - One tool with the same UX vs several different tools with different UX.
- wruza 4y agoWow, your first paragraph alone is why I’ll never even touch PS.
- loloquwowndueo 4y ago“Really isn’t worth it” - hearsay. It totally is. Also - power shell is better for long scripts, you say, but what are you going to use for short ones? I’m not buying what you’re selling tbh.
- HyperSane 4y ago" hearsay. It totally is." No it is an opinion, and IMHO the RoI for time invested in learning bash is far less than Python or Powershell.
- hdjjhhvvhga 4y agoI'm not sure if it's sarcasm but in case you are serious, Unix shell has been around for over 50 years and its variants are installed on millions systems around the world, and it's still the fastest way to accomplish simple tasks on these servers. PowerShell is something vastly different.
- smcameron 4y agoYou're out of your f'n mind.
- rr808 4y ago> It takes practice and repetition like with most programming languages To me the issue is why learn a different language for scripting? Python is the obvious replacement, but even Java write scripts in, I'm pretty sure any major language can compile and run easily.
- zaphirplane 4y agoThe ergonomics of calling other commands filtering and piping the output is better in sh, till some complexity limit and error tolerance Of course python comes with its own package management and system version clashes
- the_third_wave 4y agoNot to mention a slow startup problem, a pipe of python tools spends some significant time there where (ba)sh is close to instantaneous.
- krageon 4y agoPython is a great language, but not if you want to glue together shell commands. It is very verbose and quite obviously not a first-class citizen. That is what you use bash for.
- chriswarbo 4y agoRunning one command after another is trivial in most languages. The hard part is pipelines, which are inherently concurrent. For example, to pipe one subprocess into another in Python requires spawning off separate threads to shuttle the data around (there are libraries which make this easier, but then your scripts will require a package manager...). Shells are pretty decent at piping and spawning subprocesses. They suck at anything algorithmic, numeric, etc. Thankfully those tasks can usually be handed off to a separate tool (e.g. classic Unix text processing tools, like sed/grep/cut/etc., or more recent data processing tools like jq, mlr, etc.)
- rr888 4y agoRight, I really meant in a proper programming language you'd use high level libraries to do this work, rather than shelling sub processes. You wouldn't need sed/grep/cut.
- wruza 4y agoI remember how to write loops and conditionals for most of the languages I’ve used for practical purposes. I can even write decent perl after 15 years of not using it. But for some reason bash couldn’t stick and I google it every time. It’s obviously my laziness, but it probably has natural causes.
- loloquwowndueo 4y agoAnecdata is anecdata and I’ll counter yours with mine: I almost never have to google bash syntax (I do for things like arrays which I don’t use often). So no, there are no “natural causes”. Face it folks, it’s not bash’s fault if you use it seldom enough that you need a reminder of the syntax when you do. Nothing wrong with that!
- bigDinosaur 4y agoArrays are pretty basic. I won't have to Google how to create an array in Python for the rest of my life - I've done it in Bash and I've forgotten every single time. I think I had it memorised permanently for Python within about five minutes. I think when I find myself using arrays in Bash (or Powershell) it's usually time to take a step back and reevaluate.
- imtringued 4y agoI use bash frequently and I can't remember the syntax. I think your comment convinced me to never use bash again. Now onto finding a replacement... If people say they use bash because it is preinstalled they can go screw themselves. Install whatever replacement I'm going to pick and shut up.
- loloquwowndueo 4y agoI’ve heard good things about fish. Some of my colleagues swear by zsh.
- shultays 4y agoI have no problem writing brainfuck either. Once you get used to it and developed your building blocks for developing more complex algorithms, it is really easy!
- amelius 4y ago> Wow all the bash hate. It takes practice and repetition like with most programming languages. Except I have no issues with other programming languages. Bash is really different. I only tolerate it because it comes pre-installed on just about every system.
- loloquwowndueo 4y agoI have issues with lisp because it’s really different. I could never grok it. I don’t go around swearing off it and calling it names like people do with bash. :)
- amelius 4y agoYour "different" and my "different" are different :) I also have issues with COBOL. Sometimes a language is just too inelegant to pour time into learning it.
- loloquwowndueo 4y agoYes - like Java. And yet people learn it.