Post Reply 
HP_PRIME PYTHON SYNTAX: HP_PPY
11-13-2017, 10:08 PM
Post: #21
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
I don't want to create a flame with the following post. Rather I'd like to point out why in my opinion some objections are not that "realistic".

(11-13-2017 07:32 PM)toml_12953 Wrote:  A few people are working on replacement firmware for the Prime (non-HP, of course). I'd gladly give up HPPL, CAS or both for a full Python interpreter.

I cannot follow. If you give up the math environment developed for the prime, couldn't you just get a raspi with python and be all set?

I mean, it is not that you can program extensive python code with the prime keyboard. Therefore on pc you use python, on mac you use python, for mobile solution either android or a raspi + powerbank and python.

Python is quite ubiquitous.

On the other side, exactly to avoid to search, install libraries, verify that they are exactly what I need, etc... I bought the prime for android and windows to have a small but productive math environment. Developing on windows and let it run on silent android systems.

I could have the same math environment with C, php, java, c#, python and what not, but it is more time consuming for the scope of the problems that I'd like to attack (although I may end up learning a lot in the process to configure a non-math language for what I need). It is the same reason some companies provide as "cloud services" ready frameworks that do a lot of work with little setup. For example Watson services from IBM cloud. The service is there, you don't need to think much. Same for the HPPL, it is a math environment.

Also what is important are mostly the algorithms. Porting code (that is not massive) from a procedural language to another is not that difficult. For massive code is something different, but you don't do massive code for a calculator with the idea of having it portable. You use directly another system.

(11-13-2017 09:36 PM)toml_12953 Wrote:  Even if not Python then I'd like some other standardized language that's available across platforms. Languages such as C or Pascal. If there's room in the ROM, HPPL could easily be extended to Pascal. It's so close now.

Aside from the fact that someone could create a translator (as typescript is translated to javascript) or an independent implementation (like newRPL and RPL).

I think that the scope of the calculator is not suitable to C or Pascal.
C or Pascal could be quite complicate to manage, instead on a calculator one does not want to think much about the quirks of the code, rather one wants to think on the problem.

Python with its indentation style would be a nightmare to code on the calculator.

Moreover I don't see why it is bad to have another programming language (given that it is robust). You don't go and complain that Matlab or mathematica have their own languages instead of C or Pascal.

Neither you go saying "why people developed python if Pascal was already available!? Damn them."

Last but not least. the languages that you find fitting, say python or Pascal, may not fit another user that may prefer HPPL. The problem is why the second user should adapt to Pascal? is it that more legit than you adapting to HPPL?

Again it is not a critic, it is more like "wanting the world fitting our eyes is all nice, but reality is made of compromises". I'd love too to have HPPL working on different platforms.

The nice side is that HPPL works on different platforms (aside from linux for the moment), therefore I bought it! Sure it is not as ubiquitous as C, but neither C is that much ubiquitous if someone does not provide a compiler for the given target platform.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
11-14-2017, 02:21 AM (This post was last modified: 11-14-2017 02:32 AM by toml_12953.)
Post: #22
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-13-2017 10:08 PM)pier4r Wrote:  I don't want to create a flame with the following post. Rather I'd like to point out why in my opinion some objections are not that "realistic".

[quote='toml_12953' pid='83224' dateline='1510601543']

A few people are working on replacement firmware for the Prime (non-HP, of course). I'd gladly give up HPPL, CAS or both for a full Python interpreter.
(11-13-2017 10:08 PM)pier4r Wrote:  I cannot follow. If you give up the math environment developed for the prime, couldn't you just get a raspi with python and be all set?
It wouldn't have the great form factor or portability of the Prime

(11-13-2017 10:08 PM)pier4r Wrote:  I mean, it is not that you can program extensive python code with the prime keyboard.
Why not? All the ASCII characters are available. I don't mind choosing them from a table.

(11-13-2017 10:08 PM)pier4r Wrote:  For massive code is something different, but you don't do massive code for a calculator with the idea of having it portable. You use directly another system.

I do.

(11-13-2017 09:36 PM)toml_12953 Wrote:  Even if not Python then I'd like some other standardized language that's available across platforms. Languages such as C or Pascal. If there's room in the ROM, HPPL could easily be extended to Pascal. It's so close now.

(11-13-2017 10:08 PM)pier4r Wrote:  I think that the scope of the calculator is not suitable to C or Pascal.
C or Pascal could be quite complicate to manage, instead on a calculator one does not want to think much about the quirks of the code, rather one wants to think on the problem.

C, Pascal and BASIC (modern versions) allow me to concentrate on the problem without thinking about quirks of the code.

(11-13-2017 10:08 PM)pier4r Wrote:  Python with its indentation style would be a nightmare to code on the calculator.

Why?

(11-13-2017 10:08 PM)pier4r Wrote:  You don't go and complain that Matlab or mathematica have their own languages instead of C or Pascal.

I do.

(11-13-2017 10:08 PM)pier4r Wrote:  Last but not least. the languages that you find fitting, say python or Pascal, may not fit another user that may prefer HPPL. The problem is why the second user should adapt to Pascal? is it that more legit than you adapting to HPPL?

