differences between glowscript and python

72 views
Skip to first unread message

Horst JENS

unread,
Dec 30, 2021, 1:45:24 PM12/30/21
to glowscri...@googlegroups.com
Is there a list/webpage of "things that work in python but will NOT work in glowscript" ?

I found out that the "else" command of a "for" loop does not work and the "super().__init__() command inside a class does not work in Glowscript. 

I understand that glowscript is based on https://github.com/kovidgoyal/rapydscript-ng and does not 100% emulate python syntax, but i wonder if there is a reference page of "things that will not work in glowscript like they work in python" to check before trying to port vpython code into glowscript code. 

--
First name:   Horst     tel:+43-660-52.65.377
Last  name:   JENS      
Email:   horstje...@gmail.com
Web:     http://spielend-programmieren.at

Bruce Sherwood

unread,
Dec 30, 2021, 3:16:28 PM12/30/21
to Glowscript Users
Sorry, but there isn't such a list. The closest there is to such a list is the README at the RapydScript url you cited, though conceivably there may be some additional issues that are specific to Web VPython. One difference I can mention immediately is that In true Python division by zero throws an error, but the JavaScript generated by RapydScript generates the special floating-point value "Inf" (infinity). RapydScript deliberately chooses not to burden all division operations with the overhead of checking for whether the divisor is zero. Here and elsewhere RapydScript tries (and mainly succeeds) to match true Python but at the same time not attempt to be bit-perfect with the sacrifice of performance, especially in the case of edge cases. I once made a timing comparison between RapydScript and another widely-used Python-to-JavaScript transpiler which aimed at bit-perfection, and the RapydScript-generated code ran 50 times faster than the code generated by the other transpiler!

I had never heard of the use of an else clause in a for loop. I was amused when I googled this and the explanation included the statement, "for loops also have an else clause which most of us are unfamiliar with."

Bruce

Reply all
Reply to author
Forward
0 new messages