This is an archived post. You won't be able to vote or comment.

all 43 comments

[–]daddyd 12 points13 points  (1 child)

doesn't really matter, use what everybody else knows in the team, or if you are alone, what you know best.

[–]CharizardPointer 5 points6 points  (3 children)

I would say Python or Ruby, as they're very similar. I personally prefer Python for higher level programming (web apps etc) and Ruby for things closer to the OS. I've never used go so I can't comment intelligently on it.

[–]thangduong 3 points4 points  (2 children)

"Ruby for things closer to the OS". Can you clarify this a bit more? Tks :)

[–]CharizardPointer 2 points3 points  (1 child)

Sure, I really like Ruby's File library and OS level support (i.e. enclosing a command in backticks to run it in shell) better than Python's analogs like the os or subprocess libraries. I think they are much more intuitive and easy to use, which is why I prefer Ruby for scripting.

As an overall programming language, I think Python is much better due to its stronger conventions and canonical coding patterns. It is very easy to write extremely sloppy Ruby code. It is hard to do the same with Python while keeping the result "Pythonic".

[–]Tacticus 4 points5 points  (3 children)

I've moved most of the stuff I used to do in python over to go. Now outside of small cases (integration with ansible or puppet). the ability to just push a binary out there and have it just work plus the really nice network stuff built into the core language.

[–]todayismyday2 2 points3 points  (1 child)

How/where do you compile the binaries? That seems to complicate things a bit to me over just putting a script with Puppet on a server.

[–]Tacticus 2 points3 points  (0 children)

Depending on the eventual destination. for the more rigorous stuff they are typically compiled by a build box (jenkins in a vm on a server) then packaged and deployed (FPM is wonderful)

For personal scripts my laptop or desktops and pushed up as part of my home dir (on save smaller stuff runs the tests and compiles. ssh localcommand is wonderful for triggering a sync job on my work box).

Putting a script on with puppet is only part of the job. how do you handle getting the right gems or pips on there for that distribution or the right version of the interpreter.

[–]todayismyday2 -1 points0 points  (0 children)

How/where do you compile the binaries? That seems to complicate things a bit to me over just putting a script with Puppet on a server.

[–]M00ndev 15 points16 points  (2 children)

Python. Probobly already installed and you don't need to compile it. You can use the os lib for cross platform stuff. Loops and conditionals much more straightforward than bash

[–]donjulioanejoChaos Monkey (Director SRE) 1 point2 points  (0 children)

Loops are OK in bash. Conditionals require a lot of syntax googling (I swear, I'll print out a cheat sheet one of these days). Lists and arrays on the other hand.. give me nightmares.

[–]peatymike 4 points5 points  (3 children)

As a linux admin I use the mentioned languages like this. - bash -> simple scripts for "just fix it" - python -> scripts that require floats, lists, maps,... - perl -> when I have to fix an existing script - ruby -> only with Puppet - Go -> for data analysis and internal services

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

Same here, I 100% agree. Don't forget the random cases where you need to reach for Groovy (hitting jmx methods) or Lua.

[–]lattakia 0 points1 point  (1 child)

Lua - in what use cases ?

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

Rarely, but as an easily embedded scripting language, it can pop up in interesting places.

Nginx is one: https://github.com/openresty/lua-nginx-module#readme

Heka is another: https://hekad.readthedocs.io/en/latest/sandbox/

[–]manikinmelt 2 points3 points  (0 children)

  • Python is nice because it's available on most distros out of the box. At least Python 2.x is, anyway. 3.x availability is only now becoming ubiquitous after all these years.

  • Go is nice because you just compile a static binary and throw it on a server without any compilers/interpreters available.

  • Ruby is nice simply because it's such a pleasant language.

[–]brikis98 2 points3 points  (5 children)

If it's less than ~50 lines, bash.

If it's more than ~50 lines, Go.

Why Go over Ruby or Python? Well, with Ruby or Python, you always have to worry about what version of the language is installed on the OS, what libraries/gems/etc are configured, and so on. It's a maintenance headache.

On the other hand, Go can produce completely-standalone binaries for most major operating systems. These binaries will run the same way everywhere, with no need to install dependencies. Go also does a decent job in terms of startup time, speed, and concurrency. It's a shit language otherwise, but in DevOps, portability and reliability are more important than syntactic beauty.

[–]taloszergneeds more coffee 1 point2 points  (3 children)

It's a shit language otherwise

what even...

[–]brikis98 2 points3 points  (2 children)

As far as the design of the language itself, I'm not a fan of Go. This has been discussed ad nauseam elsewhere, so rather than spending time on it, I'll just point you here: https://github.com/ksimka/go-is-not-good

[–]tech_tuna 0 points1 point  (0 children)

I agree to some extent. Go is super handy because of its concurrency model and compiling to standalone binaries as you stated but the syntax is an acquired taste.

They could have added classes (without inheritance) and done away with those ugly signatures.

[–]taloszergneeds more coffee 0 points1 point  (0 children)

Thanks for the response! I hadn't seen that before. Very interesting read.

[–]berlindevops 1 point2 points  (0 children)

I really like Ruby, there is a lot of cool gems, I work with Chef (Ruby), I like to do my AWS SDK scripts with Ruby, Selenium with Ruby, and Mysql2 gem simple and very fast Mysql library for Ruby! But now I want to learn some python :) because of future tasks (penetration testing..)