I can program in HPPL with no problem but then I'm limited to the Prime or a Prime emulator on the PC or smartphone. I'd like a language that runs natively on each platform. If you know of a native Windows, Linux, Android or iOS version of HPPL that doesn't require an emulator, please let me know!

The TI Nspire has a great piece of third-party software called Ndless. That software allows machine language programs to be run. One of the programs currently available is Python! Ndless doesn't require a complete replacement of the OS, it just allows the user to access the calculator on the lowest level. Unfortunately (for me anyway), the entire layout of the TI OS is bizarre with documents for everything rather than a programming language that can be run standalone. The TI model just doesn't work for me and many programming statements have been omitted from their language (INPUT is extremely limited, there's no way to read the keyboard while a program is executing, there are no graphics statements). The Prime works much more compatibly with the way I think. I'm much more comfortable with it. If a program like Ndless could be developed for the Prime, that would be ideal for me.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
11-14-2017, 07:03 AM
Post: #23
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
For what I know , ndless has python but a shrinked version of it. Is my knowledge wrong?

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
11-14-2017, 12:51 PM
Post: #24
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-14-2017 07:03 AM)pier4r Wrote:  For what I know , ndless has python but a shrinked version of it. Is my knowledge wrong?

It is MicroPython but it is only slightly modified from standard. It's a huge subset with mostly obscure features missing. If you write a program in MicroPython, it will run in full Python so your programs are portable.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
11-15-2017, 12:37 PM
Post: #25
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-15-2017 11:50 AM)compsystems Wrote:  > The TI model just doesn't work for me and many programming statements have been omitted from their language (INPUT is extremely limited, there's no way to read the keyboard while a program is executing, there are no graphics statements).

>> Someone who thinks like me, the INPUT/OUTPUT command of the tinspire is very limited, the developers have not yet included the dialog boxes of the super TI68K calcs (ti89 / tiv200) although in the latest version, if they included getkey() cmd, waiting for DROPDOWN, Dialog EndDlog, Toolbar EndTBar, Popup cmds

OK! I'll have to get the latest OS and try it out. I still have a great deal of trouble working with everything having to be in a document, though. Thanks for the heads-up!

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
11-15-2017, 04:08 PM
Post: #26
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-14-2017 12:51 PM)toml_12953 Wrote:  It is MicroPython but it is only slightly modified from standard. It's a huge subset with mostly obscure features missing. If you write a program in MicroPython, it will run in full Python so your programs are portable.

It doesn't have any of the standard libraries though. That basically means you end up rewriting or needing adjust things to get it working.

Which is why I ask: Would you accept no having C bindings? Would you give up any possibility to interact with the HP math routines and all CAS functions as part of that trade?

Is what really is being asked here "give me syntax compatability" or "give me full compliant python i can bring in any program I find and use". They are really big things.

Something like microPy is in the realm of possibility (with some direct blocking of hardware direct things we can't expose). What needs good definition is the interaction points between the calculator side of things...

1. Which objects can be exchanged and how to exchange them
2. How to directly interact with screen/keyboard.
3. How to interact with memory/storage.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
11-15-2017, 04:31 PM
Post: #27
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-15-2017 04:08 PM)Tim Wessman Wrote:  
(11-14-2017 12:51 PM)toml_12953 Wrote:  It is MicroPython but it is only slightly modified from standard. It's a huge subset with mostly obscure features missing. If you write a program in MicroPython, it will run in full Python so your programs are portable.

It doesn't have any of the standard libraries though. That basically means you end up rewriting or needing adjust things to get it working.

It has some libraries including but not limited to array, cmath, math, sys, ucollections, uos, and utime :
MicroPython Libraries

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
11-15-2017, 05:30 PM
Post: #28
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
I agree with the direction hp is taking with parisse's python-like language.

My main reason is simple : I would prefer hp team to focus on improvements, new apps or features that would benefit to much instead of spending lot of time to implement microPython for less ones (and probably with less calculator object interaction).

Question of priority to my point of view. until recently I saw more feature requests than python implementation request.

primer
Find all posts by this user
Quote this message in a reply
11-15-2017, 06:05 PM
Post: #29
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
It would be interesing to know what people really did with the micropython implementation on the tinspire. This implementation has some modules (unlike the Numworks implementation), but not standard libraries like scipy/numpy or plotting libraries. I'm not sure teachers realize that in France where the question arises with the programming curriculum changes this year in highschools.
Find all posts by this user
Quote this message in a reply
11-16-2017, 07:01 AM
Post: #30
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-15-2017 05:30 PM)primer Wrote:  I agree with the direction hp is taking with parisse's python-like language.

My main reason is simple : I would prefer hp team to focus on improvements, new apps or features that would benefit to much instead of spending lot of time to implement microPython for less ones (and probably with less calculator object interaction)
I agree with this view.

It is a matter of utility. How many would program in Python vs how many would use or use already hppl.

