4 ms·
I would hard disagree with this. When bash won't cut it Python is the goto. 1. Python is installed by default of pretty much every linux out distro out there.
by hitpointdrew 4y ago
I would hard disagree with this. When bash won't cut it Python is the goto.
1. Python is installed by default of pretty much every linux out distro out there.
2. Go is a bit overkill for something that realistically doesn't need any of the speed/performance benefits you would get in Go
3. No need to compile Python
4. Go is way less readable than Python IMO
Go and Rust are fine languages for a lot of things, but sysadmin scripts is not a good use case for either of them.
- morelisp 4y ago> 1. Python is installed by default of pretty much every linux out distro out there. If you can install a Python script you can install a binary, and you won't have missing modules or version compatibility issues. > 3. No need to compile Python Anything on a server better be coming out of your orchestration tools anyway...
- matwood 4y ago> Python is installed by default of pretty much every linux out distro out there. Which Python? Do I need to install pyenv or venv? What about deps? Python is an absolutely disaster every time I try to use it. Golang easily cross compiles (fast enough it doesn't seem like a compilation is happening) to various platforms, I drop the executable there, and it runs.
- kcartlidge 4y agoYou're right with half of these, though 4 is as you say purely opinion and 2 depends on the circumstance. It is worth noting however that with `go run main.go` (or similar) you can execute Go without needing to build a binary first so it can behave exactly like a scripting language. And Go builds virtually instantly, meaning for any non-trivial script (and if you prefer Go of course) it's a virtual certainty that given the negligible build time and far better performance a Go 'script' done this way will massively out-perform a Python script. In other words if you don't accept 4 (and I like Python so not a dig) and you have a need for 2 then 3 can become irrelevant and Go is a good choice.
- tracker1 4y agojust realized you can use shebang with a go file... sweet.
- hitpointdrew 4y ago> 4 is as you say purely opinion I mean sort of opinion, it’s a pretty solid fact that there is less TO read, maybe you can argue that doesn’t make it more readable. Go package main import "fmt" func main() { fmt.Println("Hello, World") } Python print(“Hello World”) Seems like a no brainer to know which one would be easier and faster to develop sysadmin scripts in from the above alone.
- kcartlidge 4y agoWhat you've shown is that Go takes 5 times as many lines of code, but this is a trivial example based on boilerplate. Once you scale your codebase up beyond a handful of lines the percentage which is actual boilerplate becomes negligible and this example ceases to be valid. As an aside, I can't deny that on a per-line or even per-scope basis Python is often more readable. But at the meta level where you're dealing with an entire codebase, which to me is more relevant, the structural aspects come into play and that's where it devolves into pure opinion. In other words, comparing for readability across a handful of lines is not valuable unless you're only dealing with codebases which are also only a handful of lines. Of course the main driver of this thread is script files, and for readability Python probably does win as they tend to be short. But I'd argue that as long as something is readable enough (which Go is) then other factors like performance may need to come into the decision.
- deltasevennine 4y ago4. Type hints make python readable, but with as with most scripts people avoid type hints. This makes python actually less readable then go. Additionally python syntax allows for some very convoluted patterns. This is less the case for go. Go syntax forces explicit procedural steps while python you can throw 20 steps into a single 1 line list comprehension. 3. Go compiles so fast it's not that far off from an interpreted language. 2. It's not as big of a scripting language but it's close enough such that I can see justification for it's usage. 1. Yeah but go can be installed pretty quickly from package managers on every linux distro out there.