5 ms·
I think Python is getting so popular & ubiquitous now I can't see any reason to write bash scripts any more except for perhaps very simple ones that are just a
by rb808 7y ago
I think Python is getting so popular & ubiquitous now I can't see any reason to write bash scripts any more except for perhaps very simple ones that are just a few lines. Other people's bash scripts are regularly just too difficult and complex to maintain.
- sametmax 7y agoBesides, EAFP is actually a good way to make things idempotent AND free of race conditions.
- Godel_unicode 7y agoPython startup time is just not in the same league as bash though, if you tried to replace bash across the board you'd end up with lots of unnecessary lag.
- achamayou 7y agoIs that really true with limited imports though, and/or with precompiled bytecode? I was surprised to find that Ubuntu’s handler for unknown commands that tries to suggest what you could apt install is written in Python. I’ve never noticed it being slow.
- pmarreck 7y agoWhile not disagreeing, I would not agree that "everyone should go to Python" since I would personally prefer (for example) Ruby or Elixir, which can work just as well as scripting languages and are at least as readable, while also not triggering too much "VM startup" time. Of course, others would prefer, say, Clojure, or Kotlin (although the JVM startup time is the worst of all), but therein lies the issue... We're stuck with Bash scripting because everyone (more or less) knows/understands it to some extent, it's installed everywhere, and it has essentially no startup-time cost.
- pletnes 7y agoIf you’re into minimal docker images, bash or similar shell might be the only script interpreter available. Python might not exist on your windows machine. Etc.
- nyuszika7h 7y ago> Python might not exist on your windows machine. Bash might not exist either.
- antpls 7y agoSurely we could all agree on a minimal subset of useful Python to write scripts : loops, arrays, lists, some strings functions, etc. The resulting Python interpreter would probably be tiny. For example, there is https://docs.bazel.build/versions/master/skylark/language.html https://docs.bazel.build/versions/master/skylark/language.ht... which is a subset of Python.
- pletnes 7y agoMicropython runs in 16k RAM. https://micropython.org/ https://micropython.org/
- jdgiese 7y agoI agree, in general, but I do think it is worth pointing out that bash is very good at what it was made for---i.e., starting processes, redirecting their output, etc. Compare: { a; b && c; } ≫ log.txt With the same written in Python: from subprocess import check_call, CalledProcessError f = open("log.txt", "a+") try: check_call(["a"], stdout=f) except CalledProcessError as e: pass try: check_call(["b"], stdout=f) check_call(["c"], stdout=f) except CalledProcessError as e: exit(e.returncode) exit(0) (Note: I took these examples from an article I wrote a while back about programming languages https://innolitics.com/articles/programming-languages/ https://innolitics.com/articles/programming-languages/ )
- 1337shadow 7y agoThat's why Xonsh exists !