Since the effort on hppl is already big, now keep going.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
09-09-2018, 07:53 PM
Post: #31
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-15-2017 04:08 PM)Tim Wessman Wrote:  
(11-14-2017 12:51 PM)toml_12953 Wrote:  It is MicroPython but it is only slightly modified from standard. It's a huge subset with mostly obscure features missing. If you write a program in MicroPython, it will run in full Python so your programs are portable.

It doesn't have any of the standard libraries though. That basically means you end up rewriting or needing adjust things to get it working.

Which is why I ask: Would you accept no having C bindings? Would you give up any possibility to interact with the HP math routines and all CAS functions as part of that trade?

Is what really is being asked here "give me syntax compatability" or "give me full compliant python i can bring in any program I find and use". They are really big things.

Something like microPy is in the realm of possibility (with some direct blocking of hardware direct things we can't expose). What needs good definition is the interaction points between the calculator side of things...

1. Which objects can be exchanged and how to exchange them
2. How to directly interact with screen/keyboard.
3. How to interact with memory/storage.

I wld lov c anig inan pnaalble
Find all posts by this user
Quote this message in a reply
09-10-2018, 01:20 AM
Post: #32
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(09-09-2018 07:53 PM)CyberAngel Wrote:  
(11-15-2017 04:08 PM)Tim Wessman Wrote:  It doesn't have any of the standard libraries though. That basically means you end up rewriting or needing adjust things to get it working.

Which is why I ask: Would you accept no having C bindings? Would you give up any possibility to interact with the HP math routines and all CAS functions as part of that trade?

Is what really is being asked here "give me syntax compatability" or "give me full compliant python i can bring in any program I find and use". They are really big things.

Something like microPy is in the realm of possibility (with some direct blocking of hardware direct things we can't expose). What needs good definition is the interaction points between the calculator side of things...

1. Which objects can be exchanged and how to exchange them
2. How to directly interact with screen/keyboard.
3. How to interact with memory/storage.

I wld lov c anig inan pnaalble

Can anyone decipher this for me?

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
09-10-2018, 01:52 AM
Post: #33
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
Personally, I'd just like to see the Prime get closer to "real" Pascal: record and maybe even object types, differentiate between "procedure" and "function" (so you can declare a void function), include a character-cell terminal system like Turbo Pascal's CRT unit, etc.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-10-2018, 04:19 PM
Post: #34
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(09-10-2018 01:20 AM)toml_12953 Wrote:  
(09-09-2018 07:53 PM)CyberAngel Wrote:  I wld lov c anig inan pnaalble

Can anyone decipher this for me?

I would love C in any possible...form?
Someone had a broken phone word prediction autocorrupting everything.
Find all posts by this user
Quote this message in a reply
08-29-2020, 04:46 PM (This post was last modified: 08-29-2020 05:02 PM by toml_12953.)
Post: #35
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-13-2017 12:19 PM)compsystems Wrote:  
PHP Code:
#cas
def fra(X,Y,Nmax):
  
local x,y,z,c,j
  
for x in range(X):
    for 
y in range(Y):
      
0
      c 
2.7*x/X-2.1+i*(-1.87*y/Y+.935)
      for 
j in range(Nmax):
        if 
abs(z=z*z+c)>2:
          break
      
PIXON_P(x,y,255*20*j+256)
  
FREEZE
  WAIT
(0)
#end 

What is the equivalent code in Xcas language?

I've tried this program on the Prime simulator and it checks OK in the editor but I get "Ifte: Unable to check test Error: Bad Argument Value" when I try to run it. Does this really run on Prime?

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
08-29-2020, 10:00 PM
Post: #36
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
Change this line:
Code:

if abs(z=z*z+c)>2:

Into this:
Code:

z=z*z+c
if abs(z)>2:

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
08-29-2020, 10:08 PM
Post: #37
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
And it works well!
   

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
08-30-2020, 02:48 AM
Post: #38
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(08-29-2020 10:00 PM)pinkman Wrote:  Change this line:
Code:

if abs(z=z*z+c)>2:

Into this:
Code:

z=z*z+c
if abs(z)>2:

Thanks! It does work now. I wonder how it worked in the YouTube video since I copied it directly from there.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
08-30-2020, 02:56 AM
Post: #39
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
I see the print() function doesn't work the same in CAS as in Python

PHP Code:
print(4,5

should print

PHP Code:
4 5 

Instead it prints

PHP Code:
4,

However

PHP Code:
print(4,5,sep=''

does work the same as in python. It prints

PHP Code:
45 

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
08-30-2020, 09:09 AM
Post: #40
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(08-30-2020 02:48 AM)toml_12953 Wrote:  Thanks! It does work now. I wonder how it worked in the YouTube video since I copied it directly from there.

The reason is that the Python syntax converter was improved, instead of translating = (Python) to := (Xcas) everywhere, it take cares of the context.
I think := is now valid under Python, you can therefore write
Code:

if abs(z:=z*z+c)>2:
This code will run a little bit faster than
Code:

z:=z*z+c
if abs(z)>2:
and that's why I wrote it like that.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)