What would be the ultimate calculator in 2017?

General discussion about calculators, SwissMicros or otherwise
Post Reply
User avatar
dm319
Posts: 144
Joined: Thu Aug 03, 2017 12:21 pm
Location: Birmingham, UK

What would be the ultimate calculator in 2017?

Post by dm319 »

This is continuing an interesting off-topic conversation from this thread.

So this is my reasoning:

Hp perfected the the pocket calculator in 1988, providing a machine which:
  • had excellent ergonomics for calculating using built-in functions
  • was well made
  • had great key feel
but it was also a time when electronics and storage were expensive, personal computers were not common place, and there was no such thing as python - so
  • it was awful to program
Maybe I should justify that last remark. Have a look at any of the programs from Thomas's page, and compare it to the beautifully clear style of a modern programming language.

It's not only hard to read, but it seems to lack looping (which seems to be achieved by GOTOs), functions, generic if/else statements, scoping etc. And that's before we get onto advanced functionality, like optimised sort algorithms (heap sorts etc), slices, maps (and hash-table look ups), methods etc...

I'm imagining a pocket calculator which has all the instant-on and practical functionality of the HP42s/DM42, but which also runs command-line programs in python/go/R/julia/etc/etc. I don't think the calculator needs to be capable of being able to write the programs, but maybe viewing it would be possible. I'm not even saying it needs a different screen/resolution etc.. the command line can adapt to a limited character width and height if necessary. With modern connectivity - cables or wifi, it should be just a matter of dragging and dropping programs written in your favourite desktop editor onto the device. Or even neater, have it sync to your github repo automatically.

Just to continue the conversation from the previous thread:
Vitasam wrote:
Mon Aug 07, 2017 12:22 pm
Hi, I think I got your point. Just to clarify - what is a model of programming you do prefer: a) using a PC as cross-compiling tool and just run ready-made binaries on DM42 or b) programming completely 'on board' of a DM42?

Just thinking - a good compromise for option b) is a Forth language.
I guess neither! Using a calculator keyboard to program on is a bit sadistic to me :) Maybe the option would be nice if you were desperate to write out a program on-the-go and didn't have access to a keyboard. If it had a linux distro, nano/vim could easily be included, and a bluetooth keyboard would make it a lot less painful. But I envisage your desktop/laptop machine being the main place to write a program. Python and R at least are dynamic, so the code would run just fine on its own. Go would also run fine, but can also be compiled - which would probably have to happen on the device.

I'm not familiar with forth personally - but looking through the wikipedia page it looks intriguing! With an ARM processor and a linux distro, pretty much any language is doable. I can see that it functions in a similar way to the stack/RPN, which is nice, though the programming language wouldn't have to operate within the environment of the calculator.
H2X wrote:
Mon Aug 07, 2017 1:27 pm
Some kind of embedded Linux platform came to my mind as well, but that would require more hardware resources than the current DM42, yes?

What about power supply? Battery change or charging should not have to happen too often. What about screen? Surely such a platform could support larger screens than the DM42, but how large?

I get the idea, I'm just not able to imagine the kind of device. Yet.
Yes, maybe more hardware resources would be required - nothing that couldn't run on a raspberry pi 1, but would draw more power I'm sure. Power supply would likely need to be more substantial than button cell batteries, and would be unlikely to last for months without recharging. I don't think the screen would have to be too different, as long as when you write the programs you bear in mind the screen limitations. For example taking variables in on a single line, and not printing out hundreds of lines of output!

In my imagination the device would look, feel and function the same as a HP42s/DM42. But it could run programs created using modern languages, i.e. press [assignable program button 1], and it'll run, say, 'python3 mort.py', or 'go run amlprog.go'. These programs could either ask for input, or take what's already on x/y/etc registers and use those. Given cheapness of storage, you could store loads of programs, which could be accessed using a menu, or re-assigned to another hot key.

Anyway, this is just a little dream I have for the ultimate calculator! I love the HP42s, but I think its programming ability was limited by what was doable back in 1988. I would use it around work with a slew of medical programs/calculators...
SN:09075
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: What would be the ultimate calculator in 2017?

Post by grsbanks »

The HP Prime probably isn't too far from what you're thinking of.

It can be programmed in a fairly clear language called HP-PPL that can be entered directly on the machine or via a computer and it's pretty fast (400MHz CPU).

