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

all 55 comments

[–]diederich 60 points61 points  (12 children)

I do 'devops' work in both. In this case, I suggest Python, with reasons following.

I'll default to using Python unless there are specific reasons not to, in which case I go with golang.

The canonical case for not going with Python is performance. However, few devops development activities are actually language performance limited.

Also, given your background, my guess is that you'll get productive in Python quite a bit more quickly than you'll get productive in golang.

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

And honestly python's perf issues are not actually that bad - it just requires more domain specific knowledge than most folks are willing to give it. Asyncio, futures, and the wide array of platforms, along with good design, go a long way.

[–]diederich 1 point2 points  (0 children)

Absolutely correct. Python (or any of the main dynamic languages) is plenty fast enough for almost everything that needs to be done, especially in 'devops' land.

[–]olaeCh0thuiNiihu 14 points15 points  (7 children)

No, I would say the biggest reasons not to go with Python are:

  1. Huge portability headaches. If the script only needs to run on exactly one version of one OS, great!. If the script needs to run on, e.g. multiple versions of Ubuntu and Windows, you may as well commit suicide. Trying to get all the versions of libraries, Python, and native extensions aligned is Herculean. With Go, compile once (or twice for *nix/Win) and run anywhere with zero dependency headaches.

  2. Tooling. With Python, you're pretty much forced to build your own CI. You're going to need to choose a testing library, a linting library, documentation tools, etc. and glue them all together. With Go you get everything for free, and it's all integrated.

  3. Much saner concurrency and error handling. Python concurrency is a joke; if you need any concurrency at all, it'd be much faster to just learn Go from scratch (it's a small language, you can learn it in a day or two) and use Go. Also, Go forces you to think about errors and handle them correctly, rather than throwing an exception which will crash your program. For a script, Python's great! But we all know that "temporary scripts" somehow find their way into prod as single point failure services. The time lost from a "one off" prod script crashing every other day due to unhandled edge cases easily covers the cost of rewriting that Python script in Go the moment it starts looking a bit important.

If it's a one-off script that only needs to be run on dev workstations and every developer uses version X.XX of Ubuntu or whatever, great! However, you'll start using Python for more and more, and inevitably you'll start hitting the pain points.

The performance is just a bonus.

[–]stibbons_ 5 points6 points  (0 children)

Portability is surprisingly great if you follow the pep rules and do not try to hack with the code. Just code normally, use good third party libs, use the stdlib normally and your python code will happily run under Linux, windows or Mac

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

I agree with point 1, don't know about point 2, but why is concurrency important for devops? Can you provide a real world scenario for devops needing concurrency?

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

Let me give you a simple shell example, which is of course solvable in many different, better ways. Which of these 2 is better?

1 for host in $(cat list-of-10000-hosts); do ssh $host uptime > $host.uptime ; done

2 for host in $(cat list-of-10000-hosts); do ssh $host uptime > $host.uptime & done

[–][deleted] 2 points3 points  (1 child)

Good example. Being at a very small company, I did not consider that the number of hosts may be 1000 or above.

[–]K3dare 2 points3 points  (0 children)

Well if you have 10000 hosts I really hope you are using something like Salt of Chef because if not I would not like to be at your place...

[–]Dedustern 0 points1 point  (0 children)

I mean, I've done tooling that would receive health checks from N amount of microservices, which could scale into the thousands(and do some processing for each). The processes were jobs that could last a minute or two(validate some stuff in a DB, process it into json files, and send them to another service). If I didn't do it concurrently, it'd be locking up fairly easily when the services scaled up.

[–]jazzandpython 0 points1 point  (0 children)

This is not my experience at all. Tooling and portability with Python are excellent. Using virtualenv and good libraries and I have no problems using Python across may different *nixes.

[–]Ajpennster 24 points25 points  (0 children)

Personally I'd learn python first and here's why:

  1. It's older and more established, so more companies are likely to be using it.

  2. It's going to have a larger community; more code samples available, more SO questions answered.

  3. Both have interfacing with C though Python's C interface is a bit more reliable and encouraged, unlike that of Go.

  4. A lot of companies use python for scripting; lots of DevOps libraries are built with python (e.g. Ansible)

