# Not Backus-Naur Form

**URL:** <https://boards.straightdope.com/t/not-backus-naur-form/767038>\
**Category:** Factual Questions\
**Created:** [September 27, 2016, 2:36pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038 "2016-09-27T14:36:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cartoonacy](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@Cartoonacy](https://boards.straightdope.com/u/Cartoonacy)\
**Post date:** [September 27, 2016, 2:36pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/1 "2016-09-27T14:36:43Z")

</div>

When I was in college studying computer science 38 years ago, we learned about a form of mathematical notation called Backus-Naur Form (or Backus Normal Form, or as we students called it, Backwards is Normal Form). In BNF, so we were taught, the operator follows the operands. For example, instead of writing…

(5 + 7) \* 3 - 6

…in BNF one would write…

5 7 + 3 \* 6 -

I just looked at the Wikipedia entry on Backus-Naur Form, and it has nothing to do with arithmetic notation. It says that BNF is a grammar for describing the syntax of a programming language.

If this is the case, either the definition has changed, or (more likely) my memory is flaky. In either case, there must be a name for the alternate arithmetic notation that I remembered as BNF. What is it?

---

<div class="post-metadata">

**Author:** ![74westy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/74westy/32/3950_2.png) [@74westy](https://boards.straightdope.com/u/74westy)\
**Post date:** [September 27, 2016, 2:40pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/2 "2016-09-27T14:40:01Z")

</div>

[Reverse Polish](https://en.wikipedia.org/wiki/Polish_notation).

---

<div class="post-metadata">

**Author:** ![TimeWinder](https://avatars.discourse-cdn.com/v4/letter/t/bcef8e/32.png) [@TimeWinder](https://boards.straightdope.com/u/TimeWinder)\
**Post date:** [September 27, 2016, 2:40pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/3 "2016-09-27T14:40:12Z")

</div>

BNF is, in fact, a language grammar description notation.

You’re thinking of RPN ([Reverse Polish Notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation)), like high-end HP calculators.

---

<div class="post-metadata">

**Author:** ![Rysto](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@Rysto](https://boards.straightdope.com/u/Rysto)\
**Post date:** [September 27, 2016, 2:40pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/4 "2016-09-27T14:40:52Z")

</div>

I normally hear that referred to as “[reverse Polish notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation)”.

---

<div class="post-metadata">

**Author:** ![UncleRojelio](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/unclerojelio/32/3160_2.png) [@UncleRojelio](https://boards.straightdope.com/u/UncleRojelio)\
**Post date:** [September 27, 2016, 2:47pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/5 "2016-09-27T14:47:14Z")

</div>

You could also call it ‘post-fix’ notation, as opposed to ‘in-fix’ or ‘pre-fix’ notation.

---

<div class="post-metadata">

**Author:** ![naita](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/naita/32/5862_2.png) [@naita](https://boards.straightdope.com/u/naita)\
**Post date:** [September 27, 2016, 3:09pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/6 "2016-09-27T15:09:36Z")

</div>

All the cool kids had RPN-calculators when I studied engineering 20 years ago.

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [September 27, 2016, 3:20pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/7 "2016-09-27T15:20:23Z")

</div>

Yes, you’ve confused BNF for RPN.

Maybe because a common computer science exercise is to make a RPN calculator in a stack-based language like Forth, which would be described with BNF.

---

<div class="post-metadata">

**Author:** ![Duke\_of\_Rat](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@Duke\_of\_Rat](https://boards.straightdope.com/u/Duke_of_Rat)\
**Post date:** [September 27, 2016, 3:35pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/8 "2016-09-27T15:35:09Z")

</div>

> [@naita](#):
>
> All the cool kids had RPN-calculators when I studied engineering 20 years ago.

I’ve had my HP 11C for 30 years! Damn, I hadn’t thought about when I bought that thing in a while.

I was SA to the head of the math department, she looked sideways at us geeks with RPN calculators, she was a TI fan. So she’d make up complex (only algebra level stuff) equations and we’d race, her TI vs my HP. And I could beat her about half the time.

Are RPN calculators still popular with geeks in school these days?

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [September 27, 2016, 4:04pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/9 "2016-09-27T16:04:58Z")

</div>

I’ve had my HP-35 for over forty years. It hasn’t worked in decades though. It might just be the (non standard) batteries but I’ve never bothered to try to replace them.

RPN is the only way to go! I hate using non-RPN calculators.

–Mark

---

<div class="post-metadata">

**Author:** ![CookingWithGas](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/cookingwithgas/32/485_2.png) [@CookingWithGas](https://boards.straightdope.com/u/CookingWithGas)\
**Post date:** [September 27, 2016, 4:09pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/10 "2016-09-27T16:09:50Z")

</div>

I was in college studying computer science 38 years ago and your memory just committed a hardware fault. 😉

---

<div class="post-metadata">

**Author:** ![Duckster](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/duckster/32/1244_2.png) [@Duckster](https://boards.straightdope.com/u/Duckster)\
**Post date:** [September 27, 2016, 4:14pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/11 "2016-09-27T16:14:58Z")

</div>

Yoda speaks in RPN.

---

<div class="post-metadata">

**Author:** ![leahcim](https://avatars.discourse-cdn.com/v4/letter/l/b4bc9f/32.png) [@leahcim](https://boards.straightdope.com/u/leahcim)\
**Post date:** [September 27, 2016, 4:18pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/12 "2016-09-27T16:18:24Z")

</div>

Since others have given the correct name, here’s a [video](https://www.youtube.com/watch?v=7ha78yWRDlE) on the topic.

“Polish” notation is basically, “we can’t pronounce the name of the guy who popularized this but he was Polish” notation.

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [September 27, 2016, 4:25pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/13 "2016-09-27T16:25:34Z")

</div>

> [@Duckster](#):
>
> Yoda speaks in RPN.

You mean “In RPN Yoda speaks”.

–Mark

---

<div class="post-metadata">

**Author:** ![gnoitall](https://avatars.discourse-cdn.com/v4/letter/g/bb73d2/32.png) [@gnoitall](https://boards.straightdope.com/u/gnoitall)\
**Post date:** [September 27, 2016, 4:39pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/14 "2016-09-27T16:39:25Z")

</div>

> [@leahcim](#):
>
> Since others have given the correct name, here’s a [video](https://www.youtube.com/watch?v=7ha78yWRDlE) on the topic.
> 
> “Polish” notation is basically, “we can’t pronounce the name of the guy who popularized this but he was Polish” notation.

Indeed, [Jan Łukasiewicz](https://en.wikipedia.org/wiki/Jan_%C5%81ukasiewicz).

Commonly held misconception: RPN is precisely what Łukasiewicz invented. Łukasiewicz invented PN, a prefix-oriented notation in which operation symbols precede operands. So that “(5 − 6) × 7” in conventional infix algebraic notations becomes “× − 5 6 7” in classic Łukasiewicz.

RPN, Reverse Polish, is a postfix notation. In this, you state operations after operands, like “5 6 - 7 ×”. RPN is nice because it’s easy to implement in a simple stack-oriented calculator: push operands on the stack as they occur in the input symbol stream, pop operands to process when encountering an operator. Push results back on the stack. In non-reversed, you push operations and manipulate operands out-of-stack, and requires a bit of “look-ahead” in the input stream (in other words, if an operation is binary, you have to know the two operands in the input stream). In RPN, the state of the calculation is completely held in the stack and the stream position. Simplicity.

But no, not Backus-Naur Form at all. The only things the two have in common are they’re both TLAs and they both occur in computer science subjects, albeit in slightly different spheres.

---

<div class="post-metadata">

**Author:** ![ftg](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ftg/32/2801_2.png) [@ftg](https://boards.straightdope.com/u/ftg)\
**Post date:** [September 27, 2016, 4:39pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/15 "2016-09-27T16:39:36Z")

</div>

The two would be taught nearly side-by-side in a classic compiler course. The syntax of expressions (and whole programming languages) would be given in BNF. Using a BNF parser, you could then generate the expression in RPN, which in turn can be converted into assembly language.

So both are involved in different stages of the process.

Once stuff like [yacc](https://en.wikipedia.org/wiki/Yacc) came along, this became much easier. (Then came Bison which in turn inspired the name GNU, if you wanted to know where that came from.)

---

<div class="post-metadata">

**Author:** ![leahcim](https://avatars.discourse-cdn.com/v4/letter/l/b4bc9f/32.png) [@leahcim](https://boards.straightdope.com/u/leahcim)\
**Post date:** [September 27, 2016, 4:46pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/16 "2016-09-27T16:46:11Z")

</div>

> [@gnoitall](#):
>
> RPN is nice because it’s easy to implement in a simple stack-oriented calculator: push operands on the stack as they occur in the input symbol stream, pop operands to process when encountering an operator. Push results back on the stack.

The same process is the computation model for PostScript and JVM bytecode. Just gigantic stack machines.

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [September 27, 2016, 4:52pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/17 "2016-09-27T16:52:04Z")

</div>

> [@ftg](#):
>
> (Then came Bison which in turn inspired the name GNU, if you wanted to know where that came from.)

I don’t think so. The GNU project started in 1983. Bison was written in 1988.

–Mark

---

<div class="post-metadata">

**Author:** ![Hari\_Seldon](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/hari_seldon/32/5173_2.png) [@Hari\_Seldon](https://boards.straightdope.com/u/Hari_Seldon)\
**Post date:** [September 27, 2016, 4:53pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/18 "2016-09-27T16:53:13Z")

</div>

Just to set record straight, algebraic is best for a product (an already given formula), while RPN is best for a process. As an example, consider the equation F = (m\_1m\_2)/d^2. On an algebraic calculator, you put in (m\_1_m\_2)/r_r=. On an HP, you think of a process, take m\_1 and m\_2 and multiply them. Then take r and square it. Then divide.

FWIW, I find an algebraic calculator a royal PITA.

## When we were in elementary, we used something that might be called VPN (vertical Polish notation): 2 2 +

4

Backus-Naur is a formal syntax for describing programming languages. I find it unreadable.

---

<div class="post-metadata">

**Author:** ![GreenWyvern](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/greenwyvern/32/2834_2.png) [@GreenWyvern](https://boards.straightdope.com/u/GreenWyvern)\
**Post date:** [September 27, 2016, 4:53pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/19 "2016-09-27T16:53:28Z")

</div>

> [@naita](#):
>
> All the cool kids had RPN-calculators when I studied engineering 20 years ago.

Huh, I had an RPN calculator when I was studying physics and computer science in the late 1970s, back when HP first starting making them. They were \*\*\*ultra \*\*\*cool. I had an HP 29C, which was… wait for it… _programmable_.

I still love RPN calculators today. I found a great one for my android phone - so good that I even paid for it, even though there are so many free calculator apps around. [RealCalc](https://play.google.com/store/apps/details?id=uk.co.nickfines.RealCalc&hl=en) (I’m not affiliated with them.)

---

<div class="post-metadata">

**Author:** ![Voyager](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/voyager/32/133_2.png) [@Voyager](https://boards.straightdope.com/u/Voyager)\
**Post date:** [September 27, 2016, 5:27pm UTC](https://boards.straightdope.com/t/not-backus-naur-form/767038/20 "2016-09-27T17:27:53Z")

</div>

> [@CookingWithGas](#):
>
> I was in college studying computer science 38 years ago and your memory just committed a hardware fault. 😉

I know I learned it in 1974 when I took compilers in grad school, and I suspect I learned it a few years before that.

I’ve also seen BNF defined as Backus Normal Form, though I’ve seen Backus Naur Form also.

[Next page](https://boards.straightdope.com/t/not-backus-naur-form/767038.md?page=2)
