6 ms·
> That is because Python actually has a built-in way to multiply numbers and perform string manipulation, right out of the box! You really should check it out s
by saagarjha 8y ago
> That is because Python actually has a built-in way to multiply numbers and perform string manipulation, right out of the box! You really should check it out some time. So do a lot of other languages. Just not bash.
$ echo $((1*2))
2
$ string="hello, world"
$ echo ${string/hello/goodbye}
goodbye, world
- DonHopkins 8y agoNow show me how to add 1.5 and 0.5. bash-3.2$ echo $((1.5+0.5)) bash: 1.5+0.5: syntax error: invalid arithmetic operator (error token is ".5+0.5") https://unix.stackexchange.com/questions/40786/how-to-do-integer-float-calculations-in-bash-or-other-languages-frameworks https://unix.stackexchange.com/questions/40786/how-to-do-int... I gave up INTEGER BASIC for APPLESOFT several decades ago, and never looked back. (LOADING INTEGER INTO LANGUAGE CARD) ]INT >PRINT 1.5 + 0.5 *** SYNTAX ERROR >FP ]PRINT 1.5 + 0.5 2 It's 2019, and you're struggling to do in bash what you could have done on an Apple ][ in 1979, but the syntax you need to use is even WORSE than BASIC, so your code looks like line noise from when your mom picks up the phone while you're using a 300 baud modem. Is that really progress? https://en.wikipedia.org/wiki/Integer_BASIC https://en.wikipedia.org/wiki/Integer_BASIC >Integer BASIC was phased out in favor of Applesoft BASIC starting with the Apple II Plus in 1979. This was a licensed but modified version of Microsoft BASIC, which included the floating point support missing in Integer BASIC. https://en.wikipedia.org/wiki/Applesoft_BASIC https://en.wikipedia.org/wiki/Applesoft_BASIC >Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with the Apple II series of computers. It supersedes Integer BASIC and is the BASIC in ROM in all Apple II series computers after the original Apple II model. It is also referred to as FP BASIC (from "floating point") because of the Apple DOS command used to invoke it, instead of INT for Integer BASIC. Notice that there are even machine language instructions for cos, atan, tan, sin, ln, etc. How do you call those instructions in bash? https://docs.oracle.com/cd/E18752_01/html/817-5477/eoizy.html https://docs.oracle.com/cd/E18752_01/html/817-5477/eoizy.htm... >x86 Assembly Language Reference Manual: Floating-Point Instructions >The floating point instructions operate on floating-point, integer, and binary coded decimal (BCD) operands.
- js2 8y agobash is Turing complete... the rest is left as an exercise to the reader. :-)
- DonHopkins 8y agoSome people just love to dive into the deep end of the Turing Tarpit, because their point is to be as wasteful and inefficient as possible. Thus my point about buying gum with Bitcoin and rolling coal to trigger the libs. https://en.wikipedia.org/wiki/Turing_tarpit https://en.wikipedia.org/wiki/Turing_tarpit >54. Beware of the Turing tar-pit in which everything is possible but nothing of interest is easy. But I think that most people who use bash simply have no clue how expensive forking another process is, and not enough experience to realize that software always ends up growing up to be much more complex than they originally expected, and think that "1+1" is as much arithmetic as they will ever need. https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule >Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp. https://en.wikipedia.org/wiki/Jamie_Zawinski#Principles https://en.wikipedia.org/wiki/Jamie_Zawinski#Principles >Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.
- js2 8y agoI really thought you were being facetious comparing bash and forking to bitcoin. Shell scripts aren't so terrible and you wouldn't use them in performance critical scenarios. It's not like all our CPUs are running at 100% utilization. You're talking to someone who ran a web farm in the 90s so yeah, I saw the evolution from CGI to mod-perl and on. I mean I know the cost of forking. But come on, aren't you taking your criticism a bit far? I also had an Apple ][+. Actually, one wasn't available so we Frankensteined one together from an Apple ][ and an Applesoft language card by swapping the motherboard ROMs and language card ROMs.
- DonHopkins 8y ago