3 ms·
The Google shell style guide [1] says this: "If you are writing a script that is more than 100 lines long, you should probably be writing it in Python instead.
by yodsanklai 7y ago
The Google shell style guide [1] says this:
"If you are writing a script that is more than 100 lines long, you should probably be writing it in Python instead. Bear in mind that scripts grow. Rewrite your script in another language early to avoid a time-consuming rewrite at a later date."
[1] https://google.github.io/styleguide/shell.xml https://google.github.io/styleguide/shell.xml
- a3n 7y agoRelated, the longer your shell script gets, the greater potential for accumulated foot-guns. When you finally do the rewrite, will you be bug-compatible? And once discovered, will you be confident on which side the bug lies?
- blaser-waffle 7y agoAn aside: when did the phrase "foot-guns" become a thing. Cuz I've never heard it until this thread, where it pops up multiple times. Great phrase but went 0-60 in usage.
- mrguyorama 7y agoI'm pretty sure it's at least as old as usenet and mail lists
- HocusLocus 7y ago"If you are writing a script that is more than 100 lines long, you should probably be writing it in Perl instead." This is true, especially of Python scripts.
- RHSeeger 7y agoThat way, it will never be rewritten again; because nobody will be able to read it. Edit: Getting some downvotes, so to clarify, I am indeed saying that concerting something from Python to Perl has a high likelihood of making it for less maintainable. I get that people can write good perl. As someone who has had to maintain perl in the past; the fact is that it's far more common for the end result to be horrible perl. I have some issues with Python, but it is FAR more maintainable than perl.
- bsder 7y agoLet me drag this to something concrete: if you are interviewing, it is almost impossible to pass an amateur "Perl screen". Every single person who doesn't use Perl every day, professionally knows a different subset of Perl. This is one of the few times where being more knowledgeable than the interviewer is also a problem. You will write something, and the interviewer will question you on it because he has never seen it. I finally solved this problem by bringing one of my personal programs written in Perl and also rewritten in Python so we could talk about it. Now, the interviewer is in MY subset of Perl AND can't argue because I have working Perl code in front of him. This was back in the 1990's when everybody in VLSI design expected you to know Perl. Because of this "different subset" issue, if you want to maintain a Perl script, you have to basically know the entire language. This is what makes maintaining Perl scripts so difficult. This "different subset" problem is the whole reason I left the Perl ecosystem back in 1996(!) at the height of Perl's popularity and never looked back.
- cosmojg 7y agoAs an experienced Perl programmer, what's your opinion of Raku? Is it a worthwhile replacement or too little too late?
- redis_mlc 7y ago> As an experienced Perl programmer, what's your opinion of Raku? Perl5 still works fine, and is maintained. > Is it a worthwhile replacement or too little too late? False dichotomy - see above.
- DonHopkins 7y agoIt's been too little too late for many years, while it was still named Perl 5 for so long.
- frank2 7y agoRaku is the new name for Perl 6, not Perl 5.
- cookiecaper 7y agoStuff like this does a huge amount of unintentional damage. Every crappy company in the world thinks they're Google and tries to copy them. Google-caliber people might be able to be reasonable about this, but ordinary employees come across something like this and interpret it to mean "bash is evil" and ostracize everyone who tries to write a bash script for anything, no matter how sensible. At work lately, there's been a spate of contorted "just why?" Python scripts that could've been accomplished elegantly in a handful of lines of shell. While no one would select shell languages as the ideal for a lot of complex logic, data parsing, etc., there's no competition for a shell when you need to do what shells are meant to do: chaining invocations, gluing and piping output, and so on.
- Godel_unicode 7y agoJust because they write crappy Python doesn't mean they'd write good shell scripts. For me it indicates the opposite.
- samtheprogram 7y agoAs Gary Bernhardt said, and I quote often, it makes sense when it’s right half of the ass. https://youtube.com/watch?v=ZQnyApKysg4 https://youtube.com/watch?v=ZQnyApKysg4
- pmarreck 7y agowow, have seen many of Gary's talks but not this one until now; clearly I missed a gem
- DonHopkins 7y agoBut bash IS evil.
- cpach 7y agoWhy?
- 7y ago