The only real downer about the HP Prime is the fact that its RPN implementation is pretty poor. The machine is geared more towards algebraic operation.
There are only 10 kinds of people in the world: those who understand binary and those who do not.
Vitasam

Re: What would be the ultimate calculator in 2017?

Post by Vitasam »

dm319 wrote:
Mon Aug 07, 2017 5:13 pm
In my imagination the device would look, feel and function the same as a HP42s/DM42. But it could run programs created using modern languages, i.e. press [assignable program button 1], and it'll run, say, 'python3 mort.py', or 'go run amlprog.go'.
grsbanks wrote:
Mon Aug 07, 2017 5:42 pm
The HP Prime probably isn't too far from what you're thinking of.
I was also just to say about HP Prime. Quite close to the subject, right?

But let me share few cents of my feelings and wishes about my dream-calculator. What is very attractive to me:
  • An ability to get rid of a PC but still able to (i) create and (ii) perform complex computational routines with high accuracy.
  • Pocket and low-power form-factor which is capable of running without needs of charger for many days.
One can think about 1st bullet-point as a sort of 'steampunk'. And yes, it is a kind of steampunk for me - I feel really good when I do have such device :)

But programming 'on board' of 1st bullet-point device could be painful, if you end-up with long lines of modern programming languages, where you have to type A LOT of letters. Frankly speaking why do I need something else, that e.g. QPython for my Android device? It goes for free, modern language, running the same code on a PC and a mobile device etc.

I have been a user of MK-161 - Russian successor of Soviet programmable micro-calculators B3-34, MK-52, MK-61. I hope that Google translator will https://translate.google.com/translate? ... edit-text= work here.
MK-161 has almost the same programming language as Soviet ones, and it was extremely difficult to program 'on a board' without labels - if you change one command, you should update all addresses among the program. In order to simplify user life manufacturer has developed bunch of PC tools, e.g. ASM-like compiler with labels and macros, communication utility etc. Needless to say that with such programming paradigm the MK-161 becomes a kind of portable controller rather than the programmable calculator.

So, having RPN keystroke programming language with labels like in HP42s/DM42 at the moment looks the best for my needs. Design of DM42 also looks very attractive for my eyes.

To summarize: DM42 is very close to be my ideal calculator but few things are still floating in my wish-list:
- Graphics primitives RPN commands (keystrokes) with an access to a whole 400x240 screen.
- New type of binary-to-RPN API, where one can use STM32 Asm or C cross-compiler on a PC to build a binary which user can put to the file system and run directly from RPN program, as native ARM-executables.
- LED backlight?
H2X
Posts: 885
Joined: Tue Apr 25, 2017 8:00 am
Location: Norðvegr
Contact:

Re: What would be the ultimate calculator in 2017?

Post by H2X »

dm319 wrote:
Mon Aug 07, 2017 5:13 pm
But I envisage your desktop/laptop machine being the main place to write a program.
I agree, for programs written in some programming language. These might be compiled to some executable format before being transferred to the calculator, and the source code could be embedded with it - i.e. the calculator need not support more than one particular format, which need not be human readable. It needn't even be able to compile source code itself. Adding language support would be a rather trivial matter of implementing compilers.

Keystroke programming make (more?) sense on the calculator. For lack of a better term, these might be called macros, just to distinguish them from programs written in a programming language.

Apps might also be considered, especially if networking is available, allowing services to be called for computational assistance. But when does the ultimate calculator stop being a calculator, and transform into something else (which probably already exists)?
What is the metric tensor in imperial units?
User avatar
dm319
Posts: 144
Joined: Thu Aug 03, 2017 12:21 pm
Location: Birmingham, UK

Re: What would be the ultimate calculator in 2017?

Post by dm319 »

