3 ms·
But what’s the point in doing that?
by walteweiss 5y ago
But what’s the point in doing that?
- arminiusreturns 5y agoNot sure about the gp, but lots of people on hn love to hate on bash, and give reasons either it's bad or lang is better.
- mixmastamyk 5y agoReadability, maintainability, etc. if that matters to you.
- krick 5y agoThis is a pretty small project, and, furthermore, it is by its nature supposed to support a lot of different systems, so I personally don't know if it makes sense to rewrite it (and in Python out of all things: maybe then better rewrite it in a compiled language, so that you can distribute it as a binary?). So I'm hesistant to say one should do it: it might do more harm than good. But if this wouldn't bother me, I would really want to rewrite it. Just look at the source. It is 11K LoC. It is very modular by nature, since there is a lot of stuff that is "the same, but slightly different" for each OS. It is really simple by nature, just a few dozens of directives, each of them should answer 1 pretty straight-forward question. So it should be fairly easy to read (and it actually makes a practical sense even for a user, since this is so much of a collection of knowledge about different OS, not so much a "real program"). But it's not (I mean, it's not easy to read, assuming you are comfortable with bash). And it's not badly-written bash-script, quite otherwise. It's just… bash. How exactly you'd improve that would depend on the language of choice, but every "proper" PL should make it possible to write this very thing in such a way, that reading it "entirely" in a few minutes would be trivial, and wouldn't require scrolling through 11K LoC. Just separating all ASCII-art from code and making a separate class (if we use Python) for each OS implementation with a common interface, extending 1 or more base-classes (for OS families) would improve it greatly, since it would take me literally seconds to see all directives it currently supports, and to find their implementations for the particular system I'm interested in. After scrolling through some maybe 200 LoC you'd feel that you know everything that it does, and the rest 10K LoC (or whatever it would be) are just "details". So while actually suggesting to rewrite it in Python might show some lack of analysis, I wouldn't bash anyone for wishing it would have been written in Python.