"Python" in GlowScript 1.1

56 views
Skip to first unread message

Bruce Sherwood

unread,
Oct 25, 2014, 6:45:43 PM10/25/14
to rapyd...@googlegroups.com
Announcing GlowScript 1.1

GlowScript programs can now be written in RapydScript, a Python look-alike, as well as in JavaScript or CoffeeScript. You can see examples of RapydScript programs among the Example programs available at glowscript.org.

There are various projects aimed at making it possible to use Python in a browser by compiling Python to JavaScript, the language that is built into browsers. However, attempts to represent Python exactly generate very inefficient JavaScript that runs too slowly for many purposes. For typical GlowScript programs there is no difference between Python and RapydScript; the differences are often rather arcane. For example, in Python division by zero gives an error, whereas in RapydScript division by zero generates NaN ("not a number"). Full details are found at


There are however differences between VPython and GlowScript even when using RapydScript. For example, objects do not have length, height, or width attributes; these must be specified by the size attribute. At the bottom of the first page of the GlowScript Help is a link to a comparison of VPython and GlowScript. It is intended to provide a Python program to convert to the extent possible a VPython program to GlowScript.

Much help in integrating RapydScript into GlowScript was provided by Alexander Tsepkov, Charles Law, and Salvatore di Dio.

GlowScript 1.1 also benefits from work by Adam Thompson to be able to put jquery and jquery-ui under version control, and to make it possible to place the print area to the right of the canvas.

At the moment the Share option to export the final generated JavaScript code to your own web site is not working; to be fixed.

Bruce Sherwood

unread,
Oct 25, 2014, 6:46:37 PM10/25/14
to rapyd...@googlegroups.com
I posted this announcement in a variety of places. Thanks much, Alexander, Charles, and Salvatore!

Charles Law

unread,
Oct 25, 2014, 6:51:28 PM10/25/14
to rapyd...@googlegroups.com
Awesome!  Glad I could help.

I peeked at some of the examples, and it's cool to see all JavaScript, RapydScript, and CoffeeScript side by side.

Bruce Sherwood

unread,
Oct 25, 2014, 7:06:51 PM10/25/14
to Charles Law, RapydScript
And the best examples are in RapydScript.....

I intend to rewrite many of those examples to be in RapydScript. 

The GlowScript documentation used to be couched in terms of JavaScript, leaving it to CoffeeScript users to make mental conversions, something that is mostly okay because to use CoffeeScript you basically have to already know JavaScript well. But with GlowScript 1.1 the documentation is focused on RapydScript, with sort of footnotes about the other two languages.

Alexander Tsepkov

unread,
Oct 25, 2014, 7:57:45 PM10/25/14
to Bruce Sherwood, Charles Law, RapydScript
Glad to see that RapydScript is helping with the demos. Looked at the source code and it definitely looks cleaner than JavaScript. A couple things I noticed that I figured I'd comment on in case you weren't already aware:

- while not-Pythonic, range(0,N) can be replaced with [0 til N] syntax (or [0 to N-1]), which is unique to RapydScript. You may choose to ignore it, I introduced it because I kept getting confused by range's final bound (inclusive vs exclusive)
- sometimes I see you returning an array as 'return [hour, minute]'. Like Python, RapydScript automatically handles tuple packing/unpacking upon return/assignment. So you can use 'return hour, minute' syntax.

Bruce Sherwood

unread,
Oct 26, 2014, 12:17:16 AM10/26/14
to Alexander Tsepkov, Charles Law, RapydScript
Good points. I personally don't have a problem with the range issue, having gotten used to non-exclusive range in Python, but I'll probably change the unpacking usage.

I particularly like not having to distinguish between range and arange.

Bruce Sherwood

unread,
Oct 26, 2014, 12:41:56 PM10/26/14
to rapyd...@googlegroups.com, atse...@gmail.com, charl...@gmail.com
The "share" option is fixed.
Message has been deleted

Salvatore Di Dio

unread,
Oct 28, 2014, 4:42:14 AM10/28/14
to rapyd...@googlegroups.com
Very happy for you and the RapydScript community/
Congratulations Bruce



Le dimanche 26 octobre 2014 00:46:37 UTC+2, Bruce Sherwood a écrit :
Reply all
Reply to author
Forward
0 new messages