5 ms·
If you are doing this for a bunch of images once in a while it is meaningless to even care about the performance implications. If you are doing this often enou
by Crinus 7y ago
If you are doing this for a bunch of images once in a while it is meaningless to even care about the performance implications.
If you are doing this often enough where such computation affects the throughput of your application, then you are using the wrong approach - computation is not meant to be done via the shell or shell scripts, these are meant to be used to tie together applications. That you can use bc for computations is just a convenience the overall design enables you, but that doesn't mean it is how you should use it.
- DonHopkins 7y ago>"computation is not meant to be done via the shell or shell scripts" You are using the passive voice, which is useful when you want to obscure the subject of the sentence. So WHO does not mean for you to perform floating point calculations and string manipulation with the shell? The shell is a human designed artifact. God did not create the category of shell scripting languages and declare that nobody should ever use them perform floating point or string manipulation. Windows Powershell isn't ridiculously crippled like bash is. It's still a shell. That disproves your point that there is some universal definition of a shell that precludes it being useful for general purpose programming tasks.
- Crinus 7y agoI didn't claim that there is a universal definition of shell. My comment is about how these tools are meant to be used and designed as to follow unix philosophy (btw Bash does not follow the unix philosophy as it is a very complicated program that tries to do way more than it needs to). If the Unix Philosophy is a good thing or not is another matter, but to judge that you first have to understand it.
- DonHopkins 7y agoIf you don't mean there's a universal definition of what a shell should and should not do, then WHO do you mean proclaimed that "computation is not meant to be done via the shell or shell scripts"? Just because Eric Raymond writes something in a book doesn't mean it's true. I've been using Unix for at least 37 years, and other operating systems before that, so I think I have enough experience and understanding to judge the "Unix Philosophy" myself, instead of simply believing without question and regurgitating everything Eric Raymond writes. (And unlike him, I also don't believe black people are violent and stupid, or that white people's long term objective must be to break, crush and eventually destroy Islamic culture, either!) https://en.wikiquote.org/wiki/Eric_S._Raymond https://en.wikiquote.org/wiki/Eric_S._Raymond
- Crinus 7y ago> If you don't mean there's a universal definition of what a shell should and should not do, then WHO do you mean proclaimed that "computation is not meant to be done via the shell or shell scripts"? One doesn't follow the other, the "computation is not meant to be done via the shell or shell scripts" is a statement i made and that was under the context of the Unix Philosophy. Also you are focusing on the wrong thing here. > Just because Eric Raymond writes something in a book doesn't mean it's true. I haven't read any of his books nor i see what he has to do with it. > I have enough experience to judge the "Unix Philosophy" myself Then why are you using floating point computation with a bash script as an example for where the Unix Philosophy is bad? Bash doesn't follow the Unix Philosophy, shell scripts aren't even meant to be used for floating point computation when you consider it, instead you should either use a tool dedicated to such computations or to the specific computation you want to perform. There are issues with the Unix Philosophy, like the simplicity it boasts only exists at a micro/local scale but it disappears at a macro/global scale - combining a few simple tools ends up with the combined complexity of all those tools plus the complexity inherent in the communication of them. To use these simple tools effectively you need to know all of them, knowledge of a single tool - despite how simple it might be by itself - is not very useful if it can only do one thing because an application almost never needs to do one thing. This isn't a matter of performance, since nobody ever claimed that following the Unix Philosophy would be fast - but many do claim that it is simple.
- DonHopkins 7y ago>shell scripts aren't even meant to be used for floating point computation There you go with the passive voice again. I ask you yet again: WHO didn't mean for shell scripts to be used for floating point computation? Citations, please? >I haven't read any of his books nor i see what he has to do with it. He wrote "The [Brainf]Art of Unix Programming". Since you claimed to understand the "Unix Philosophy", I assume you would have at least heard of the book written by one of the self-proclaimed experts on the topic, which has a whole section including 17 rules in the Wikipedia page on "Unix Philosophy". How long have you been philosophizing away about Unix anyway? Have you seriously never heard of that book? https://en.wikipedia.org/wiki/Unix_philosophy#Eric_Raymond's_17_Unix_Rules https://en.wikipedia.org/wiki/Unix_philosophy#Eric_Raymond's... >Bash doesn't follow the Unix Philosophy. Bash is no true Scotsman, huh? Bash doesn't follow the Unix Philosophy. Csh doesn't follow the Unix Philosophy. Sh doesn't follow the Unix Philosophy. Yet they are all historically the predominant shell scripting languages of the Unix versions of their time. Can you name ONE popular Unix shell that DOES actually follow the Unix Philosophy? Or does the Unix Philosophy not apply to shells? And who said so? The "Unix Philosophy" is after-the fact rationalization and bullshit. If the main way to program it is shell scripting, but none of the official shells actually follow the Unix Philosophy, then where does that leave you?
- mixmastamyk 7y ago> Windows Powershell isn't ridiculously crippled like bash is. Ok, so you want a more powerful shell, see my other replies for examples.