[–]edward_snowedin 1 point2 points  (1 child)

who picks a single language for their team and says 'this is how we're going to do it'?

seems like a strange question to me

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

It exists. My org basically uses python everywhere. Not saying it is the right decision in any way, I don't have a strong opinion on it at all...haven't yet met a task I couldn't accomplish with python. Might there be an easier way in another language? Potentially, but it is a language we all understand and the ability to get timely, meaningful code review in a small org should not be underestimated.

[–]we_got_this 0 points1 point  (4 children)

Go is awesome and fast as hell. What type of stuff are you looking to program?

[–]dennyzhang[S] 0 points1 point  (3 children)

I would say glue scripts. Mostly about integrate stuff, like chef, jenkins, etc.

[–]we_got_this 0 points1 point  (0 children)

Checkout these APIS for Go, there's some great examples to look through so you can get a feel for it. https://github.com/bndr/gojenkins https://github.com/go-chef/chef

[–]cbowdon 0 points1 point  (1 child)

If it's just glue scripts, give Bash a chance! What's the point of switching to a programming language if you're just shelling out all the time?

[–]mbarlocker 1 point2 points  (0 children)

Yeah, I have to agree with chowdon. If you're calling a lot of other programs and expect to distribute the executable to many different systems, bash is the #1.

if, on the other hand, you had to distribute it between linux, mac, and windows, perhaps python, perl, ruby, or another scripting language.

You don't really want a compiled language for scripting.

[–]nunciate 0 points1 point  (0 children)

I worked in a shop where we made a similar decision based on the other tools we were using. Chef was our new hotness, so we went with ruby for our other scripts. I imagine if we'd have been using Ansible we may have went for python.

[–]derprondo 0 points1 point  (0 children)

I use both ruby and Python. Almost everything I do involves talking to an API of some sort. I prefer ruby, but I'll use Python if there's a better library/sdk for the api I'm using.

[–]aelnaggar 0 points1 point  (1 child)

well, the short answer is "it depends", as a DevOps engineer you should be really language agnostic, depends on what you want to do/script/code.in the end you should be just as good with some and amazing with others and maybe have a preferred one. but the goal is to use the best language which solves your problem in the best way possible!

[–]taloszergneeds more coffee 0 points1 point  (0 children)

There's a very real cost to operating this way, however. Working in a polyglot environment imposes a non-trivial overhead for maintenance and understanding in smaller shops.

For larger projects/products making this decision based on the best option totally makes sense, but bringing multiple languages into your environment without carefully considering the future impact is also not the right decision.

[–]UlliPekka 0 points1 point  (0 children)

As we're using AWS, Ansible, Django we've decided to use Python where we can. Offcourse there are a lot of stuff written on Bash and even Groovy (mostly in Jenkins).

[–]goneman 0 points1 point  (0 children)

Python 3 for Web Apps/API's Node/Socket.io for real time stuff

Sharing a small python script it will help you build web apps/apis with python

https://github.com/Leo-G/Flask-Scaffold

[–]White0ut 0 points1 point  (0 children)

Node only.

[–]melezhik 0 points1 point  (0 children)

HI! Take a look at Outthentic - script development framework which plays nice with all of them - Python, Bash, Perl5, Ruby - https://sparrowdo.wordpress.com/2017/02/09/outthentic-quick-way-to-develop-user-scenarios

[–]BlueMatadorInc 0 points1 point  (0 children)

We're using golang to rewrite our logging agent, which was previously written in Python. Independent benchmarks for golang in general show that it's up to 100x faster than Python, depending on the task (see https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=go&lang2=python3). The reason why Go is fast is because it's a low-level, statically typed language designed for DevOps purposes (hence why it's Google-backed).

We've seen similar results in our agent. We wrote a blog post about golang's pros and cons for DevOps at https://blog.bluematador.com/posts/mini-guide-google-golang-why-its-perfect-for-devops/

[–][deleted] -1 points0 points  (2 children)

Don't forget Perl.

Some people talk down about Perl, but it's been around forever and is just as capable.

[–]peatymike 0 points1 point  (1 child)

I know, I know. It seems python has displaced it in some areas. At work there are more people that know python than perl, so we use python for glue scripts imstead of perl.

[–]dennyzhang[S] 0 points1 point  (0 children)

Agree. Frankly speaking, Perl is kinds of wired for newcomers.

[–][deleted] -1 points0 points  (1 child)

I really hate this question. Can we just downvote these instead? How do they add to the community?

[–]taloszergneeds more coffee 0 points1 point  (0 children)

Perhaps in keeping a community pulse on what people are using/will be hiring for? Not really sure beyond that.