Using Python Ruby Golang as Quick Calculator in Emacs
- i now use golang as calculator. C-n new buffer, g3 inserts main template. type 1+2, space w j shows result.
- many advantages of using lang instead of emacs Alt+x
calc. faster, more powerful, flexible, and saved result, editable.
- you can use golang python ruby nodejs julia etc. In a buffer and press a button to run it.
- i used to use emacs calc for quicky back in 1999. switched to python ~2009. then switched to ruby, now golang.
- for example, ruby, just Alt+x
irb, 1+3 enter.
- but notebook interface is usually better than repl, because you have more powerful editing and saving features
- e.g. Ctrl+n open new, type
p 1+2, Alt+x
xah-run-current-file, type x.rb, result shows 3
- for lang require template such as golang “main” stuff, just type g3 and it inserts it. Using emacs abbrev.
Note, strictly typed language such as golang may not be suitable. Because it's more cumbersome.
The advantage of using a full featured language in a buffer instead of calc are:
- calc was killer app in the 1990s. Not anymore. It haven't been updated for 10 or 20 years, only maintained.
- In a buffer, you have far more power and ease in typing/editing, and keep a record of computation, from calculating bill payment to taxes. Compute what if variation, etc.
- Full featured language allows you to do far more advanced math. e.g. python, julia. you can load lib for calculus or linear algebra or statistics.
For how to setup, see
put in a few bucks to my patreon. https://www.patreon.com/xahlee Thanks.