Post Reply 
Is RPN still relevant?
12-23-2023, 11:36 PM
Post: #83
RE: Is RPN still relevant?
(12-21-2023 01:27 PM)rprosperi Wrote:  The incomplete question "Is RPN still relevant?" is simply not clear enough for any kind of consensus, as the disparate and diverse replies show.

Is RPN still relevant for the public at large?

Is RPN still relevant for high-end calculator users?

Is RPN still relevant for readers of this MoHPC Forum?

Is RPN relevant for American (or substitute UK, EU, China, Indonesian, 3rd-world, etc.) school children?

are all questions that might reasonably be debated, likely with differing conclusions, but as initially asked is so wide open as to be impossible to reach a conclusion.
This separation into different domains is indeed important, thank you. While I have nothing to add on the latter three domains, the "public at large" one is in need of some addition.

In certain (admittedly somewhat niche) topics reverse polish notation remains relevant, maybe even inescapable. The one that immediately comes to my mind is parsers (for programming languages, mathematical expressions, etc). Case in point: just yesterday independent game development studio Wube Software released a blog post in their Factorio Friday Facts series containing the following tidbit with a mention of RPN.
FFF-390 Wrote:The parser was split into three logical parts.

  1. Tokenizer, which processes a stream of characters and categorises individual character groups to token types. The operator character set is based on Lua with a few exceptions where both C++ and Lua syntax are supported. Apart from regular numbers, it supports scientific notation, and other formats can be added as needed.
  2. PostfixTokenizer, which converts infix tokens to postfix (reverse Polish) notation. This step is responsible for following operator precedence rules and for making sure that resulting expressions are unambiguous. It uses a modified version of the shunting yard algorithm to process data.
  3. NoiseExpressionParser, which takes postfix tokens and converts them to a noise expression tree (AST).
(Original post here.)

Ironically the need for a parser means modern algebraic calculators likely contain some RPN deep inside their bowels. You'd have to get their firmware source code or engage in an excessive amount of reverse engineering to find it, but there's a very good chance it's there.

Outside the world of calculators, here's a piece of what Clang can spit out when instructed to print the Abstract Syntax Tree of a C program. In particular, this is a function call.
Code:
|   |-CallExpr 0x559193b5a4b0 <line:19:1, col:41> 'void'
|   | |-ImplicitCastExpr 0x559193b5a498 <col:1> 'void (*)(struct list *, void *)' <FunctionToPointerDecay>
|   | | `-DeclRefExpr 0x559193b5a3e0 <col:1> 'void (struct list *, void *)' Function 0x559193b597c8 'appendToList' 'void (struct list *, void *)'
|   | |-ImplicitCastExpr 0x559193b5a4e0 <col:16> 'struct list *' <LValueToRValue>
|   | | `-DeclRefExpr 0x559193b5a400 <col:16> 'struct list *' lvalue Var 0x559193b5a0d8 'l' 'struct list *'
|   | `-ImplicitCastExpr 0x559193b5a4f8 <col:27> 'void *' <LValueToRValue>
|   |   `-DeclRefExpr 0x559193b5a420 <col:27> 'void *' lvalue Var 0x559193b5a020 'elem' 'void *'
Printed this way, it looks more similar to RPN's sibling Polish Notation, but the Reverse part is just a matter of traversing the same AST differently (parent nodes after their children instead of before). In code generation there's bound to be a part processing this into instructions to place parameters onto the target processor's stack, followed by the instruction to actually issue the call. It'll be obscured by handling for (platform-specific) register-passed parameters and other optimizations, of course, but if you can look past that, you'll recognize the RPN basics even in this widely used program.

