4 ms·
I started using Forth because I wanted a Reverse Polish Notation calculator at the command line. It turned out to be very practical and extensible. For example
by madphilosopher 4y ago
I started using Forth because I wanted a Reverse Polish Notation calculator at the command line. It turned out to be very practical and extensible.
For example, I created many words to perform unit conversion, such as temperature:
: 2fahrenheit 9 * 5 / 32 + ;
: 2celsius 32 - 5 * 9 / ;
Furthermore, I can even pull in live currency conversion rates from Yahoo Finance to go between USD and CAD.
Since my underlying Forth interpreter runs on Python[0], I get the full large integer and floating-point support that Python has.
[0] http://openbookproject.net/py4fun/forth/forth.html http://openbookproject.net/py4fun/forth/forth.html
- every 4y agoReminds me a bit of dc: https://en.wikipedia.org/wiki/Dc_%28computer_program%29 https://en.wikipedia.org/wiki/Dc_%28computer_program%29
- 082349872349872 4y agoPeople who are interested in low-level language implementation might wish to learn a little dc, because its ability to easily produce arbitrary binary output may come in handy when boostrapping.
- shagie 4y agoThere was that old RSA in a sig file... #!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj $/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1 lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/) You'll note on that last line a |dc` as all of that stuff after the `echo` gets packed into something for dc to run. http://www.cypherspace.org/adam/rsa/rsa-details.html http://www.cypherspace.org/adam/rsa/rsa-details.html
- vram22 4y agobc is built on dc and uses infix notation. bc -l supports arbitrary-precision arithmetic, IIRC.
- Shugyousha 4y ago`k` in dc sets the fractional digits after the dot. I am not sure there is a limit but 99 works ...
- vram22 4y agoGood to know, can be useful.
- prezjordan 4y agoThank you for linking this! Went down a 2-hour rabbit hole and it's really scratching some sort of itch.
- every 4y agoIt is exceedingly terse. Every command is a single character and the only required formatting is a single space to separate numbers. Just this side of line noise...
- zelphirkalt 4y agoSomething I like about Forth is, that one can use almost anything in identifier names ant any position, because the language does not have arbitrary limitations in that like mainstream langs have. I also like that in Scheme. Very useful for making shorter and meaningful names.