The double entry writing style, also known as Knuth-Schützenberger priority or reverse Polish notation, is a method of parsing mathematical expressions in which operators are placed after their operands. This unique approach offers several benefits, including the ability to omit parentheses and improved legacy code readability. Let's delve into this distinctive style, explore its advantages, and understand how it works.

Double-entry journals: a flexible reading comprehension tool
Double-entry journals: a flexible reading comprehension tool

In traditional mathematical notations, expressions are written using infix notation. For instance, the expression "3 + 4" would be written as "3 + 4". However, in double entry notation, the expression is written as "3 4 +", where the operator ('+') follows its operands ('3' and '4').

a piece of paper with writing on it that says, double entry journal from the text from your mind
a piece of paper with writing on it that says, double entry journal from the text from your mind

The Parse Tree

The parse tree is a critical concept in understanding the double entry style. It represents a hierarchical structure of nodes, where internal nodes are operators, and leaf nodes are operands. In the '3 4 +' expression, '+' would be the root (internal node), and '3' and '4' would be the leaf nodes.

the double entry journal is shown with arrows pointing to different words and phrases on it
the double entry journal is shown with arrows pointing to different words and phrases on it

Douglas Hofstadter and Giorgio Cody, in their paper "Tan: A Better Look at Reverse Polish Notation," demonstrate how parse trees can simplify parenthesis-free expressions, contributing to the appeal of double entry notation.

Operator Precedence and Associativity

Journal, daybook entries launch transactions in accounting cycle
Journal, daybook entries launch transactions in accounting cycle

In double entry, the order of operations is implicitly defined by the order of operands and operators, eliminating the need for explicit rules like BODMAS (Brackets, Orders, Division and Multiplication, Addition and Subtraction).

Moreover, the associativity of operators is inherently handled. For example, '5 2 + 3 *' becomes '(5 + 2) * 3' in infix notation, demonstratingdouble entry's ability to preserve mathematical intent without parentheses.

Improved Code Readability

the different types of calligraphys are shown
the different types of calligraphys are shown

Legacy code often contains expressions with numerous nested parentheses, making it challenging to understand. Double entry notation can simplify such expressions. For instance, '(A + B) * (C - D) + E' can be written as 'A B + C D - * E +'.

This rewrite reduces visual clutter, improving the code's readability and maintainability.

Applications and Limitations

Ultimate Guide to Double Entry
Ultimate Guide to Double Entry

Double entry notation finds applications in computer languages like APL and PostScript. It also simplifies stack-based architectures in programming, where operators are applied to the top values of the stack.

However, double entry notations are not without limitations. Despite its advantages, it may not be suitable for broader adoption due to a lack of immediate intuitive appeal. The learning curve for those unfamiliar with the method can be steep.

21 *Jaw-Dropping* Double Door Entryway Ideas That Will Make Neighbors Stare
21 *Jaw-Dropping* Double Door Entryway Ideas That Will Make Neighbors Stare
several different types of writing on top of each other
several different types of writing on top of each other
an open book with writing on it and the letters written in cursive form
an open book with writing on it and the letters written in cursive form
cursive handwriting worksheet with different types of calligraphy
cursive handwriting worksheet with different types of calligraphy
a notepad with some writing on it next to a pen and a clipboard
a notepad with some writing on it next to a pen and a clipboard
Unga favourite edhu? 🖋️ 3 Ways to write headings - Tamil tips✨ #niruscalligraphy #handwriting
Unga favourite edhu? 🖋️ 3 Ways to write headings - Tamil tips✨ #niruscalligraphy #handwriting
20 Double Door Entryway Ideas That Make an Entrance, Literally
20 Double Door Entryway Ideas That Make an Entrance, Literally
Not mine!!
Not mine!!
a hand holding up a notebook with the words mindset written on it in front of a field of tulips
a hand holding up a notebook with the words mindset written on it in front of a field of tulips
sketchbook entry
sketchbook entry

Learning Double Entry Notation

To learn the double entry style, start by practicing with simple arithmetic expressions. Gradually incorporating parentheses manipulation, predictors, and negators like unary minus. Resources like Hofstadter and Cody's paper and Peter Landin's "The Next 700 Programming Languages" can offer deeper insights.

Websites and communities dedicated to programming languages using double entry notation, like APL and J, can also provide valuable learning experiences.

In conclusion, while the double entry writing style may not be universally adopted, its unique benefits, such as eliminating parentheses and improving legacy code readability, make it a valuable addition to the programmer's toolkit. Embracing this style, despite its learning curve, can expand one's understanding of mathematical expressions and programming concepts.