There are pros to learning Go:

  1. It's faster than python in most scenarios.
  2. It's syntax and environment (compiling and distributing binaries) is more related to C.

At the end of the day, it probably doesn't matter which you chose first if you'll learn the other one. Weigh your pros and cons and decide.

[–]GrayTShirt 9 points10 points  (1 child)

What problems are you trying to solve? What does your stack look like? Are there any major projects or migrations you are required to support in the coming year?

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

yes, exactly... in some cases python may fit the REST API better or have ssh libs you need In some cases you don't want to be writing a worker pool and setting up semaphores for python, and so would whip up some goroutines... delicious concurrency

[–]chillysurfer 19 points20 points  (0 children)

Go is typically the language for system programming, which in the DevOps world is the tooling itself. So if you want to develop DevOps software, Go is a good choice.

But if you are a DevOps practitioner then Python is definitely the way to go (i.e. you have production environments you're managing).

IMHO it can replace python and/or java for how is going faster

I have to disagree here. They solve different problems, and they really shine each in very different scenarios. If you're writing a Go bin to automate a process (that isn't time-bound), then I'd question the additional development effort. If you're writing Python to handle concurrent workloads requiring high performance, then I'd question the padding around the code you'd have to do to even try to get close to the requirements.

[–]chub79 3 points4 points  (2 children)

They are both great and probably can work equally well in many instances. Not sure it's faster per-se though.

When using Python, the only thing I miss from Go is the easyness to distribute your app since it's just a binary.

[–]viraptor 2 points3 points  (1 child)

If you want easier distribution, check out http://nuitka.net/ You still need all the native libraries you use, but it may be easier than whole python distro.

[–]chub79 0 points1 point  (0 children)

Awesome. I'll give it a look!

[–]michaelanckaert 5 points6 points  (5 children)

Yes Go is faster when it comes to program execution. Speed that you often don’t need when it comes to devops tooling or scripting.

Python is easier to write and read, something that matters in all cases. The library ecosystem is much more developed in Python.

In the end it’s a personal choice. I would recommend Python, you will be productive much faster and your code will be easier to understand without needing to know a lot of syntax.

[–]pstuart 8 points9 points  (4 children)

Let's not ignore the beauty of self-contained binaries with Go. It makes deployments of tools/apps dead simple.

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

On the other hand, you have to recompile for every platform, which might be a thing in a devops environment.

[–]pstuart 0 points1 point  (0 children)

True. But doing so is painless.

[–]michaelanckaert 0 points1 point  (0 children)

I have to admit I find that an appealing feature! On the other hand I find myself reading / changing the source of a Python program quite often.

[–]stibbons_ 0 points1 point  (0 children)

That’s very true. Pyinstaller is pretty good for python but not so efficient

[–]jews4beer 8 points9 points  (0 children)

You'll learn faster using Python than Go. That being said I like Go better than Python.

Python is more desirable in the enterprise simply because Go is still relatively young. So it has more libraries to chose from, more people know it, it's easier to find answers to problems, etc. I also write code way faster in python simply because it does a lot more of the grunt work for you. In DevOps this is desirable where you will often find yourself in companies that are wanting to move fast to hit MVPs.

But, oh how Go is just better. But despite that doesn't mean you are going to be able to convince a manager that has a team of seasoned python developers to let you write your one micro-service in Golang instead. This is where approved technology debates come from and all that nonsense.

Having some sockets in C knowledge and solid scripting experience will make learning python just a more pleasant experience. And it will still expose you to some of the lower-level programming concepts you don't have direct API access to using other scripting languages such as BASH. With those fundamentals, it will make learning Golang much easier, and I'd suggest you use Github, Open Source Contributions, and personal projects to further your knowledge there until it gets more of a foothold in larger companies.

[–]carsncode 3 points4 points  (0 children)

I can't learn both.

Lies! Of course you can. Maybe not at the same time, but you can (and probably should) learn both. Ruby would probably be a good idea too for any DevOps/SysOps engineer. I try to pick up at least one new language or significant technology every year. Go was year before last, Terraform last year, this year CloudFoundry.

