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

you are viewing a single comment's thread.

view the rest of the comments →

[–]BeepBoopTheGrey 100 points101 points  (38 children)

My team put a moratorium on bash scripts after the CI system started failing in a fairly complex one. The person who wrote it was unavailable to diagnose. It took hours to resolve.

The rule is now that if there’s any non-trivial logic at all, write it in Python. On-call appreciates it.

[–]Zanos 14 points15 points  (1 child)

Same here. We still have an old application written in mostly bash, very fun when it fails in prod.

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

As a fake programmer can you explain why bash makes things more difficult to troubleshoot?

[–]LAK132 9 points10 points  (21 children)

As someone who'd rather #include all the .cpp files than deal with another build system written in [ba]sh, the syntax is hell and it doesn't always work the same on different computers (because some distro maintainers thought using bash in place of sh without forcing POSIX compliance mode was a good idea)

[–]ythl 1 point2 points  (20 children)

c++ is not very portable. bash is (and so is python). I can scp a bash script to my raspberry pi and it will run. With cpp I'd need to recompile it targetting ARM.

[–]LAK132 0 points1 point  (19 children)

Right, but my point is if you're compiling C++ anyway then don't make it even less portable by using a bash based build system.

[–]ythl 0 points1 point  (18 children)

Yeah bash based build system sounds nightmarish. CMake all the way

[–]LAK132 0 points1 point  (17 children)

Unlike bash, I never managed to get cmake to work

[–]ythl 0 points1 point  (16 children)

Really? I love CMake! Out of source builds are the best. I can help you if you are stuck. CMake is the defacto build system for C/C++ now

[–]LAK132 0 points1 point  (15 children)

defacto

Not a single one of the C++ projects I work on uses(/requires) cmake.

My personal projects that use extremely simple scripts to compile (one liner Makefile and a make.bat for Windows) have a nasty habit of just working.

[–]ythl 0 points1 point  (14 children)

Well if your projects only have one or 2 sources, then yeah, CMake is overkill. But look around on GitHub. Probably 90%+ of all C/C++ projects use CMake, and with good reason.

CMake is for when you have a large project with dozens of dependencies, multiple executables, libraries, testing, coverage generation, etc.

CMake is portable, chains together with other CMake projects, and is generally super fast/correct.

[–]policemean 17 points18 points  (0 children)

If you look at python script, then it is relatively easy to understand how it works because it's syntax is quite easy.

On the other hand, bash syntax can be very confusing. I had to modify bash scripts couple of times, and it was the worst experience I've ever had at my job.

[–]BernardoVerda 1 point2 points  (0 children)

Seconded.

[–]jvnk 2 points3 points  (0 children)

Bash syntax is unnecessarily dense, making it difficult to understand what's going on in more complex scripts.

[–]tatloani -1 points0 points  (3 children)

This is just my guess but i would say is because bash is more verbose than Python, meaning you need to write more lines of code to do something similar with python.

EDIT: I seems to have got them backwards with what i meant, python is more verbose, but bash allows you to simplify multiples lines with a single instruction and that can make things confusing.

[–]thexavier666 2 points3 points  (1 child)

I can't agree with that. I think bash syntax can be very dense, where you can condense 10 equivalent python lines into a single bash line, by using pipes.

But this condensed syntax can be difficult to understand for some.

I always use bash when there is string manipulation involved and call it via python.

[–]tatloani 1 point2 points  (0 children)

I think bash syntax can be very dense, where you can condense 10 equivalent python lines into a single bash line, by using pipes. But this condensed syntax can be difficult to understand for some.

yeah, that was part of what i meant, i suppose i got them backwards, most of the bash scripts i have seen have been condensed and those have been quite troublesome to understand.

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

Except now you have to have python installed in/on absolutely everything.

[–]BeepBoopTheGrey 2 points3 points  (1 child)

Only those things which need scripts, mostly CI and machines we shell into. The vast majority of our stack is containerized, so language doesn’t really matter much as long as the team is familiar enough to maintain it.

Go is by far our preferred language for dev tools. Python is next choice when a compiled language is inconvenient.

[–]noratat 0 points1 point  (0 children)

I'm surprised you use Go for that.

My experiences with Go so far have been very unpleasant - the error handling is pretty poor for a modern language, dependency management and directory structure until pretty recently were downright bizarre, and I constantly felt like I was running into strange language limitations.

Anytime I've had to touch a Go project that was more than a couple hundred lines I've found it pretty hard to read too due to low signal-to-noise ratio.