3 ms·
I have ksh scripts I wrote over 20 years ago on xenix, which still work today on bash or ksh. Meanwhile I have python apps that didn't make it a year. Any part
by Brian_K_White 5y ago
I have ksh scripts I wrote over 20 years ago on xenix, which still work today on bash or ksh. Meanwhile I have python apps that didn't make it a year.
Any particular version of Python is a saner choice, if you could pick one and freeze it retroactively for the last 20 years and for at least the next 20. But that is not how Python works. Python breaks every 11 minutes.
I would not write anything in Python that I cared the slightest bit about longevity or portability.
Maybe if we made a subset of python, locked down the syntax and feature set, discouraged any use of plugins or libraries in any fancy way that relies on any kind of repository or package manager system, and gave it a new name to distinguish it from normal python, maybe that would be an ok replacement for any of the shells.
But that is not happeing and don't even try to pretend like it could.
- kafkaIncarnate 5y agoThat's what Python2.7 is and why every major proprietary product won't adopt anything else. It's also why it won't go away. All of my Python 2.6-2.7 scripts haven't been touched in 10 years in production and they aren't likely to ever be updated. I actually now refuse to write new Python that isn't compatible with both 2&3 for this reason. Python3 refuses to stabilize.
- fiddlerwoaroof 5y agoI’ve been slowly embracing the mantra “only use unmaintained software”: maintenance is great when it’s fixing bugs and such, but eventually people insist on breaking backwards compatibility.
- Brian_K_White 5y agoThat is a captivating idea!
- kafkaIncarnate 5y agoPython2.7 is still maintained. If you mean my software I mentioned if something breaks I'm still required to fix it. I just doubt that will happen at this point and have other tasks to do.
- fiddlerwoaroof 5y agoIsn’t Python 2.7 EOL as of January 2020 or something? It’s maintained in the sense that there are still people shipping patches, but the core Python developers no longer maintain it.
- kafkaIncarnate 5y agoThat is news to me, and good to know. https://www.bleepingcomputer.com/news/software/python-27-reaches-end-of-life-after-20-years-of-development/ https://www.bleepingcomputer.com/news/software/python-27-rea... Apparently RHEL will maintain any security problems until 2024, but yeah it's pretty much dead. Huh. Not sure how to react to that.
- laserlight 5y ago> It's also why it won't go away. Python 2 went away in macOS. Bash still exists.
- pmags 5y agoDid it really? `/usr/bin/python` invokes Python 2.7.18 on my just-bought Macbook Pro 14 running MacOS 12.2. Maybe that's because I installed the Xcode command line tools?
- laserlight 5y agoIIRC, Apple announced that Python 2 will be removed in a future version of macOS, without specifying a version. Looks like they removed it in macOS 12.3 [0]. [0] https://www.macrumors.com/2022/01/28/apple-removing-python-2-in-macos-12-3/ https://www.macrumors.com/2022/01/28/apple-removing-python-2...
- kafkaIncarnate 5y agohttps://www.python.org/downloads/release/python-2718/ https://www.python.org/downloads/release/python-2718/ There's still a macOS installer for the latest release of Python2.7 (4/20/2020).
- laserlight 5y agoThe discussion was around longevity, and Python 2 is dead as of January 2020 [0]. Installer might exist, but it has already become more difficult to maintain Python 2. It will become even more difficult in time. Bash, on the other hand, will more likely to be around for longer. [0] Sunsetting Python 2. https://www.python.org/doc/sunset-python-2/ https://www.python.org/doc/sunset-python-2/
- Izkata 5y agoOver the past decade I've been drifting towards doing more and more in bash that I'd've normally done one one language or another just because of this stability. Perl is another candidate if I need something more complicated, but I'm not as familiar with it so I don't really reach for it often. Are there any other languages with the same stability that would also fill this niche?
- HeckFeck 5y agoI've learnt Perl for this very reason. It is extremely capable, extensible and still very backwards-compatible. It feels like an evolution of bash but much more performant. A bit of a shame that it's seen as an anachronism to many. Perl soon rubs off on you and becomes a delight.
- fiddlerwoaroof 5y agoFor shell-scripting sorts of tasks, there’s also awk which I find a nice sort of halfway between bash and Perl. Also, I’ve been using various lisps (elisp in emacs org-mode and Common Lisp) and they both can be written in ways that will probably last a long time.
- Brian_K_White 5y agoAwk is a strange seeming suggestion, but I agree it's probably the next most universal, installed, stable over time option, and more readable than sh. Using awk as a general purpose language means slightly bending it out of shape, by mostly ignoring the main section (which runs once per selected record of input) and writing your entire program in a big END{} section. BUT * It's installed everywhere and has been forever just like sh * A 20 year old awk script from hpux or something, works in todays gawk, just like sh. * Unlike sh, the language is more like a normal generic language than, making it more readable and less arcane for non-trivial jobs. For example, bash has a handy substitute feature, in the form of a brace expansion. ${FOO//a/b} Awk has an actual sub() or gsub() function. A lot of things in bash require tricks essentially abusing various fancy brace expansions and messing with IFS to hijack the line parser into doing things there is no explicit command for, especially if you're avoiding external commands. IE you're not simply writing code that does what it says, you're running a bash interpreter in your head and manipulating strings so that when they are expanded and resolved, they mean something to the the parser and results in the parser doing something more useful. It's like your always writing code that writes code, instead of just writing code. External dependencies is another whole point too. Shells main explicit job is to run other programs. You actually have to work pretty hard not to run an external binary by accident, ie you have know which commands are built in and which are executables. In awk or anything else, you have to go out of your way to exec() or system().