Overview of Functional Programming for the Visual RPN Calculator
IMPORTANT NOTE: before getting started on programming the calculator, please have a look at the Important Programming Notes section.
The calculator uses a functional programming model to allow the user to program their own functions. Functional programs are almost indistinguishable from ordinary calculations - except for the fact that a functional program contains some Names (variables) in place of numbers. Yet, the functional programming paradigm allows the creation of quite sophisticated functions, as is demonstrated in the Functional Programming Examples section. This level of functionality is made possible by the commands available in the Programming Menu.
Learning to Program the Calculator
To learn to program the calculator, you're going to want to review the following chapters:
- Names, Labels, and Functions - This section explains the basics behind creating functions and linking calculations. This is the simple foundation for all functional programming on the calculator.
- Functional Programming Examples - This section contains progressively more sophisticated examples on how to write functions for the calculator.
- Programming Menu - This section contains help for the calculator functions which are generally oriented towards creating functional programs.
Note that usually when there is an example in the help files there is a list of commands that may be used to run the example on the calculator and there is also a link which can be clicked which will load the example into the calculator so you can run it.
Further Notes
Programming functionality for the calculator is still in work, although core functionality is already in place. If there is a programming oriented command you would really like to see supported on the calculator, contact the app creator at john@linstrum.net and it will get put near the top of the to-do list.
While fairly sophisticated functions may be written on the calculator, it is not really recommended for "heavy duty" programming applications. Rather, programming on the calculator is ideal for replacing repetitive calculations that you might have done on the calculator anyway, or for doing certain calculations that aren't incredibly complex but that require a certain amount of repetition (i.e., the use of recursive calls or sets). That said, if you want to try something really challenging, go ahead, and if it turns out great and you want to share it, send it to the developer and he will make it available as an example for other users.
Why the calculator doesn't have a procedural (imperative) stack based programming language
like HP's RPL
(optional information for HP RPL programming wonks)
A lot of consideration was put into creating a stack based programming language for the calculator (i.e., something like RPL or FORTH). However, there were several reasons why this path wasn't chosen:
- The calculator already had functions, which are simple, useful, and blend well with how the calculator works.
- From the aspect of the developer, RPN is an entry mode used to create mathematical expressions, and it's actually the expressions that return a result. This is a little different than HP RPN, where the RPN is used as commands to manipulate a very simple stack. Since the expressions in Visual RPN Calculator are already fairly sophisticated, it seemed appropriate to extend them rather than create a programming paradigm based on the RPN data entry mode.
- While stack based programming languages are an interesting paradigm, they are fairly horrible from a software engineering perspective. RPL might be a fun challenge, but it's also hard to understand someone else's work, or even your own work a few months after you write a program (similar to low level languages like assembly language). This was going to make it difficult to write examples for new users, and if new users can't readily understand a language they are not going to use it.
- Quite honestly, it seemed like an interesting challenge to try to make a functional programming paradigm work and to see what could be done with it. If you wanted to see an RPL-like language on the calculator mostly because it's fun thinking in a different way, try functional programming - it's different too, only it's better. :)
- This wasn't known when functional programming was implemented in this app, but it turns out the Microsoft has implement a very similar approach for a new Excel feature called Lambdas .
It is not impossible that a stack based programming language could be revisited in the future. If that's something you really, really think should be done, send the developer your arguments for your case and he'll give it some thought (but please, try the way it works now before calling for a replacement).