I've been reminiscing a lot about calculators lately. I started learning math just when electronic scientific calculators were replacing slide rules as tools for engineers.
But scientific calculators are themselves almost extinct outside of the classroom, because computers, smartphones and tablets running powerful CAS or numerical software can do all the kinds of computing you really need... unless you're not allowed to use them because of classroom or exam restrictions.
So the market has contracted to education, and the high-end calculators sold today, though they're extremely powerful, are very much catering to students rather than to engineers or scientists. There's a lot of power siloed into user-friendly apps, but less ability to link those together into powerful custom-built systems of your own design.
And inevitably, because I'm getting old, I have a lot of nostalgia for old ones... particularly for HP's RPL line, starting in the late 1980s with the 28C (which was woefully underpowered, but the potential was there) and continuing through the very capable 28S and 48/49/50 series.
The ones I actually had were the 28S and the 48SX--the latter got stolen after just a few years; it was too damned expensive to leave lying around. I still have the 28S somewhere though the batteries for it can be hard to find. But I've been getting back into messing with them through emulation. Here's Calculator Culture's review of the 48SX that goes through its innovations, strengths and weaknesses.
HP's scientific calculators were quirky in that most of them until quite recently solely or primarily used postfix or Reverse Polish Notation (RPN), a stack-based system in which every operator followed its operands: to add 2 + 3, instead of
2 + 3 =,
you'd press
2 [ENTER] 3 +.
These calculators had a stack, that is, a list of numbers represented as a vertical tower that they would generally enter and exit from the "bottom" (in HP's terminology, at least). In the addition above, the ENTER key would signal that you were finished typing a number and put the 2 on the stack. The + would implicitly do an ENTER if necessary, then take the bottom two items off the stack and add them.
For more complex calculations, there was no messing around with order of operations or nested parentheses--the stack was everything. So, say, (4+5) * 3 - 2 could be entered as
4 5 + 3 * 2 -
(where it's understood you type ENTER after every number not followed by an operator.)
The joke was that an advantage to using an HP was that nobody ever asked to borrow your calculator more than once. But for complex calculations off the cuff, people who used them soon learned to prefer RPN to algebraic entry, and I still like it.
Now, the RPL line overhauled and expanded this system in ways that annoyed some RPN calculator purists, but it was where I came in, so none of this bothered me much.
HP's older calculators all had a four-level stack, with levels named X, Y, Z and T, and they often only showed the bottom, X level on the display. With these new models, the stack was "infinite" up to the capacity of the calculator's RAM, and they'd display the bottom few levels.
And instead of just storing numbers, a single stack level could store... *anything*: a matrix, a vector, a complex number, a string, a bitmap image, even a function or an algebraic expression. Or a list of other objects.
Because the programming system in these models had been expanded into a functional language with list processing, that could script anything the calculator could do, called RPL (which unofficially stood for "Reverse Polish Lisp"). RPL was my favorite programming language for a while, back in the day, though I'm rusty. For a handheld device in the late 1980s it was mind-blowingly powerful.
These calculators were also the first to have some CAS and graphing capabilities. They could do some symbolic algebra and symbolic calculus on algebraic expressions (on top of the numerical evaluation and integration of functions that HP's scientifics could always do).
Probably the most controversial thing to older-school HP fans was that the algebraic expressions that the symbolic math functions could manipulate were *only* expressed in algebraic notation, not in RPN. Beginning with the 48, there was even a "WYSIWYG" equation editor. That was anathema to some, and I suppose in some ways it was the crack of doom for RPN as they'd known it.
A thing I'd forgotten how to do until the other day was how to define a new function that could not just be evaluated (like executing a program), but actually be used in algebraic expressions that you could simplify, graph, differentiate and so forth. The answer was the DEFINE key. Thinking about it is a little illuminating about how it did CAS stuff.
If I wanted to define my old friend the Gudermannian arctan(sinh(𝑥)), I could just write a little RPL program that went
« SINH ATAN »
and store that in a variable called GD, and it'd make a button that would find the Gudermannian of the bottom thing on the stack. Great! Simple! But if I put GD(X) in an algebraic expression, it won't work. The CAS and graphing stuff isn't up to chewing on arbitrary RPL programs.
But what will work? If I instead enter the algebraic equation
'GD(X) = ATAN(SINH(X))'
and hit the DEFINE key, now what happens seems to be exactly the same, only now I can use GD(X) in algebraic expressions just like it was a built-in function. I can differentiate or integrate it, I can graph it, great!
If I look at the contents of the GD variable, what's in there? It's still RPL, but it looks like this:
« → X 'ATAN(SINH(X))' »
Ha, it looks kind of like a lambda expression with a bound variable, but in RPL! I guess I know why they call it Reverse Polish Lisp.
Anyway, the pattern from the perspective of the user interface was clearly that anything you entered algebraically could be manipulated by the symbolic math system, whereas anything that was pure RPL couldn't be.
So this "lambda expression" format was a kind of wrapper to make an RPL program that just represented an algebraic expression. (I *think* that the algebraics were really represented internally in an RPL-esque format, but it was clearly a specially restricted subset.)
There was another level called "System RPL" that was compiled and removed a lot of type checking for speed, and in which apparently the internal utilities were written, but I never got into that. User RPL was enough.
Anyway, how am I even messing with this stuff, given that I don't currently have batteries for my 28? Well, there are free emulators for these things.
For a while, I've had an Android 48G/48S emulator on my phone called Droid48, and I actually use it for day-to-day calculation sometimes. Most of the advanced capabilities of these calculators can be done better by other means these days--Wolfram Alpha has a phone app that is, like, three bucks, and even the Google search bar is a fairly sophisticated calculator. But sometimes you want to bang out stuff in RPN.
Lately I discovered that a much fancier, popular Windows emulator called Emu48 had been ported to Android--this one actually supports a whole bunch of HP calculators, including the 50g, which was the latest and greatest in the line, from 2006.
The 50g was a big enough beast that its keyboard can be a little difficult to manipulate on my little phone screen, but it's impressive.
It added something that must have seemed even more like the crack of doom for reverse Polish notation: a purely algebraic entry mode much like TI's calculators... which is the default! But you can switch it to RPN entry easily.
But that was the last RPL calculator. Later ones do have a simpler RPN mode, but their programming environments are different.
Most of these ran on HP's custom Saturn processor, but the HP50g was actually running an ARM processor and emulating a Saturn-based system. Another sign of changing times.
As much as I liked RPL, I wasn't thinking in terms of functional programming at the time; I tended to write traditional procedural programs and I think I only barely scratched the surface of what it could do. In some ways it was way ahead of its time.
...But reading old forum conversations on this, the consistent pattern seemed to be that RPL made people unfamiliar with it (aficionados of older HP programmables, and people who wanted to program in any other kind of language) *extremely angry*. It had a reputation for being incomprehensible. The older HP fans got incensed just that it used different names for stack operations (derived from Forth) than older HP calculators did. So maybe HP just realized that nobody other than a particular small subset of their fan base wanted it.
(Why is "reverse Polish notation" called that? Well, "Polish notation" is a prefix notation, in which the operator always comes *before* the operands, and it was invented by the Polish logician Jan Łukasiewicz. Lisp uses a variant of it, though Łukasiewicz's version avoided parentheses, which you can do if the number of arguments for an operator is fixed, whereas Lisp slings around parentheses like there was just a clearance special on parentheses at the parentheses store. Anyway, RPN is the reverse of that.)
I should also say that in the HP calculator community specifically, "RPN" is often used to mean "RPN but *not* RPL": a four-level numeric stack, and there are buttons that say "R↓" and "x⇄y".
Most of these calculators supported a simpler programming model, essentially keyboard macros plus branching and looping operations, which varied in the details from model to model.
The beloved Voyager series, like the 15C, were all like that, and the mighty 41C, which was easily the most powerful pre-RPL calculator HP made, more of a full-fledged handheld computing platform with all manner of accessories and peripherals. HP actually went back and made more of these after the RPL series was established--the HP42s has a passionate fan base of its own.
A thing I always wondered was why the first RPL calculator, the HP 28C, was so underpowered for its operating system--just 2K of RAM, which would quickly run out if you were trying to use its powerful software to do anything significant.
Apparently (based on a comment I read somewhere) it's because the hardware was just a repurposing of the HP 18C Business Consultant, which had the same physical clamshell design as the 28 but was a business/finance calculator. The 18C's software was written in RPL, but RPL was not exposed to the user, it lacked the 28C's complicated algebra/calculus/scientific functions, and it didn't need more than 2K to support its capabilities.
HP felt that this radical overhaul of their scientific line was a big risk, and the easiest way to mitigate that was just to ship the first model on the 18C's hardware without spending any money on upgrading it. Once it was successful enough, they came out with the 28S with far more RAM, and eventually the 48SX which was more or less what the designers of RPL had really wanted to ship in the first place.
I had a 28S, which expanded the RAM to a much more reasonable 32K, and added a few software enhancements. I loved that calculator and used it through most of college.
The clamshell case was divisive but I thought it was a great design--apart from the fragile battery door, which had a tendency to self-destruct over time under the pressure of the powerful contact springs, a real design flaw.
Having all those keys reduced the amount of shifting you had to do, and you could fold the alphabetic keyboard back for handheld operation if you only needed basic calculator functionality. The 48 went to a more traditional vertical format with three shift keys and I was *slightly* disappointed by that.
But the 28's display was kind of short, which limited its graphing capability. The most ambitious program I wrote for it was a utility to render and display tall graphs that you could scroll up and down through with the arrow keys. It used the "graphics strings" capability that was one of the 28S's new enhancements. A friend of mine, who has since passed away, had a work account with a connection to the Internet and posted a listing of the program for me on the Usenet group comp.sys.handhelds; that was (by proxy) my very first Internet activity of any kind.
Playing with the HP 50G in emulation for a little while... in some ways it does seem like the ultimate refinement of the RPL line; in other ways, there are things I don't like.
The keyboard was rearranged completely to give it a more TI-84-like feel, and it makes it hard for me to find stuff. But on the other hand, I give the keyboard layout huge credit *just* for including an unshifted X key, which is a great convenience for entering algebraic formulae.
It doesn't have an i key, but they did make it so that (unlike the 48 models) i requires only a single shift rather than shift + alpha. That is good too.
(Some of their other later RPN calculators actually included a built-in i key, which was great for electrical engineers.)
...Something I'd been a little curious about was why so many people preferred the classic, simpler version of HP's RPN that there was continued demand for it *after* RPL appeared.
Playing with it in emulation, I think I get it: while I don't personally prefer it, it's just different enough for the difference to throw off muscle memory, which I think is something that gets people who do a lot of calculation attached to a particular model. And it's maybe simpler to explain, though every model seemed to handle things like complex numbers and matrices differently.
One difference is in a subtlety of how number entry and the ENTER key work: in classic RPN, you're typing directly into the X register (the lowest stack level), and ENTER always pushes the stack and copies it to Y.
In RPL, you're really typing into a separate input buffer, and ENTER will push the stack and move that to the lowest level, giving you an opportunity to cancel errors before altering the stack (but operators also do an implicit ENTER if you're entering a number). ENTER only copies to the second stack level if you aren't entering data. It's a very subtle difference but can throw you off.
Another quirk of classic RPN with its four-level stack was that the fourth, top level, T, was "sticky"-- dropping the stack would copy anything in it to the lower levels, so it was like you had infinite copies of whatever was in there. People could take advantage of that, and that behavior went away with the "infinite" stack in RPL.
...also, since classic RPN evolved from a system that only supported floating point numbers, all stack levels contained the number 0 by default. RPL, with its sophisticated type system, also has a concept of null, and the stack starts out empty, with math operators unable to act on it. That's a big difference.
So I can see a lot of engineers who wanted to bang on numbers and did not want to think about computer science concepts preferring the classic system.
(So if you go back and read closely, you'll see that in my post describing RPN, I was technically describing the RPL version of RPN because that was what I was familiar with. If you learned RPN from the computer language Forth or Postscript, those are actually closer to the RPL version of RPN than to the classic HP version.
Though there's also another terminology difference in that in those languages you usually imagine the business end of the stack as being the top, rather than the bottom, and items "pop" off the stack instead of "dropping" off. I think HP had multi-line displays on their desktop calculators from early on, so this was more than just conceptual there.)
LISP/SCHEME:
(* 7 12)
Translates to
( listen up
* I want to multiply
7 seven
12 by twelve
) You got that?
The parentheses encapsulate the whole thing so I don't care about the state of the stack or whatever variables might be defined or whatever.
Algebraic:
7*12
Translates to
7 here's a number. Without context and for no reason.
* I want to multiply that number
12 by twelve. Aren't you glad you hung on to that random number I gave you earlier?
And don't even get me started on implied multiplication like "2x". Math horror.
FORTH/PostScript/RPN:
7 12 *
Translates to
7 here's a number. Without context and for no reason.
12 here's another number. Bear with me. It'll all make sense in the end. Trust me, bro.
* Remember those numbers I gave you? I want them multiplied.
This just never made sense to me...
@SvenGeier Maybe I don't know what I want to do with those numbers until I've got them! RPN tends to support an exploratory mode of operation.
Most scientific calculators from the Eighties or so had an entry mode that was mostly algebraic, but evaluated single-input things like trig functions as postfix. I'm still used to that and have trouble using modern algebraic calculators where you press 30 SIN and you get "30∙SIN(".
@SvenGeier Anyway, Casio made a handheld Lisp machine in 1989--the "fifth-generation computing" era produced some remarkable things, especially in Japan:
@SvenGeier and if you think that's remarkable, check out Sega's 1986 Prolog machine for kids:
(tip of the hat to @timchuma )
(I can just imagine both of these triggering intense "OMG Japan will eat us" anxiety in American Eighties Guys)
@mattmcirvin A hand-held LISP machine. Now I finally know what I might do with a Raspberry Pi ...
@SvenGeier There's a commercial project called PockEmul which is trying to emulate some huge number of old calculators with emphasis on Sharp and Casio models--this is one of them. I haven't tried it though.
@mattmcirvin I always wondered where "reverse Polish notation" came from... I feared it was an insult (akin to Polish jokes from bygone times).
Thanks!
@KarenCampe I was always afraid of that too, since these calculators appeared at a time when that kind of ethnic joke was inexplicably popular. I suspect there *was* an angle of English speakers not being able to spell or pronounce "Łukasiewicz", and that kind of thing can have this odd performative aspect.
@mattmcirvin
I had a HP15c for many years. Even now I use an RPN calculator on my phone ("realcalc" on Android).
RPN is, to me, the easiest way to think about numerical calculations. Using parentheses for grouping feel clumsy by comparison.
@jannem Some of my grad school classmates had the 15c-- it seems to be a particularly beloved model. The financial counterpart, the 12c, became such an industry standard that it is still sold today, in a version with modern internals but an essentially identical case design to the original.
@mattmcirvin
It's definitely easier to work out calculations on the fly with RPN and put off deciding to do with the parts to later. Like first work out the mass, then work out the velocity, square that, multiply by the mass that's still on the stack, now divide by 2.
The stack seems small, but is sufficient for all arithmetic and two arg functions.
@Sdowney Even with an unlimited stack, you soon prefer to organize calculations so that it doesn't get too deep, to reduce the cognitive load. It helps to be able to see more of it though.
A pattern I liked to use a lot with the tall RPL-style stack was that if there were a bunch of numbers or terms I wanted to add together, I'd put them all on the stack, review them to make sure they made sense and only add them up at the end. A deep stack with a multi-line display helps with that. It's not too different from the adding-machine logic in accountants' desk calculators, where the printer prints out all the terms while the machine internally maintains a running total/subtotal. Useful when you're dealing with money--I just hauled out the 48 emulator when helping my daughter fill out college financial-aid documentation. Though I suppose a spreadsheet might have been more appropriate.
@Sdowney The *comments* on this old video about the HP-12C are fascinating:
https://www.youtube.com/watch?v=Ot6rgGJv46E
because when he talks about how it works, he doesn't even use the word "stack", he just mentions the X and Y registers. And then he talks about the numbered storage registers, but he doesn't mention the stack going higher than Y.
And that results in a bunch of people in the comments saying "wow, I could never understand RPN but you just explained it in a way that made me understand."
Maybe keeping it finite and small reduces the cognitive load.
@mattmcirvin
I inherited my Dad's 12C a few months ago. Mine vanished sometime after I got out of WallSt a few decades ago.
I have my 28s at my desk, but need to replace the batteries again.
An elegant weapon for a more civilized age.
But I mostly use the a41cv android app.
@mattmcirvin strangely I was lent an HP-3X series calculator for a few weeks in school until my parents, who were dead against calculators being used in schools, finally understood why I needed to have my own calculator. I still prefer RPN, but can fly Casio. Before the HP, I used Log and Trig tables, because I had to do the homework. I still have tables as a Last Resort.
@mattmcirvin I miss my HP48... The best calculator I ever had.
@mattmcirvin @john_chu I got an HP calculator for Christmas when I was in high school, I'm guessing around 1977 or so, and I *adored* RPN.
@mattmcirvin
There were two nerd camps in my time.
The TI-59 camp, and the HP-41C camp.
I was in the TI-59 camp.
We wore them in belt holsters like gun fighters.
@EricCarroll I remember seeing the ads for the TI-59 when it first came out. Magnetic-card storage and ROM expansion modules made it seem very futuristic--the HP-41C had similar capabilities.
By selling my TI-59 (upgraded from TI-57) to my math teacher in school, I went to the HP RPN camp with the HP-34C and never looked back. My dad had an HP-67 which I couldn’t afford. Maybe that was more comparable to the TI-59?
I still use the Voyager series (bought an HP-12C for my economics studies and work), mostly HP-11C and the 12C.
The whole 80s era HP calculators were such a joy. This is what’s left from that time: https://mastodon.social/@bondo/111516485729579693
@mattmcirvin I saw "RPL" and "RPN" in your posts and spent about 30 seconds trying to figure out "what kind of Role Playing is he talking about?" before I remembered Reverse Polish Notation.
I never had an HP calculator, especially not a programmable one, so when people talk about RPN, I think "oh yeah, FORTH." I had never heard of RPL before, and I'm not sure I understand how it works from the example.
@urbeatle FORTH was one of the inspirations for RPL, though as I recall the control structures in FORTH for loops and such are much more strictly postfix whereas RPL'S parser cheats a little to make them more "normal" looking. But RPL also borrows a lot from Lisp.
@urbeatle The most culturally significant FORTH derivative may have been PostScript, though. I had to learn that for professional reasons.
@urbeatle As for the code examples, the only relevant facts are that guillemets define a code block, single quotes instead define an algebraic expression, and the right arrow assigns objects on the stack to local variables (often used for function arguments).
@mattmcirvin have you read "Empire of the Sum: The Rise & Reign of the Pocket Calculator" by Keith Houston?
Interesting engineering & economic history.
@KarenCampe I have not but I heard it being discussed on a podcast a while back.
@KarenCampe @mattmcirvin This has been on my wish list for a long while, hope to get it some day! Glad you like it; now I look forward even more
I got my local library to purchase it (I have *way* too many books here )
@mattmcirvin I loved my 28S, it was a bit slower than the 48 SX, but the double keyboard was really good. I feel sorry now that I sold it so many years ago.
@mattmcirvin Second ever calculator I got to play with (owning came later) was an HP. But the first, owned by an accountant uncle, I have never seen the like of since. It didn't use buttons, it had metal pads, and you entered a number by touching the metal tip of the stylus that was connected by a cable and plugged into the side. Like the Rolf Harris advertised (while he was persona grata) stylophone. I had fun doing illegal things - the state of the art didn't do proper error handling.
I use a 48gx app in my phone. You can even load programs coded in a txt.
And I prefer the real one despite it is slower… It still works perfectly.
@guetto I do like devices with well-made physical buttons, and I miss their general disappearance.
@mattmcirvin I have a 48s still in the lab, and I introduce it to every student who sets foot in it, just to encourage them to think differently. Unfortunately it is getting a bit on in years and sometimes doing normal calculations it just beeps and crashes. But I find it so convenient to use that I’m keeping my eyes peeled for a modern alternative, ideally with the same nice solid tactile button feel.
@doc At the moment, there isn't a true modern alternative that is a physical calculator. The RPL line died with the 50g. The HP Prime has a simpler RPN mode but that's not its main focus, and there's also the HP35s which is a sort of nostalgic exercise implementing the old-school RPN. HP isn't really HP any more-- their calculators are made by Kinpo Electronics, a Taiwanese company, under license.
There's a company called Swiss Micros that makes these sort of tributes to old HP calculators (rather pricey ones) and its software guy seems to be trying to revive RPL in some super-ambitious new-generation form. I don't have a feel for how likely it is to result in a usable product.
@mattmcirvin thanks for the insight, it’s unfortunate to know the line has all but dried up. I see the occasional 35s on Amazon but haven’t gotten one yet.
Ah well, I guess we got to change with the times.
@doc
The 50g isn't that old (made from about 2006-2015) so used ones in good shape may be readily available. It actually defaulted to an algebraic mode but when you switch it to RPN, it seems like a worthy successor to the 48 albeit with a pretty different keyboard layout.
Phone apps are your easiest way to experience these machines today, but they don't have that tactile reality.
@mattmcirvin thanks for the tip. Are the buttons on the 50g any decent?
@doc I don't really know since I haven't handled a real one! I heard bad things about the keyboard on the 49, its lower-end counterpart.
@mattmcirvin @doc after our conversation I couldn’t help but pick this one up at a second hand store they also had a 17s but this one looked cooler
@doc The amazing thing about the 12c is that it's the one RPN model that has stayed in production essentially externally unchanged *to this day*, because it became a near-universal standard for time-value-of-money calculations and such in the financial industry.
The version they sell now is using a modern processor on the inside, so it's much faster but the battery life may not be as good. HP doesn't even make their own calculators any more, but apparently it's a good emulation of the original.
@doc Back in the 80s-90s, I remember some of my friends carried one or the other of the scientific counterparts of this model (the 10c, 11c or 15c). I always liked the physical layout.
The same line had a programmer's calculator, the 16c, which specialized in bit-twiddling operations with any desired word size. I just saw a video of someone demonstrating that one and realized I could have gotten a lot of use out of it in the late 1990s-early 2000s. The calculator I did have *could* do those operations but didn't foreground them in the same convenient way.
@mattmcirvin I have an HP 48SX, complete with user manual, reference manual, and serial cable. Great calculator, great FORTH-like learning tool. And the first device I owned that used AAA batteries when they weren't commonly available. Got them from a camera store, when *those* still existed...
@bobjonkman definitely easier to find these days than the N cells the 28S ran on.