Great discussion here - there's a lot for me to look up!
grsbanks wrote:
Mon Aug 07, 2017 5:42 pm
The HP Prime probably isn't too far from what you're thinking of.
I'm going to have to look at this machine, clearly. It's shame if the RPN isn't nicely implemented - though, really, how can one get that wrong? (dare I ask?)
Vitasam wrote:
Mon Aug 07, 2017 8:34 pm
the MK-161 becomes a kind of portable controller rather than the programmable calculator.
Yes, fair point. I also like the idea of a unit being able to function independently - so yes, my dream calculator would still be programmable by hand. In fact, I think given the limitations of the form-factor, the HP42s implementation was very good. I like the program labels and soft keys, and a well-place execute button. My only real complaint is the actual language.
Vitasam wrote:
Mon Aug 07, 2017 8:34 pm
New type of binary-to-RPN API, where one can use STM32 Asm or C cross-compiler on a PC to build a binary which user can put to the file system and run directly from RPN program, as native ARM-executables.
I have a feeling Go will do that quite nicely. It's fairly similar to C, and building an executable is just 'go build main.go' - it takes in all the packages and put's it into a nice executable. Not sure how you would get it to be an ARM-executable, but it must be possible! Actually, it's probably not going to be native is it?
H2X wrote:
Mon Aug 07, 2017 10:55 pm
For lack of a better term, these might be called macros, just to distinguish them from programs written in a programming language.

Apps might also be considered, especially if networking is available, allowing services to be called for computational assistance. But when does the ultimate calculator stop being a calculator, and transform into something else (which probably already exists)?
Yes those are good points. I suppose ideally there would be a simple calculator language that you can program yourself, and also proper programs for some algorithms you'd like to run. I think a calculator is something that is adept at computing simple calculations. The reason I take that definition is that they have to be good for the mentally lazy. Instant on, ready to work out how many minutes between now and the morning (as I had to do this evening putting my kids to bed). If it's good at doing that, I'll call it a calculator!

Here's something some of you might be interested in:

Project Euler is a website with some easier and some fiendishly tricky puzzles. They all require at least an element of maths and programming to solve. I'll be impressed if anyone can use their HP calculator to solve any!
SN:09075
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: What would be the ultimate calculator in 2017?

Post by grsbanks »

dm319 wrote:
Tue Aug 08, 2017 12:04 am
grsbanks wrote:
Mon Aug 07, 2017 5:42 pm
The HP Prime probably isn't too far from what you're thinking of.
I'm going to have to look at this machine, clearly. It's shame if the RPN isn't nicely implemented - though, really, how can one get that wrong? (dare I ask?)
You used to be able to download a simulator of the HP Prime so that you could "try before you buy". It also works with the connectivity kit, allowing you to test stuff that you write before transferring it to the physical calculator.
dm319 wrote:
Tue Aug 08, 2017 12:04 am
Project Euler is a website with some easier and some fiendishly tricky puzzles. They all require at least an element of maths and programming to solve. I'll be impressed if anyone can use their HP calculator to solve any!
Bookmarked!

Some of the problems are simple enough to crack with an HP-11C but I'll look at them using a DM42 to keep it on-topic :)
There are only 10 kinds of people in the world: those who understand binary and those who do not.
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: What would be the ultimate calculator in 2017?

Post by grsbanks »

dm319 wrote:
Tue Aug 08, 2017 12:04 am
Project Euler is a website with some easier and some fiendishly tricky puzzles. They all require at least an element of maths and programming to solve. I'll be impressed if anyone can use their HP calculator to solve any!
I took a trivial problem from the list: what is the sum of the natural numbers below 1000 that are multiples of 3 or multiples of 5?

DM42 solution:

Code: Select all

00 { 64-Byte Prgm }
01▸LBL "MUL35"
02 CLX
03 STO 00
04 999.002
05 STO 01
06▸LBL 00
07 RCL 01
08 IP
09 STO ST Y
10 STO ST Z
11 3
12 MOD
13 X=0?
14 GTO 01
15 R↓
16 5
17 MOD
18 X=0?
19 GTO 01
20▸LBL 02
21 DSE 01
22 GTO 00
23 "TOTAL: "
24 RCL 00
25 AIP
26 AVIEW
27 RTN
28▸LBL 01
29 X<>Y
30 STO+ 00
31 GTO 02
This runs in about 2 seconds on battery power.

Just so you could have a look at what HP-PPL looks like, I did it on the HP Prime as well:

Code: Select all

EXPORT Mul35()
BEGIN
LOCAL n, t;
  t := 0;
  FOR n FROM 3 TO 999 DO
    if n mod 3 = 0 OR n mod 5 = 0 THEN
      t := t + n;
    END;
  END;
  RETURN t;
END;
It's instantaneous on the Prime...