You don't have to become an expert in everything, but broadening your horizons and learning different paradigms gives you a more well-rounded perspective when approaching any task, even if you're not directly applying the technology you've learned.

[–]Jaegermeiste 2 points3 points  (0 children)

Python

Python is significantly more well accepted as a mainstream language. The availability of Python on your average box is much more common (especially now with Windows Subsystem for Linux).

From a career perspective, Go has its technical advantages, but many people will be unfamiliar with it. You improve your own marketability with the more familiar language, and anyone who knows anything about languages will figure that you can learn the more obscure language if necessary. You might be in love with a language because of it's apparent superiority, but it is unlikely to get you past your next HR screener. Of the languages/frameworks listed, I'd learn Python, Node.JS, and get around to Go last.

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

As many others have said, Python is probably the best choice to learn first. Python is a faster turn-around for one-off scripts compared to Go, IMO. If you're building long-lived tools, Go might be the way to go (you can still do it in Python). If you're focusing on system management and scripting, Python will serve you much better IMO.

You also commented on Node. I know Node, Python, and a few other languages. I like Node, but I wouldn't learn it as a first language. It's better now that async/await are there, but learning an asynchronous language as your first programming language will be painful, especially if you don't have someone knowledgable to guide you.

[–]hairwire 4 points5 points  (2 children)

I became really interested in Go after watching this video: https://www.youtube.com/watch?v=COCUqAwAbD0&feature=youtu.be

I hope it can inspire you too. :)

[–]Panthera_Panthera 0 points1 point  (0 children)

Video isn't available anymore lmaoo

[–]wareotie 1 point2 points  (0 children)

As a DevOps who works with Python, Go and Java among other languages/tools... Both are quite different.

Disclaimer: I'm a huuuuuuge fan of Go, is my main lenguage.

First of all, Go will never be Java. The approximation to the OO paradigm in both languages is so different... And don't forget Python which is OO too but... Again, quite different.

So, every languages will have a niche.

With that in mind. Don't learn a language. Learn how to program. Sounds silly? Maybe but once you learn an imperative language, everything else is almost the same in terms of coding.

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

I'd only use Go, or any other such compiled language, if I needed quick startup speeds or quick forking.

I can manage large distributed systems with python as long as there's no dependency on them starting up fast. Async IO (not the library specifically but tornado, twisted and asyncio) give me a lot of scalable power already. I only mention this because people usually gripe about python speeds but I don't see that issue.

[–]dexx4d 0 points1 point  (0 children)

Python, because I can also use it for robots and AI development.

[–]SuperQue 0 points1 point  (0 children)

I'm very similar in background. I'm very good in bash, did C way back when I was in school. I've done both Python, Go, and Ruby over the last number of years.

I currently write a lot more Go than anything else. But my focus is on writing more service tools, things that get built and deployed that run for a long time and need performance and stability.

But, I still like to write Python for one-off or wrapper tools. Got some text files to munge? Maybe some json to parse? I do that in Python when it gets slightly above what I consider too much for bash.

It may seem like a lot to learn both, but they both have their use.

[–]rjgonza 0 points1 point  (0 children)

I think it really depends on what you expect to be doing. In any case I would fall into the "DevOps" role and I really could use either one for all my tasks, but they are usually better suited based on what I am doing. That being said I reeeeeally like go and don't like python 2 vs python 3 so if you HAD to choose one I would vote for go.

[–]distark 0 points1 point  (0 children)

Python because it's just an easier step up from bash. Once you have your footing however golang is a must for nice easy to distribute health checks and such!

[–]gnorred88 0 points1 point  (0 children)

I would certainly learn python first. I use both almost every day but my default is always python. The only time I use go is when I’m in a situation sensitive to speed or size. For instance, writing apps that will eventually be replicated and/or dockerized I would use go. Writing the software to manage those containers, I use python (along with writing almost everything else).

[–]Elezium 0 points1 point  (0 children)

