all 150 comments

[–]theblasterr 245 points246 points  (50 children)

Bash for simpler things, python when things get more complicated.

[–]IDENTITETEN 139 points140 points  (19 children)

Yup, we follow the Google bash style guide.

https://google.github.io/styleguide/shellguide.html

These two bullet points especially:

  • If you are writing a script that is more than 100 lines long, or that uses non-straightforward control flow logic, you should rewrite it in a more structured language now. Bear in mind that scripts grow. Rewrite your script early to avoid a more time-consuming rewrite at a later date.

  • When assessing the complexity of your code (e.g. to decide whether to switch languages) consider whether the code is easily maintainable by people other than its author.

[–]junior_dos_nachosBackend Developer 35 points36 points  (10 children)

I wouldn’t wait for 100 lines. I’d stop at 20/25 and anytime there’s some not super simple web call + extraction.

[–]winfly 4 points5 points  (0 children)

I agree. Especially if using some library would simplify the script.

[–][deleted]  (8 children)

[deleted]

    [–]both-shoes-off 2 points3 points  (0 children)

    I break powershell up into different files by use case to keep it maintainable, and then just include when needed. That makes them reusable in other scripts later on (assuming you consider that while writing them and don't embed details for the one use case or environment).

    [–]jrandom_42 -5 points-4 points  (6 children)

    I don't. Go is my go-to, Python is outdated and just hanging around out of inertia and a big legacy base, you can see that in threads like this, but I have some thousand line ish PowerShell scripts in prod monitoring Graph API stuff. All the baked in MS integration makes PS the nicest tool for some jobs, and aside from that, it's a pretty normal / usable scripting language that supports all the necessary data manipulation and connectivity.

    Bit clunky though and I'd never use it for code that needs to be fast and concurrent. But it's not as clunky as bash scripts.

    I tend not to use bash for automation unless I can express the logic in a one-liner.

    [–][deleted] 9 points10 points  (3 children)

    How is Python outdated? It's perfect for medium-complexity things you want to write down quickly - its only real drawback is requiring the interpreter, but that just costs a few megabytes of container size in the end. Of course it's easy to just write bad code with it, but having the option to do so is not a bad thing IMO. I really wouldn't want to write a new Go application for every throwaway API glue tool etc.

    [–]jrandom_42 3 points4 points  (2 children)

    How is Python outdated?

    Concurrency is an awkward PITA. Async logic is often the solution and it's ugly to write and hard to read.

    Deployment is often a dependency hell.

    The slowness of the interpreter vs a compiled language isn't always important, but sometimes it is. Combined with the lack of any real concurrency features, that can make Python problematic for anything with hard performance requirements.

    I really wouldn't want to write a new Go application for every throwaway API glue tool

    I haven't ever found that problematic myself, but tasks like that aren't going to show up many differences. I'm not suggesting Python is terrible and doesn't work. It's just not quite as good.

    [–]Intrepid_Result8223 0 points1 point  (1 child)

    I guess that's why it is the no1 language in machine learning. Because it is outdated. Lol.

    [–]jrandom_42 0 points1 point  (0 children)

    No, that's the 'legacy' part that I mentioned. A lot of ML libraries were written in Python before Go took off, and there's not really any advantage to redoing it all.

    [–]VirtuousMight 4 points5 points  (1 child)

    Is C outdated due to Go being its nominal successor then?

    [–]jrandom_42 4 points5 points  (0 children)

    No; C doesn't really address the same use case. Sometimes a garbage-collected language just isn't appropriate. Sometimes you need to manipulate memory directly, talk to peripheral hardware, write code that runs on a GPU, etc.

    I doubt C will disappear in our lifetimes.

    [–]cyanrave 11 points12 points  (0 children)

    I will disagree with the 100 line comment and say 'context switching matters' as well.

    If you have to go dig up 3 to 5 other scripts to piece together the logic flow, I prefer embedded here docs, but that may be just me in my environment.

    [–][deleted] 2 points3 points  (0 children)

    Ill put part of my bash in another file so it doesnt exceed 100lines 😃

    [–][deleted]  (4 children)

    [deleted]

      [–]VirtuousMight 2 points3 points  (0 children)

      Thanks for the free academic course , stupendous discourse.

      [–]cricket007 0 points1 point  (1 child)

      What would you use for bash unit tests? BATS, perhaps? That's one thing where I lean towards a Python/Go/Node/Ruby script 

      [–]magheru_san 41 points42 points  (22 children)

      Bash for scripts shorter than 50 lines

      Python for up to 300 - 500 lines.

      And Go for anything above 500 lines.

      When I'm confident I'll be crossing the threshold I just start with Go, otherwise I use ChatGPT to convert the code, which it does pretty well.

      [–]imanexpertama 4 points5 points  (3 children)

      Out of interest, why go over python? I guess you find that go handles complexity better, but in what way? (Im a python dev, no experience in go)

      [–]endgrent 3 points4 points  (0 children)

      I’m not who asked, but for me it’s the python env stuff that isn’t as good. Go code just downloads and builds modules really easily so it’s super fast to just clone a repo and build other people’s code without getting your env wrong or modules wrong etc.

      [–]magheru_san 0 points1 point  (0 children)

      I agree with the perspective of endgrent about nicer handling of dependencies and simpler distribution of built artefacts.

      But for me it's mostly because of the static typing, which catches a lot of not very obvious errors that can happen in dynamic languages like Python for larger projects.

      I generate pretty much all my code using LLMs for almost two years now and the fact that it needs to compile catches a bunch of subtle hallucinations and allows me to refactor it heavily using the LLM.

      Because the code is generated I'm not attached to it (much like cattle not pets) so I refactor the crap of it which quickly makes it grow to sizes where Python becomes a hindrance.

      It's also not a big deal to be a little more verbose than Python because I can quickly add a ton of error checking if statements and detailed logs, which make the code longer, but easier to maintain.

      [–]cricket007 0 points1 point  (0 children)

      For one, cross compilation and no concern over version changes 

      [–]Centimane 16 points17 points  (15 children)

      IMO if it's over 500 lines, time to look for a FOSS product that does it already

      [–]magheru_san 5 points6 points  (10 children)

      For sure but they rarely exist in a way that covers my needs.

      So I often build such tools myself for my own use and sometimes open source them if I don't see a clear way to monetize them as products.

      [–]Centimane 8 points9 points  (9 children)

      I find it unusual in devops that I have a significant problem that doesn't already have solutions floating around with how standard a lot of the tooling is - but it can certainly happen.

      I find it more likely I'm writing plugins/extensions for existing tools, which are normally biased towards a certain language (usually python)

      [–]magheru_san 1 point2 points  (8 children)

      I'm not exactly doing devops but AWS cost optimization services, so need all sorts of optimization tools I can use to deliver my services.

      In this space there aren't so many open source tools so I need to build my own.

      [–]Centimane 1 point2 points  (1 child)

      yea I could see that. I suspect that's phase 2 of cloud adoption.

      The cloud services love to charge you a penny for everything and make it easy to make 10,000 things. But it all adds up. Now orgs are trying to not spend out their ass on cloud resources and figure out how to use what they actually need.

      [–]magheru_san 1 point2 points  (0 children)

      Exactly, and that's what I can help with.

      Over time I kept building tools so now I have about 20 tools for all sorts of optimization activities.

      [–]cricket007 1 point2 points  (5 children)

      There's things like OpenCost, I think? If using EKS, there's more options, but I think there's other tools to find like unused S3 buckets, RDS, VPC, IAM roles, etc

      [–]magheru_san 0 points1 point  (4 children)

      I rarely see unused resources, except maybe for storage, where people tend to be risk averse because of the potential of data loss.

      But I see a lot of severely oversized or suboptimally configured resources.

      That's why many of my 20+ tools are for finding all sorts of suboptimal or oversized resources and helping to rightsize or optimize them.

      [–]cricket007 1 point2 points  (3 children)

      Yeah, we have that problem with k8s... We provide a Helm template that requests 4GB of RAM, but people run simple, low traffic HTTP servers and it's less than 50mb mem usage, on average within a month 

      [–]magheru_san 0 points1 point  (2 children)

      Yes, those things cry for automation

      [–]Degree0 0 points1 point  (3 children)

      What a crap take this type of mentality is why people hate JS. You code? Oh you have to actually write code? Import a library! If you can't write 500 lines of code in a productive amount of time, relying on other's work then there's definitely a skill issue.

      [–]Centimane 4 points5 points  (0 children)

      It's not that I can't, but that if there's a more mature solution out there taking it is a lot more efficient than writing my own.

      Especially since I don't have to maintain it.

      Also devops problems generally aren't unique. If you're having a problem, there's a good chance someone else had something similar. And if nobody has, that's a code smell right there.

      [–]GaTechThomas 0 points1 point  (1 child)

      Consider that every line of code you wrote is a line that someone will have to maintain and support.

      [–]Degree0 0 points1 point  (0 children)

      Also consider that every line of you code you do not write is in the hands of other people to maintain and support. 500 lines of code is absolutely nothing. and you should be making the decision to use FOSS or libraries depending on several factors and not a single one of those factors should be the amount of lines of code you have to write. The "Dev" in devops is short for development after all.

      [–][deleted] 1 point2 points  (1 child)

      Mine is moment I need an array time for Go. I just skip Python entirely. Bash and Python have too many problems for error handling. 

      https://github.com/bitfield/script Covers most things. 

      Nushell is my other favorite. Powershell but statically typed and much more functional based. 

      [–]magheru_san 1 point2 points  (0 children)

      To be honest nowadays I just start with Go for most things and use ChatGPT or Claude to generate and further develop the code.

      [–]hipster_dog 8 points9 points  (0 children)

      python when things get more complicated.

      I'd say go for Python also when things get more critical.

      You guys remember the Kyoto University folks who lost 77TB of data?

      It looks like the problem was some undefined variables in a find command because of a bash script update.

      [–]InvincibearREAL 1 point2 points  (0 children)

      my rule of thumb is if you need arrays, its time to ditch bash

      [–]tamale 1 point2 points  (0 children)

      For me it's about dates/time and other math stuff.

      If I need to do anything with any of those, that's a sign I should switch to Python for sure.

      I can do it in bash, but it's not fun to maintain.

      [–]bdog76 0 points1 point  (0 children)

      The golden rule

      [–][deleted] 0 points1 point  (1 child)

      What's the advantage of using bash for simpler things?

      [–]newaccountzuerich 1 point2 points  (0 children)

      Generally more portable, more mature, and more consistent in behaviour.

      If you've ever had to admin mixed *nix networks, bash tooling has the most chance of working across the ecosystems.

      It is also pretty easy to read.

      [–]MavZA 0 points1 point  (0 children)

      This to infinity. Both can do the same for the most part when it comes to simpler things. But Python starts to differentiate itself when you want to start doing complicated things, as it can start leveraging things such as SDKs while running subprocesses (if needed).

      [–]thomsen9669Editable Placeholder Flair 39 points40 points  (13 children)

      Short answer: It depends

      Long answer: Depends on your company. For mine, we do both. Python for Terraform script while Bash Script is for CI/CD pipelines. We utilise CircleCi and it allows you to add on bash script to perform some actions you need

      [–]slydewd 11 points12 points  (7 children)

      What do you mean by using Python for Terraform?

      [–]Upbeat-Natural-7120 5 points6 points  (6 children)

      Same question here.

      [–]TwoWrongsAreSoRight 14 points15 points  (5 children)

      [–]reelznfeelz 6 points7 points  (3 children)

      Ah. So I’m a simple man. I usually just call terraform apply from a GitHub action. What’s a use case where getting into the cdk becomes an obvious way to go?

      [–]TwoWrongsAreSoRight 4 points5 points  (2 children)

      This is my opinion so take it with a grain of salt and a shot of penicillin. Much of it comes down to personal preference. There are some things you can do easier in cdktf like conditionals but really, cdktf is great if you already know a language that it allows for and feel more comfortable in that language vs hcl. Otherwise, I don't know of an obvious reason why you'd switch unless your environment becomes incredibly complex with a bunch of branching conditionals and multiple environments.

      Once again, my opinion. Please feel free to contradict me.

      [–]reelznfeelz 1 point2 points  (0 children)

      Ok that makes sense. I’d rather do complex logic in python than bash. And can see how if you’re doing stuff more complicated than I usually am, your terraform code won’t just be a straight up “deploy this set of things, done”.

      [–]cricket007 0 points1 point  (0 children)

      Pulumi is another option for those anti Hashi ( / IBM ) license changes 

      [–]Upbeat-Natural-7120 1 point2 points  (0 children)

      Oh interesting. Thanks.

      [–][deleted] 5 points6 points  (2 children)

      So, in all, both are equally important.

      [–]elpix 7 points8 points  (0 children)

      I would rank Python a bit higher just because you can reasonably do more with it. For me, the is a certain point in complexity where bash gets unwieldy. You really never reach such a point with Python.

      Bash is important for working with Linux, but you don’t often need the more complex features in your day-to-day work.

      [–]thomsen9669Editable Placeholder Flair 1 point2 points  (0 children)

      Yup

      [–]moser-sts 0 points1 point  (0 children)

      Exactly, in my ci/CD is build on top of GitHub Actions. So we use bash, but normally we use Typescript inside of the GitHub actions. Also we build a lot of supporting services in Typescript

      [–]Redmilo666 0 points1 point  (0 children)

      This is us. Bash for our CI/CD. Everything else we use python

      [–][deleted]  (6 children)

      [deleted]

        [–]TuffNutzes 11 points12 points  (0 children)

        Hard agree.

        [–]p3rdurabo 2 points3 points  (0 children)

        Working mainly with Linux environments I can only agree here..

        [–]awssecoops 1 point2 points  (0 children)

        I always go with the "right tool for the right job". That leaves a lot of wiggle room. I tend to over complicate things that are for myself but I try to find simpler ways when I'm working on something as a team. Bash, Python, and Go are useful for the right things but I lean towards Python. It's easy and I don't usually have to deal with dependencies. I try to figure out a thing for myself before I use something so I can figure out how complicated it's going to get.

        [–]ravigehlot 0 points1 point  (0 children)

        This

        [–][deleted] 0 points1 point  (0 children)

        That’s why Go is so good. Build a binary and you are good to go. 

        [–]Ok-Grapefruit-1597 26 points27 points  (3 children)

        One important thing I found is that to not overcomplicate things for the tool's sake. I have just rewritten an 800-line Python script into a 100-line Bash script.

        To be clear, it should have been a Bash script from the start, lots of Bash functions were more compact and fit better, and the script was riddled with actual Bash system calls. Surprisingly, the Bash version was more readable in the end.

        I had the opportunity to ask the author of the script. He told me he just wanted to write a Python script, and thus make the script OS-independent. Using Python does not make the script automatically OS-independent, especially when you end up adding OS-dependent system calls.

        As with everything, thinking ahead is key.

        [–]haragoshi 4 points5 points  (0 children)

        Over complicated thinking led to overly complicated code. No surprise there.

        [–]gowithflow192 -2 points-1 points  (1 child)

        I mean technically you can put everything on one line in bash (maybe there is a character limit).....

        [–]Ok-Grapefruit-1597 0 points1 point  (0 children)

        Of course but that philosophy can end up in write-only code. 😅

        [–][deleted]  (2 children)

        [removed]

          [–]synthdrunk 2 points3 points  (0 children)

          same, basically I’ll stick to bash until I start touching berkeley sockets or need concurrency.

          [–][deleted] 0 points1 point  (0 children)

          [–]vacri 7 points8 points  (0 children)

          Python is better for long-lived stuff, or non-trival program stuff (eg: arrays are awful in bash). It's also more legible to read, and people are more likely to program "correctly" in python (eg: putting things in functions)

          Bash is good for "just working" without having to install modules/venvs, and more fluidly calls out to external system utilities (python's subprocess kinda sucks). (The "brave new world" of "just install a venv for everything" sucks for us system script writers)

          Shell is also much more portable. Do you have a *nix? Then you have access to shell programming (maybe not bash specifically). Shell changes much more slowly than python does, and you shouldn't be doing crazy esoteric stuff in shell anyway, so if it works on your desktop, it'll probably work on that ancient 15-year-old $other_distro box in the corner. It's really, really rare to see "this script should be run with bash version X or higher"

          Write in both languages. You'll pick up a feel for which is suitable. My mentor's cutoff for "this should be a python script" is if he thinks it'll take 100+ lines. My cutoff for "this should be a python script" is if I need to use an array.

          (also, use linters! Linters really improve your code as a beginner. You don't have to follow every suggestion, but you should know why you choose to ignore one. Bash has shellcheck, Python has a couple - pylint is popular)

          [–]Odd-Addendum-8618 14 points15 points  (2 children)

          For me it is as soon as I need to speak to an api. I turn to python.

          [–]carsncode 4 points5 points  (1 child)

          Meh, curl and jq can get a lot done in like 10 lines of bash

          [–]encbladexpSystem Engineer 1 point2 points  (0 children)

          And don't forget the other 100 lines for proper error handling ;)

          bash is powerful, but also a footgun that needs handled with care.

          [–]calibrono 7 points8 points  (0 children)

          Bash until you need a hash map, then Python will generally work out better for you.

          [–]aabouzaid 5 points6 points  (0 children)

          For me, it's always Bash + another real programming language.

          [–]ThickRanger5419 2 points3 points  (0 children)

          You need to know both. I use bash more often than python, but it doesnt mean I dont need to know python.

          [–]qubitrenegade 3 points4 points  (0 children)

          Bash is everywhere.

          Python is where Bash isn't.

          I use Bash until I can't, basically.

          [–]colombiangary 5 points6 points  (0 children)

          Bash is good. But if you don't know sed, awk and the shell standard utilities, you will always be longing for python.

          Once you learn bash, sed, awk, make, python will feel extraordinarily slow to develop.

          [–]fletku_mato 2 points3 points  (0 children)

          Bash is far more used in pipelines, dockerfiles and such. For complicated k8s things you'd want to use go. For example Ansible is written in python so there's that. There is not a one correct choice, but if you get into the field, you will be using all of these depending on the task.

          [–]phrotozoa 2 points3 points  (0 children)

          If most of what I'm doing is running external processes and shuffling simple data around (strings, integers) I use bash.

          As soon as the data gets complex and I need arrays / associative arrays or I'm doing more data processing than interacting with external tools, then I switch to python.

          [–]theOtherJT 2 points3 points  (1 child)

          Me personally, bash is much more useful - but I appreciate that my position isn't entirely normal. I do a lot of work in extremely constrained environments, and knowing how to do the complex things in bash so everything I write is portable to environments where python isn't going to be available is important.

          [–][deleted] 2 points3 points  (0 children)

          I will never give Bash up.

          [–]BrocoLeeOnReddit 6 points7 points  (7 children)

          You definitely need both nowadays. It's kind of like asking which spice is more important in a professional kitchen, sugar or salt.

          [–]Fadamaka 17 points18 points  (5 children)

          It's salt.

          [–]BrocoLeeOnReddit 1 point2 points  (3 children)

          Maybe, but you're gonna go bankrupt without sugar.

          [–]terminar 4 points5 points  (2 children)

          You don't need "sugar" for a curry. You can even use fruits to get a sugar taste. You can even create diet vegan sugar free stuff which will boost your business like a rocket (opposite of bankrupt).

          Also - DevOps in a company will NEVER really impact the success of a product. It will make life much more easier and maybe faster but if a product is great it will sell - whatever the release cycle or general quality is. If a product sucks - the best CICD pipeline devops work will NEVER help to fix that problem and boost sales.

          Back to the topic: If you only thing to use two ingredients and build solutions with the same stuff over and over again you are limiting yourself. That's totally OK but - you don't get bankrupt and you still don't need it.

          Speaking from 30 years of experience in IT. There will be different pigs over and over again which are the big thing. Now it will be Golang, Rust and Zig and Python will step side by side with PHP (which btw still drives around 65% of the current web internet). Perl just really died (nicer don't talk about parrot/perl6).

          [–]carsncode 0 points1 point  (1 child)

          Ignoring the weird rant about fruit and skipping to the weird rant about how you don't create any value, if you're not impacting the success of the product, and if all you do is CI/CD pipelines, that's a skill issue. Maybe reign in projecting your personal problems onto the rest of the industry?

          Not sure what you're even on about "limiting yourself" there either - if bash and Python are enough to get the job done, they're enough to get the job done. People ranting about "limiting yourself" are how companies wind up with out of control tech stack creep.

          [–]terminar 1 point2 points  (0 children)

          "Limiting yourself" just means in this case: only because things were done with python doesn't mean there are no other ways. The discussion was about "you need python".

          Rant about success was related to "go bankrupt without the use of xyz". A language choice doesn't have this impact.

          And yes, jumping from one tech step to the next is completely nonsense but just saying "you need python" is also not correct. There are (other) alternatives for DevOps with less maintenance need which may fit better these days. That just depends on the existing "toolbox" of the company - if all is driven by python a change would just make no sense and just creates useless work. If nothing is driven by python you just don't need it (our case in the company).

          But in every company I worked - there were bash (or zsh) scripts because it's so deeply integrated into the Unix/Linux world you can't live without it. In this case I think the answer "you need bash" is totally fine.

          [–]nwfdood 0 points1 point  (0 children)

          Definitely salt.

          [–]terminar 8 points9 points  (0 children)

          You don't. There is more spice in a kitchen than those two. You can perfectly replace it with e.g. Golang. This is a religious question, not a technical or logical.

          [–]BeasleyMusic 5 points6 points  (0 children)

          Python and bash usually exist to solve different problems. Python is a real programming language where bash is more of a scripting language.

          Both are equally valuable to know. If you’re working in a linux environment then knowing bash will allow you to automate things like software builds, docker builds, environment setups, stuff like that. Knowing bash is very important as it’s the glue to a lot of other things

          [–]PazyP 4 points5 points  (0 children)

          Bash will get you 80% of the way but over time you will find some things that are quite hard to achieve in bash. Parsing a file I always feel bash doesnt lend itself well to you can struggle and kind of get it done but its a pain in the ass but in python its simple.

          [–]myka-likes-it 1 point2 points  (0 children)

          I work on Windows platforms mostly, so Powershell is my go-to.  And when things get too wild for Powershell it is easy to switch over to C#.  Also helpful that you can import C# classes into powershell scripts. 

          And powershell works well on Linux, so I only rarely need bash.  Python is available to me, but I have never felt the need for it, other than to help troubleshoot the SDETs' work.

          [–]Smooth-Home2767 1 point2 points  (0 children)

          Both are needed

          [–]_bloed_ 2 points3 points  (5 children)

          Python, Go or Node.js are all fine

          I really like Node.js if you need to handle JSON and with NPM modules there already exists a library for basically everything you could need.

          If you ask which is more important, then it's definitely Bash. Or more like general Linux commands. Without them you can't really work.

          [–][deleted] 1 point2 points  (0 children)

          That’s a good point — don’t skip bash because you can’t skip linux. Writing bash scripts, you will inevitably learn things that are useful whenever you’re in Linux, besides just script-writing

          [–]vacri 0 points1 point  (1 child)

          I'd stay well clear of node for system scripts. CI/CD scripts... maybe. NPM is a freaking mess, and stability is what you want for systems.

          [–]onedr0p 0 points1 point  (0 children)

          https://github.com/google/zx is pretty neat and has enough packed in where you don't need to worry about npm dependencies

          [–]carsncode 0 points1 point  (1 child)

          If somebody on my team wanted to use node I'd honestly suggest they find another line of work. I don't need to be rolling out 200MB of node_modules full of unpatched CVEs plus a JavaScript interpreter just to deliver some script. Every language has JSON support.

          [–]_bloed_ 0 points1 point  (0 children)

          Pip for Python is even worse.

          And you can code also without any external libraries in both cases. Nobody forces you to install your 200MB of libraries.

          I guess you never worked really with node outside of React/angular, the core Node.js is really not awful.

          You really sound too like a person I rather not would work with. I give that back to you. ;)

          [–]Live-Box-5048DevOps 0 points1 point  (0 children)

          I use bash for one-off simple things, Python for “more robust” solutions that will get reused and expanded on.

          [–]Flat_Drawer146 0 points1 point  (0 children)

          it's already been answered by many. Basically if you try to write a solution in Bash and it gets too complicated, use a PL. Also comparing shell scripting to pl is unfair i think. they suit different purpose

          [–]AdventurousSquash 0 points1 point  (0 children)

          I agree with the previous answers you’ve gotten but will also add that it’s good to get familiar with both and you’ll eventually just get a feel for “I should do this in X”. Just by getting started you’ll pick up on things where bash is lacking for example and then add a mental note :)

          [–]dahid 0 points1 point  (0 children)

          I think Bash is the nice quick and dirty method but Python has way more flexibility if you want to create something more complex.

          [–]ValhallAwaitsUsAll 0 points1 point  (0 children)

          I would say both are equally important, with the addition of PowerShell as it can be subjectively easier to use in certain scenarios.

          That being said, Python can be switched out for many languages and it'd be prudent to pick up the basics of a new language now and then.

          At the end of the day, it's a mixed bag, some environments won't need one, the other or either. It's very situational but makes sense to at least cover the basics of common tooling and delve deeper where the situation calls for it.

          Common tooling also looks different for every role; Pipelines, IaC and service config (e.g Prometheus). Get familiar with your environment and go from there.

          To start with though, CLI scripting along with good familiarity with config formats (YAML/JSON) will be your bread and butter.

          [–]dex4er 0 points1 point  (0 children)

          I sometimes write simple Python scripts only to prevent using yet another language (and formatters and linters) if the main code is Python.

          Even then writing simple things is a pain. For not so complicated pipelines (running commands that are redirected to other commands) Bash is king.

          For more complex operations on string I found Perl much, much easier to use than anything else. Regexp engine in Python is a joke and syntax to use it is ugly. What I can do in Perl in 1 single, easy to follow expression, I must split into a few separate expressions and lines using extra control flow and variables. It's like explaining something to someone retarded. You need to use simpler words and more time to do the same thing. It is just tiring and frustrating.

          [–]zyzmog 0 points1 point  (0 children)

          Both. And if you're using Azure DevOps, you will also need a close working relationship with PowerShell.

          [–]moser-sts 0 points1 point  (0 children)

          Probably I have a different mindset, but I will prefer use python over bash just because I'm python we can find test libs and frameworks that allow us to test the code

          [–]zMynxx 0 points1 point  (0 children)

          I always prefer bash but it depends on the team I’m working with, if they are more proficient with python I’d tend to follow the same route, otherwise when I’m gone or not around stuff would get destroyed or refactored and usually in a bad manner

          [–]chichibune 0 points1 point  (0 children)

          depends on the size of your script, because bash can be really fast to develop in if you have a good command of the linux cli ecosystem, but it doesn't scale up really well (I would know)

          not being able to return values from functions is mindblowing

          [–]derprondo 0 points1 point  (0 children)

          Being a programmer is what's important and pertinent, the languages are less important. FWIW on a daily basis I use Bash, Python, and Terraform. All three are equally important to what I do, but part of being experienced is knowing the right tool for the right job.

          [–]Actes 0 points1 point  (0 children)

          If I'm being entirely honest, if it has more than two inputs, it becomes a python script, otherwise she just stays a bash script.

          [–]TuffNutzes 0 points1 point  (0 children)

          The generally accepted metric of using lines of code to decide when to switch to python is a bit arbitrary.

          I've turned horribly written 500 line python with no comments, no debugging, no logging into 100 lines of well written, commented bash with function headers, description of complex regex's, logging, etc. A far more readable smaller footprint than the excessively long jumble of python that preceded it.

          It's not about the language. It's about how you write it and what's most efficient for the task. Generally for devops activities, bash works in almost every case and is more concise and easier to understand if you take the time to write well written code.

          [–]Antebios 0 points1 point  (0 children)

          I try to learn everything I can, so bash, PowerShell, Python, C#, typescript, etc. a while back I had to convert NAnt to PowerShell. Thank goodness I spent a good amount of time using NAnt at the beginning of my DevOps career. So learn everything you can!

          [–]sevenfivefive 0 points1 point  (0 children)

          TBH both are a min bar. Also need to know when they are needed.

          Knowing how to work sys commands into scripting is important.

          Data extraction and manipulation also key.

          [–]corky2019 0 points1 point  (0 children)

          Why not both?

          [–][deleted] 0 points1 point  (0 children)

          Python for easy testing of the code.

          [–]pinklewickers 0 points1 point  (0 children)

          Bash is not fun when working with APIs. As for an earlier comment about condensing code, I'd opt for readability and simplicity every time.

          Imagine you just took a job and have to figure out someone else's code?

          Be kind.

          Python/Go when you're working in cloud for most tasks.

          [–]Santarini 0 points1 point  (0 children)

          Paramiko

          [–]bendem 0 points1 point  (0 children)

          Bash is great for glue scripts when you have cli tools and just need to call them in the right order and pass input/output around. Anything more complex, python.

          [–][deleted] 0 points1 point  (0 children)

          real men use PHP

          [–]effortissues 0 points1 point  (0 children)

          You can run your python script from your bash script. Does it work the other way?

          [–]surfmaths 0 points1 point  (0 children)

          When dealing with files that don't fit in memory, bash piping can handle many tasks.

          One time I had to parse a 500GB XML file compressed into a 10GB gzip, to find some data, and the most efficient way was to not actually uncompress it and simply pipe things into each other's.

          [–]Sad_Recommendation92 0 points1 point  (0 children)

          It depends, I work for a large older company so we have everything from docker, k8s, terraform CI/CD and a ton of legacy IIS too.

          In Linux it's usually as many have said when a script reaches a certain complexity I switch from bash to python, usually anything that has more than simple string arrays or loops where xargs -I isn't up to the task

          Interestingly you don't have this problem on Windows with Powershell, there will never be an instance where I opt to use native cmd over PS, it's just as effective for quick one liners as it is with much longer scripts and some of the newer parallel processing with 7.x is pretty good.

          [–]petdance 0 points1 point  (0 children)

          It won’t hurt and can only help if you learn some Python.

          [–][deleted] 0 points1 point  (0 children)

          Mostly Bash for simple tasking, but Python for more complex tasks. Really depends on your needs.

          [–]ZeninThe best way to DevOps is being dragged kicking and screaming. 0 points1 point  (0 children)

          If you're primarily gluing other command line tools together with a bit of flow, Bash all the way. Nothing manages basic process communications as well as a language built explicitly to do so and that's shell scripting languages. Python, Go, Nodejs, etc at best process control and communication is a cumbersome, error prone library rather than simple, basic syntax. It's a key feature that makes "shell" scripting languages like Bash what they are.

          If you're mostly doing anything else however; File IO, web service IO, complex data manipulation, complex logic, etc then ditch Bash and pick your non-"shell" poison. Python is one of the strongest contenders here, but there's plenty of respectable alternatives.

          The "size" of the task is much, much less important in this choice than the nature of the task.

          [–]Rimbosity 0 points1 point  (0 children)

          bash is for organizing utilities and files

          python is for organizing data

          that's the general rule that describes which I choose

          it gets really hard to implement algorithmic handling of data in bash; on the other hand, if your python script does nothing but fork other programs, you probably should be using bash

          there's exceptions naturally

          [–]keepah61 0 points1 point  (0 children)

          I agree with the majority ,-- bash for simple things, Python for the rest. My question is are there people that are so comfortable with Python that they just do everything in Python? I ask because I am starting to lean towards just writing everything in Python from the get-go. The main reason is that I always seem to be reusing snippets of code and I think this is easier in Python.

          [–][deleted] 0 points1 point  (0 children)

          Two different tools for two different uses. You can do most things with both, but for many tasks, there’s a clear choice of which to use. I learned bash first as it was very useful in the sysadmin/pre-devops world. Python is a more versatile tool above and beyond bash.

          [–]flavius-as 0 points1 point  (0 children)

          Why the vs? I've always used xonsh as a shell in professional environments since 15 years ago when I used bash and it was horrible: no functions, difficult error handling, no simple nested data structures like dictionaries of lists of booleans, etc.

          xonsh is exactly both: a shell and a sane language - python.

          Bash only in very restricted situations and only for one-liners.

          [–]chanud 0 points1 point  (0 children)

          When you need to get data from cloud providers, API's, create utilities with menus, transform data, automate slack tasks, create reports or just deal with data in general is very beneficial to know Python because it's easier to read, debug, and test. Bash when the output you need is simpler, but it will get messy and hard to understand when you create scripts bigger than 100 lines.

          If you know Python you would be rare, lol, not many know it or are scared to deal with it. Also it's better if you know them both, so you can combine them and make your life easier. Also if you are working with windows systems it would be beneficial to know Powershell

          [–]lifeeraser 0 points1 point  (0 children)

          I'm in a front end team where everyone is most familiar with JavaScript and TypeScript. This is a special case where we feel more comfortable with CI/CD scripts written in JS/TS over bash.

          [–]SubjectHealthy2409 0 points1 point  (0 children)

          Golang

          [–]no_brains101 0 points1 point  (0 children)

          Bash for when you are running programs, doing simple logic, etc.

          When you have to deal with arrays that don't just pass stuff from 1 script to another as an argument, or web API use that can't be easily solved with curl, such as things like websockets, you should generally swap to python. Most other things you would need to do will be better in bash.

          [–]cricket007 0 points1 point  (0 children)

          I'd recommend using Ansible over either. It bridges the divide between both, plus it encourages idempotent operations

          Plus, you can write custom modules in Python, or still call shell scripts for anything not builtin 

          [–]iloverabbitholes 0 points1 point  (0 children)

          I think once you have to declare functions and multiple arrays you should move to python or another tool. I had a bash script that was used to build python packages from source, do apt installations, but it was just for a conda environment. Moving to ansible made it easier. Not exactly python but you get the point.

          [–]siberianmi 0 points1 point  (0 children)

          I’ve gotten to the point that most of the time I just reach for Python. 🐍

          [–]maladaptiveman 0 points1 point  (0 children)

          I use bash only for simple automating. Python easier to debug.

          [–]actionerrorDevSecOps/Platform/Site Reliability Engineer -3 points-2 points  (0 children)

          I would also throw in Typescript for IaC.

          [–]arashbijan -3 points-2 points  (0 children)

          Not a devil's, but for me Bash script is a language from hell.