Also, if memory serves, the first time a Prime runs a program, it compiles it. Second and subsequent runs are much quicker because the program is already compiled. Obviously, if the program is altered bewteen runs, the compiled version is discarded and the program has to be re-compiled.
There are only 10 kinds of people in the world: those who understand binary and those who do not.
User avatar
dm319
Posts: 144
Joined: Thu Aug 03, 2017 12:21 pm
Location: Birmingham, UK

Re: What would be the ultimate calculator in 2017?

Post by dm319 »

grsbanks wrote:
Tue Aug 08, 2017 10:40 am
I took a trivial problem from the list: what is the sum of the natural numbers below 1000 that are multiples of 3 or multiples of 5?
Really enjoyed looking through that, and putting it into free42s. I must admit I had to do a lot of ctrl-f through the alternative HP-42s manual! It brings back my school days programming the BBC micro - I find it so strangely serial/linear. I almost get claustrophobic reading through that code - I imagine a pipe with numbers being moved around like sokoban. The GTOs are clever - you must have to plan how the code fits together - I can't imagine how you start thinking like that. Though I can also see how it can become spaghetti. Can you explain why you did 999.02, then the integer? And also how DSE works? I guess it decrements the value stored in that register, but then does it skip when it hits zero?

Your HP Prime code looks, in contrast, clear and understandable!

You should definitely post the HP42s code to the problem 1 thread. Esoteric languages get a lot of curiosity on that site! (PS project euler doesn't like people posting code solutions to other forums in case other people chance upon it. Since this is so trivial and this forum is so obscure I'm sure it's not an issue!) So here is a Go solution (260ms compile and run, 0.001s pre-compiled, on an laptop i7 - I feel sorry asking it to do such a lowly task...):

Code: Select all

package main

import ("fmt")

func check(a int) bool {
	return 0 == a%3*a%5
}

func main() {
	var s int

	for i := 1; i < 1000; i++ {
		if check(i) {
			s += i
		}
	}

	fmt.Printf("sum: %d\n", s)
}
And an R solution. NB R can do the same loop as in the Go and your prime solution, but it's not what it's designed for, which is working on arrays. 0.178s.

Code: Select all

x        <- data.frame(i = 1:999)
x$three  <- x$i%%3 == 0
x$five   <- x$i%%5 == 0
x$both   <- x$three | x$five
sum(x[x$both,"i"])
It's been a while since I've been on project euler. The pentatagonal numbers problem is quite a fun one - if you do it, post it to their problem thread and I'll look it up. I loved reading through everyone's solution to that puzzle. I'll be pretty impressed if you can do it on the HP42s. The last one I tried was a hexagon puzzle (I think released this year), and that stumped me. I got some nice working code, but it wasn't anywhere near efficient enough to compute it in a reasonable time frame. Tempted to upload it to our high-performance cluster and let it run there for a few days :)
SN:09075
User avatar
pauli
Posts: 252
Joined: Tue May 02, 2017 10:11 am
Location: Australia

Re: What would be the ultimate calculator in 2017?

Post by pauli »

Problem #2 from project Euler (sum of even Fibonacci numbers under 4,000,000) for the WP 34S:

Code: Select all

01:  # 001
02:  # 000
03:  # 004
04:  SDL 006
05:  RCL Z
06:  FIB
07:  x>? Y
08:    SKIP 005
09:  EVEN?
10:    STO+ Z
11:  DROP
12:  INC Z
13:  BACK 008
14:  RCL Z
Not bad for fourteen instructions :)

Agreed, it isn't the greatest code, but it is straightforward.

Pauli
dlachieze
Posts: 613
Joined: Thu May 04, 2017 12:20 pm
Location: France

Re: What would be the ultimate calculator in 2017?

Post by dlachieze »

grsbanks wrote:
Tue Aug 08, 2017 10:40 am
dm319 wrote:
Tue Aug 08, 2017 12:04 am
Project Euler is a website with some easier and some fiendishly tricky puzzles. They all require at least an element of maths and programming to solve. I'll be impressed if anyone can use their HP calculator to solve any!
I took a trivial problem from the list: what is the sum of the natural numbers below 1000 that are multiples of 3 or multiples of 5?
A one-liner version for the Prime:

Code: Select all

ΣLIST(MAKELIST(N*NOT((N MOD 3)*(N MOD 5)),N,3,999))
DM42: 00425 - DM41X: β00066 - WP43: 00042
Post Reply