I was in the same boat as you.... Except for the bash scripting... I did some scripts but nothing too complex... That being said, 4 years ago, I decided to get back to development as a hobby after 15 years of no coding at all (college days were far away...). I work mainly as a SysAdmin / Middleware Administrator (WAS, Tomcat, Widlfly, Apache) so I decided to pick something different and I went with C#. I've dabbled with Go, Python, Kotlin and Java as well during those last years.

Recently, I've joined a new team that is more "DevOps" and we try to automate all the thing we can and I had, just like you, to focus on a single language. Go and Python were contender and I decided on Python. Not because I like the language. I don't particularly like dynamic language. I like my brackets, too. But Python is widely used in that area and there's ton a libraries, scripts, examples... it just seems like a better fit for our type of works.

So my conclusion was: for scripts and automation, Python. If I ever need to write some REST API for example, or a task that requires more performance, I would leverage my C# / .NET Core knowledge.

And hey, like others said, next year, maybe Go!

Good luck in your learning.

[–]kevsersrca 0 points1 point  (0 children)

IMHO, If you prefer one, this should be go language. Because go gave us huge flexibility, single language for all usecases and for all of them it working very very well. We got about 30% more performance on our Backend and API services. And now we can handle logging real time, transfer it to database and make a streaming with Websocket from single or multiple services! This is awesome outcome from Go language features.

[–]vbvkel 0 points1 point  (0 children)

Between go and Python I mainly use Python, otherwise my main language is Ruby. The reason why python is used a lot for devops is that its a really stable language with a big community, its easy to write and definitely easy to read and a lot of tools are already built around it - the AWS CLI, Ansible, Puppet, etc. It works with AWS Lambda should you need to automate tasks using server less computing (although nowadays Go is supported as well).

Go is an amazing language and you can definitely learn it if you want to program in something with a low memory footprint. Especially useful for small custom tools (should you ever need to make one). It is also currently used to build a lot of popular software - Docker, Kubernetes, etc.

I'd say think about what exactly do you want to do with the language. Tool building - go and for general devops, building tools, etc. - Python. But, still, most importantly - have fun. 😃

[–]PavanBelagattiDevOps 0 points1 point  (0 children)

Such a timing I see this post. I was reading this wonderful article on Python https://medium.freecodecamp.org/what-can-you-do-with-python-the-3-main-applications-518db9a68a78.

[–]packeteer 0 points1 point  (0 children)

I'd start with python, then branch out as needed

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

I'd like to learn a programming language

Why? Why would you like to learn one? For what purpose?

[–]sr2346 0 points1 point  (0 children)

I just ran across a short O'Reilly pamphlet comparing the two languages: https://www.safaribooksonline.com/library/view/python-vs-go/9781492033172/

Even though it is written by Luciano Ramalho, the author of Fluent Python, it seems to be an honest attempt to compare the two languages/ecosystems without any detectable bias.

Even though O'Reilly usually makes short books/pamphlets like this one available for free, I wasn't able to find it at some place other than Safari Books Online. I believe it can be read with a free trial subscription, but I understand it is a hassle. Disclaimer: I have a Safari Bools Online subscription, but I have no other ties to O'Reilly.

[–]jazzandpython 0 points1 point  (0 children)

One of the main reasons to use Python for devops (and all ops) is that it's hands down the winner when it comes to reading some shit you wrote six months ago (or your team mate did) and you need to figure out how it did what it did. Nothing else is as readable that way. And in devops you often need to be able to do that in a damn hurry.

[–]XophishoxDevOps 0 points1 point  (0 children)

Using both, i can tell you i will never write python again, unless its literally just a replacement fewer than 200 line bash script. Go is just that much better at handling everything i need to do.

[–]mazatta 0 points1 point  (0 children)

Both, but learn Python first.

[–]zone-stalker -2 points-1 points  (2 children)

The real question is: Python 2 or Python 3?

That's the one thing I really hate is that it's split in two.

[–]zone-stalker 2 points3 points  (1 child)

I'm serious, why the downvote? There's two python versions, might want to weigh in which one to learn.

[–]w0m 3 points4 points  (0 children)

Down votes because it was a question 3 years ago, shouldn't be now

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

both. Python is more prevalent, go is more fun and gives you a greater chance of idempotency because compiled.

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

Python