Omnimaga

Calculator Community => HP Calculators => Topic started by: DJ Omnimaga on January 07, 2014, 07:18:08 pm

Title: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: DJ Omnimaga on January 07, 2014, 07:18:08 pm
I was wondering this for a while, because I think I am one of the only two HP Prime coders to ever have used the STO symbol ▶ in HP PPL programming. Everyone else uses the := syntax, which is closer to computer languages.

However, I was wondering if it was considered a bad practice in HP programming to use the STO symbol to store variables instead of the var := value syntax or if it was considered as fine? To be honest, I prefer the STO syntax because I have used TI-83 Plus BASIC for over 12 years, as well as Axe and to a lesser extent Casio BASIC, which all uses the STO syntax, so I am very used to it. Also, using STO makes it much easier for me to port old TI programs, not to mention the = symbol is much harder to access than STO on the HP Prime keypad.

I was wondering what is everyone thoughts about this?
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: blue_bear_94 on January 07, 2014, 07:50:28 pm
Whichever is slower or bigger is bad practice.
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: Han on January 07, 2014, 09:09:20 pm
I am pretty sure the ▶ symbol was implemented to help the TI folks transition to the HP Prime. The := syntax was implemented (again I am guessing) so that it would be easy to program on a PC and transfer to the calculator. So if you program on the calculator, either is fine. They even use the same keystrokes (if you have alpha locked for the := notation). On a PC, it would be very impractical to use ▶ unless you have a special setup.
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: DJ Omnimaga on January 07, 2014, 09:25:59 pm
They even use the same keystrokes (if you have alpha locked for the := notation).
I am confused, because I can't see := as a whole on the HP Prime keypad (although I can see = selectable in a menu). ???


And I see, I guess that might explain it. I personally don't mind using :=, but I feel more comfortable with STO except when using the Connectivity Kit.
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: Han on January 07, 2014, 09:33:11 pm
I mean number of keystrokes. [Shift][EEX] vs [-][.] if you already have alpha-lower-case-shift locked (press [Alpha][Alpha][Shift][Alpha])
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: DJ Omnimaga on January 07, 2014, 10:01:57 pm
Oh right I see now. It's kinda weird since it shows :. if lowercase isn't on. Thanks ;D
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: TomL_12953 on January 08, 2014, 04:58:11 am
However, I was wondering if it was considered a bad practice in HP programming to use the STO symbol to store variables instead of the var := value syntax or if it was considered as fine?
I was wondering what is everyone thoughts about this?

I use the := since it's closer to other languages and it can be saved to a text file with no special fonts. The STO symbol doesn't always work well in text files. (Neither do the square root symbol, the less than or equal to symbol, etc.)

Tom L
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: MacBernick on January 08, 2014, 12:40:28 pm
I don't know if there is good or bad practice about STO or :=, only the guys who wrote the PPL compiler could answer that I guess. I tend to use := for same reasons as TomL above, because well, it is how it has always worked on computer ^^ I don't know why calculators BASICs always have so weird syntax.
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: DJ Omnimaga on January 08, 2014, 01:39:28 pm
I think the STO command is because older scientific calculators from various companies (such as sharp and Casio) worked with it when storing to one of the available memories, so when TI made graphing calcs, they wanted to keep it similar, same for Casio, but then HP released the Prime so they probably decided to offer both syntax in case.

In my case I am not very used to := since the last time I programmed for the computer was in 2003.

That said, I guess the conclusion is that both are fine as long as they take the same amount of memory and speed to execute, and that just the STO syntax might be slightly harder to read by the HP programmer majority.

Welcome on the forums by the way TomL_12953 :D
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: MacBernick on January 08, 2014, 01:56:09 pm
I know, the last time I programmed using calculator BASIC (excluding RPL, wich was even more cryptic, but for good reasons, and now PPL) was in 94 or so, on the Casio FX8500G (the last of the first gen of graphing calc). This didn't make more sense even then, every computer BASICs already had VAR = xxx syntax for years. My guess is that it was an attempt to make a programming language for non-programmer people, which sounds like a strange idea to me.
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: DJ Omnimaga on January 08, 2014, 02:03:11 pm
Yeah the TI-83 Plus has a third-party RPL language called FastRPL and many people including myself didn't use it because we found it too cryptic and confusing (it seemed like we needed Z80 ASM knowledge in order to use it), but I heard it gave much more freedom to the programmer.

I'm thinking that the calculator languages were often designed so that the user can enter code the same way he enters equations on a scientific calculator, but allow him to execute them in one click, rather than offering a programming language similar to computer ones.

That said, it didn't stop people from getting interested into computer programming by using their experience from calculator programming. :D
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: MacBernick on January 08, 2014, 02:27:54 pm
RPL looks weird when not used to it because it is stack based. Instead of having the traditional function(args) syntax, you push args on the stack, then call the function (not to be mingled with the Z80 stack which is a different thing, I can't remember using any assembly knowledge to do RPL programs but.. maybe). I think It made sense on HP4x series because the whole OS was stack based, thus parsing it is straightforward. Funny thing there's a TI version out there, I'll try it one day.

Anyway, we have choice now to use the syntax we want, this is a good thing :)
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: bb010g on January 08, 2014, 11:40:16 pm
RPL feels reminiscent of lambda calc for me, which is nice. :) One thing I can't wait for on the Prime is RPN programming and the anonymous « PROG » (or now « prog » if you want, thank goodness) that I grew to love on the 28S and the simplicity of programs as evaluated vars. Once you get used to it, or use the « → [var...] » syntax (really like lambda there), it's awesome for development as it is really quick to prototype. (Related: is anyone else getting problems where sin(2π)=-2.0676...e-13? It's annoying. I don't want to have to do a CAS simplify for my trig functions.)

With the  ▶, I treat it like I have on the Nspire; I avoid it and use := because of code readability on long lines. The code's compiled in programs, so it is speed-wise the same either way you choose. I also second Han's comment on keystrokes, if you program in non-shouty mode it's just (-)(.) (which are (:) (=) in lowercase).
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: timwessman on January 16, 2014, 10:51:27 am
There is no difference internally between the two STO commands. They just allow you to do stuff in a slightly different way if preferred. The STO> operator is nice to store into variables during calculations though since very often you don't realize you want to save something till near the end of the line. :-)
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: Eiyeron on January 16, 2014, 03:14:20 pm
I am pretty sure the ▶ symbol was implemented to help the TI folks transition to the HP Prime. The := syntax was implemented (again I am guessing) so that it would be easy to program on a PC and transfer to the calculator. So if you program on the calculator, either is fine. They even use the same keystrokes (if you have alpha locked for the := notation). On a PC, it would be very impractical to use ▶ unless you have a special setup.

Remember folks, te nSpire have too the both syntaxes!
Title: Re: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: DJ Omnimaga on January 16, 2014, 07:36:19 pm
In Basic or Lua? I didn't know O.O
Title: Re: Is 1▶a instead of a := 1 bad practice? (HP Prime)
Post by: bb010g on January 16, 2014, 07:37:47 pm
Should only be Basic; Lua uses plain =.