I teach computing to 18 year olds. After having reverse polish notation explained to them one asked why is it significant enough to be in the public exam. I explained the historical significance of 70s calculators but this failed to really address the issue. So are there and concurrent practical or theorhetical applications of RPN.
I've used RPN several times for rapid prototyping, e.g. of programs that have to read and interpret a user-supplied mathematical expression.
Whereas regular mathematical notation would require at least a recursive parser (think brackets, operator order, etc...), an RPN parser is basically a stack with a
switch-like statement. I guess it's this combination of simplicity and expressive power that led HP to use it initially.
This is, however, usually for rapid prototyping and for convenience. I would never assume that a user can, or wants to, understand RPN.
Just to expand the previous answers/comments: don't forget that RPN is alive and on great form ... indeed it is currently used in stack machines like the Java virtual machine.
From Wikipedia: "... a stack machine implements a stack with registers. The operands of the arithmetic logic unit (ALU) are always the top two registers of the stack and the result from the ALU is stored in the top register of the stack. 'Stack machine' commonly refers to computers which use a Last-in, First-out stack to hold short-lived temporary values while executing individual program statements. The instruction set carries out most ALU actions with postfix (Reverse Polish notation) operations that work only on the expression stack, not on data registers or main memory cells ..."
Forth and PostScript (and thus PDF which IIRC started as a binary encoding of a subset of PostScript) are more well known postfix languages that HP pocket calculator one.
Then it is also a relatively common choice as intermediate representation in simple compilers.
The simpler VM tend to have also a postfix "machine" language.
With regards to calculators: See What is RPN?
Benefits: RPN saves time and keystrokes. You avoid using and keeping track of parentheses while doing calculations. The process is similar to the way you learned math on paper.
You can see the intermediary results as you perform your computations rather than just the answer at the end. This is extremely helpful for learning the logic. Math teachers are using this feature to improve student understanding of mathematics.
An intermediate result allows the user to check the answer and correct errors more easily. It's easier to follow the stream of calculation. The user defines the priority of operators.
RPN is logical because the user first gives the number and then tells what to do with it.
As the name indicates, Reverse Polish Notation, or Direct Polish notation, are notations. They are syntax for representing something, and actually efficient syntax if you consider memory requirements. What they represent are rooted trees, which can be formulae, abstract syntax trees (AST), and other kinds of entities, that anyone has a constitutional right to consider absolutely useless.
Occasionally, one has to store such entities on file. For example there are systems that may edit or transform programs as AST, and may need to store such representations. Polish Form is convenient. It has limited readability for humans, especially for large trees, but it is a very convenient representation for machines.
Another aspect of it is that I believe the study of trees and their elementary uses and representation, as well as associated devices (stacks), to be pedagogically useful as an introduction to future studies of more advanced concepts (syntax, parsing, logic, linguistics, ...).
It has also the advantage of being conceptually rather simple, and easy to experiment on paper. It is also a nice occasion to discuss syntax and the fact that syntax is representation, and that representations may vary, while representing the same thing, and that different representations may be used depending on the need to be met (space optimization, easy modification, human readability, computer readability, ...).
But I am surprised that this question, and its answers, are considering only RPN, and none considers direct polish notation.
It is certainly excellent that students ask. But answering such question always has diverse aspects. Is it useful for the knowledge itself? I think it is. Is it useful as pedagogical exercise? I think it is, but that depends much on the intended audience, and only the teacher can assess what it is able to understand. Is it useful to understand some conceptual issues? I think it is, but again it depends on the teacher's assessment of what concepts can be explained to their students.
Your student was absolutely right. Reverse Polish Notation is not significant enough in computer science to be worth spending very limited class time on it. Instead, there are so many other wonderful conceptual ideas you could have taught, with deep intellectual ideas: stable marriage, cake-cutting, diagonalization and undecidability of the halting problem, interactive proofs and zero-knowledge proofs, etc., etc. Yes, all of those can be made accessible to 18-year-olds.
And, I do hope you praised your student for being brave enough to ask the question! They had to put themselves on a ledge to raise the issue. It speaks well for your teaching style that they felt comfortable asking you this question.
Reverse Polish Notation was a good tool in my education for understanding parse trees and tree data structures in general. It's also useful if anyone has any interest at all in programming in any of the Lisp family of languages (Clojure, emacs-lisp, scheme etc..).
protected by FrankW Sep 16 '14 at 9:21
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?