Other compilers similarly have a pinch of RPN (or maybe in some cases just PN) in them. And in the world of academia, the compiler-adjacent automata theory works with a stack once you move past type 3 automata in the Chomsky hierarchy into type 2, This stack obviously lends itself to RPN style utilization. Types 1 and 0 correspond to Turing machines (with a certain limitation for type 1), with a tape memory instead, but that could be described as two stacks (one in each direction of the type head), or maybe as a stack you can ROLL like we do in RPL.
Either way, deep within computers, RPN is lurking. Not many people dig that deep anymore (which I think is a problem as it easily leads to misconceptions), but once you need to, you'd be better off if you can wrap your brain around RPN.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Is RPN still relevant? - Matt Agajanian - 12-17-2023, 06:50 AM
RE: Is RPN still relevant? - Garth Wilson - 12-17-2023, 07:28 AM
RE: Is RPN still relevant? - ttw - 12-17-2023, 03:36 PM
RE: Is RPN still relevant? - Philk27 - 01-08-2024, 06:49 AM
RE: Is RPN still relevant? - Albert Chan - 12-17-2023, 04:29 PM
RE: Is RPN still relevant? - rprosperi - 12-18-2023, 02:02 AM
RE: Is RPN still relevant? - bxparks - 12-17-2023, 04:34 PM
RE: Is RPN still relevant? - cdmackay - 12-17-2023, 06:30 PM
RE: Is RPN still relevant? - Commie - 12-17-2023, 07:52 PM
RE: Is RPN still relevant? - Garth Wilson - 12-17-2023, 08:37 PM
RE: Is RPN still relevant? - Commie - 12-17-2023, 08:53 PM
RE: Is RPN still relevant? - Thomas Klemm - 12-17-2023, 07:23 PM
RE: Is RPN still relevant? - dm319 - 12-17-2023, 09:33 PM
RE: Is RPN still relevant? - ijabbott - 12-18-2023, 12:08 PM
RE: Is RPN still relevant? - bxparks - 12-18-2023, 03:18 PM
RE: Is RPN still relevant? - dm319 - 12-18-2023, 11:32 PM
RE: Is RPN still relevant? - Garth Wilson - 12-20-2023, 10:26 PM
RE: Is RPN still relevant? - cjsuk - 12-17-2023, 10:11 PM
RE: Is RPN still relevant? - Roberto Volpi - 12-18-2023, 05:28 AM
RE: Is RPN still relevant? - rprosperi - 12-18-2023, 01:21 PM
RE: Is RPN still relevant? - rprosperi - 12-18-2023, 10:53 PM
RE: Is RPN still relevant? - Philk27 - 01-08-2024, 07:11 AM
RE: Is RPN still relevant? - Thomas Radtke - 12-18-2023, 06:43 AM
RE: Is RPN still relevant? - carey - 12-18-2023, 07:56 AM
RE: Is RPN still relevant? - Garth Wilson - 12-18-2023, 09:23 AM
RE: Is RPN still relevant? - carey - 12-18-2023, 11:00 AM
RE: Is RPN still relevant? - dm319 - 12-18-2023, 01:50 PM
RE: Is RPN still relevant? - Peter Klein - 12-19-2023, 07:54 AM
RE: Is RPN still relevant? - Garth Wilson - 12-20-2023, 10:27 PM
RE: Is RPN still relevant? - carey - 12-20-2023, 01:24 AM
RE: Is RPN still relevant? - Garth Wilson - 12-20-2023, 10:24 PM
RE: Is RPN still relevant? - Siegfried - 12-19-2023, 05:39 AM
RE: Is RPN still relevant? - compsystems - 12-18-2023, 07:49 PM
RE: Is RPN still relevant? - avsebastian - 12-19-2023, 02:51 AM
RE: Is RPN still relevant? - Thomas Klemm - 12-19-2023, 03:14 AM
RE: Is RPN still relevant? - Hans S. - 12-19-2023, 06:09 PM
RE: Is RPN still relevant? - Thomas Klemm - 12-19-2023, 03:38 AM
RE: Is RPN still relevant? - Thomas Klemm - 12-19-2023, 03:53 AM
RE: Is RPN still relevant? - Peter Klein - 12-19-2023, 07:42 AM
RE: Is RPN still relevant? - Peet - 12-19-2023, 07:50 PM
RE: Is RPN still relevant? - ctrclckws - 12-19-2023, 08:04 PM
RE: Is RPN still relevant? - dm319 - 12-19-2023, 08:31 PM
RE: Is RPN still relevant? - MikeSD - 12-20-2023, 05:04 PM
RE: Is RPN still relevant? - carey - 12-21-2023, 12:43 AM
RE: Is RPN still relevant? - bxparks - 12-22-2023, 07:11 PM
RE: Is RPN still relevant? - Voldemar - 12-22-2023, 09:16 PM
RE: Is RPN still relevant? - bxparks - 12-22-2023, 09:53 PM
RE: Is RPN still relevant? - Voldemar - 12-22-2023, 10:37 PM
RE: Is RPN still relevant? - bxparks - 12-22-2023, 11:01 PM
RE: Is RPN still relevant? - avsebastian - 12-28-2023, 12:41 AM
RE: Is RPN still relevant? - Steve Simpkin - 12-28-2023, 11:18 AM
RE: Is RPN still relevant? - twoweims - 12-28-2023, 10:55 PM
RE: Is RPN still relevant? - rprosperi - 12-21-2023, 01:27 PM
RE: Is RPN still relevant? - Garth Wilson - 12-22-2023, 03:49 AM
RE: Is RPN still relevant? - Peter Klein - 12-22-2023, 05:22 AM
RE: Is RPN still relevant? - 3298 - 12-23-2023 11:36 PM
RE: Is RPN still relevant? - dm319 - 12-24-2023, 11:32 AM
RE: Is RPN still relevant? - ijabbott - 12-24-2023, 04:28 PM
RE: Is RPN still relevant? - Peet - 12-23-2023, 11:44 PM
RE: Is RPN still relevant? - dm319 - 12-21-2023, 07:06 PM
RE: Is RPN still relevant? - Peet - 12-21-2023, 07:48 PM
RE: Is RPN still relevant? - polbit - 12-22-2023, 01:55 AM
RE: Is RPN still relevant? - dm319 - 12-22-2023, 08:20 AM
RE: Is RPN still relevant? - Siegfried - 12-23-2023, 07:45 AM
RE: Is RPN still relevant? - Voldemar - 12-23-2023, 10:30 AM
RE: Is RPN still relevant? - Thomas Klemm - 12-23-2023, 12:14 PM
RE: Is RPN still relevant? - cdmackay - 12-23-2023, 08:22 PM
RE: Is RPN still relevant? - Steve Simpkin - 12-24-2023, 12:52 AM
RE: Is RPN still relevant? - cdmackay - 12-25-2023, 01:00 AM
RE: Is RPN still relevant? - avsebastian - 12-28-2023, 12:50 AM
RE: Is RPN still relevant? - trojdor - 12-28-2023, 01:15 AM
RE: Is RPN still relevant? - cjsuk - 12-28-2023, 10:16 AM
RE: Is RPN still relevant? - Thomas Klemm - 12-29-2023, 12:57 PM
RE: Is RPN still relevant? - Thomas Klemm - 01-09-2024, 06:01 PM



User(s) browsing this thread: 1 Guest(s)