Re: An "Open" letter to "DIY" and "Repurposed" calculator projects Message #7 Posted by Oliver Unter Ecker on 21 Oct 2011, 10:34 a.m., in response to message #6 by David Hayden
Quote:
If I'm missing something, can you explain how this would work?
Certainly.
The only calc I know that implements what I'm referring to is my own, so forgive me for illustrating the point with an ND1 example:
Say ND1 had no "SINH" function, or there would be an error in its implementation.
At run-time, a user can type this code
calculator.functions["SINH"] = function(x) { return (Math.exp(x)-Math.exp(-x))/2; };
in an "Injection" text editor and save it. Subsequently, the calculator will have a system-wide "SINH" function. It will be available in normal RPN operation and in RPL programming, and it will be indistinguishable from a built-in function.
This works because (most) interpreted languages allow you to evaluate code written in their own language. It's as if C could compile C code and dynamically bind to the compiled result.
Sometimes this is used with another language feature called "introspection" that let's you discover what properties are presently associated with an object.
Besides this enabling cool things such as updating your calc (entirely, or partially) by simply re-evaluating some code, it's really simple and elegant to code. No object IDs, method IDs, RTTI stuff as in statically compiled languages.
You can find more info about how this works in ND1 here. The same general idea would work and be supported by pretty much any interpreted language.
If you think interpreted performance sucks, know that modern implementations use JIT compilers and can achieve pretty high speeds. For JavaScript, it's currently a factor ~10x slower than C. The gap is shrinking and one could argue that performance isn't of paramount importance in a calculator.
It's not slow. I'm getting a factor 10x-100x faster RPL performance on ND1 in comparison to a 50g. And ~20x as much speed on top of that for code written in JavaScript, which, as "run-time environment", becomes the rough equivalent of SysRPL.
See the Benchmarks section at the end of this, which also lists a few HPGCC results.
[EDIT: Forgot to mention: ND1 has a "Restore Calculator" button that will fetch key definitions and any injection code from a server and re-create the calculator. This can be used to deliver a full update, fixes, new functionality, new key definitions, new menus. The process takes a second or two.]
Edited: 21 Oct 2011, 10:41 a.m.
|