5 ms·
Au contraire, I'm saying the shell could turn your multiplication command into a single instruction, no need to call an external process. But at some point you
by 1_player 7y ago
Au contraire, I'm saying the shell could turn your multiplication command into a single instruction, no need to call an external process.
But at some point you need to delegate to other processes. You can't have /bin/bash embed your Chrome browser in it.
But that's not even Unix philosophy. That's how DOS used to work as well.
- DonHopkins 7y agoI'm talking about the shell that actually exists, not some hypothetical shell that doesn't exist and never will. You can't defend the "Unix Philosophy" by proposing a non-standard MONOLITHIC shell be universally adopted that totally goes against what the Unix Philosophy explicitly states: "Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new "features". At least Apple figured out that floating point was useful early enough to replace INTEGER BASIC with APPLESOFT. Forking "bc" from "bash" is the canonical way to multiply two floating point numbers in Unix, according to the "Unix Philosophy". https://stackoverflow.com/questions/12722095/how-do-i-use-floating-point-division-in-bash https://stackoverflow.com/questions/12722095/how-do-i-use-fl... >You can't. bash only does integers; you must delegate to a tool such as bc.
- Crinus 7y agoThe shell is meant to pipe programs together, not perform computations itself. Computations are meant to be made by programs, not shell scripts. Use the right tool for the job, do not complain that you screwdriver sucks because you cannot cut wood with it.
- DonHopkins 7y agoYou too are blinded by the limitations of your tools. Of course the shell performs all kinds of computations. Just not a useful enough set of them that you don't still need "bc" and "awk" and "sed" and "grep" and many other ridiculous "Unix Philosophy Compliant" tools. I complain my screwdriver sucks when it's made of plastic, and it's only good for driving plastic screws into styrofoam.
- Crinus 7y agoThe idea is that the tools are meant to be limited to avoid complexity (this is why bash, like most GNU tools, isn't really a good example of unix philosophy - it is too complex) and instead rely on composition.
- DonHopkins 7y agoAs if the bash syntax for simple string manipulation and piping and quoting and escaping and even determining if a string is empty wasn't unnecessarily complex. As I said, the "Unix Philosophy" of plugging together artificially limited tools by pipes is intellectually bankrupt (and terribly inefficient). That was my whole point.
- mixmastamyk 7y agoIt is inefficient, but that doesn't matter much for interactive use. After a shell script reaches a dozen lines, it's time to port it to Python. If the job needs absolute performance you rewrite in a performant language instead. I'm not sure why you are upset to be honest? What design would you prefer? This one seems to hit all use cases. In another thread I mention that fish has math and string manipulation builtins.
- darkpuma 7y agoIf you browse through GNU documents, you sometimes come across strange ancient passages like > "Avoid arbitrary limits on the length or number of any data structure, including file names, lines, files, and symbols, by allocating all data structures dynamically. In most Unix utilities, “long lines are silently truncated”. This is not acceptable in a GNU utility. " What do you suppose the ancients meant by this? Some have taken it as evidence that in ancient times before GNU, Unix tools were not in fact "doing one thing and doing it well" as the Unix priests so often claim. This of course is blasphemy and the guilty are punished accordingly... but are they wrong?
- pdkl95 7y ago> shell ... Just not a useful enough set chsh - change login shell DESCRIPTION The chsh command changes the user login shell. If you don't like the features of your shell, use a different shell. > you don't still need ... "awk" and "sed" and "grep" I don't need those programs - there are many other ways to solve most problems. I want to use them because they are both fast to start and execute, and make development time extremely fast. > You too are blinded by the limitations of your tools. You appear to be trying to use the shell for tasks that that should be done in a different language. You also don't seem to understand that some of use use the shell because discovered it was a much faster and easier to use tool for some problems than the other methods we've tried. For some tasks, complaining about the overhead to do some things like floating point or trivialities like the <100ms it takes to fork and run bc is a premature optimization. If you don't find shell to be a useful tool for the problems you need to solve, that's fine; use whatever tool works best for you. We might be trying to solve different problems. Just because you don't like a particular tool doesn't mean it's "ridiculous".
- hedora 7y agoPlenty of Unix shells support floating point. For example, the conveniently-named ksh93 was released in 1993, and was / is available on a wide range of systems. I’d guess the hipster-compliant fish shell can do these things too, but can’t be bothered to RTFM. I think the takeaway is that floating point shell use cases are so vanishingly rare that no one bothers to switch shells over it. https://unix.stackexchange.com/questions/40786/how-to-do-integer-float-calculations-in-bash-or-other-languages-frameworks#40787 https://unix.stackexchange.com/questions/40786/how-to-do-int...