Hi everyone,
A little while ago I started on a new rur-ple related project. This project is tentatively named "Reeborg's world". While it is not progressing very fast, due to lack of time, I feel I have done enough to share some thoughts on this list and see what people think.
Description
=========
Reeborg's world will be a browser-based program, living on a dedicated website. The lessons/tutorials will be broken up in individual html files. Ideally, each page should contain one (and only one) exercise. The site will contain sub-sites for individual languages (English, French, etc.).
Graphics will either be done using the html canvas or svg graphics (using the Raphël library
http://raphaeljs.com/index.html). I have not started on this yet. My goal would be to have a very nice looking robot world, as I find the "standard" karel the robot clones (viewed using google image search) to be rather boring and less appealing than rur-ple's ... which itself could be improved upon.
This UI might look a little bit like
http://gvr.carduner.net/ui/index.html . However, I intend to include a graphical world builder as well, like I have done in rur-ple. Lines of code that are executed will be highlighted as well (like it is done in rur-ple).
The language will be a subset of Python. Using test driven development (tdd), I have started implementing a very, very simple-minded parser in Python which I then use as a basis to write the corresponding javascript code (also using tdd). I currently have over 600 lines of tests written in each language. Currently, the parser can translate (and a simple runner can mock tests for):
1. Function definitions using "def" in the usual Python way - however, no arguments for functions are allowed (yet?)
2. Assignments/synonyms, e.g.
m = move
m() # same as move()
3. Comments
4. while/break
5. if/elif/else (multiple elif allowed)
6. True/False
7a). on_beeper(), move(), turn_left() - easy to extend.... I only use these three for testing
7b) avance(), tourne_a_gauche() - yes, French translations of basic commands; the idea will be to support multiple human languages (likely limited to ascii characters...)
I intend to further support the following:
8. for count in range(42): where 42 could be any integer. "count" would be a dummy variable, not accessible to the user.
9. try/except and raise with only a few exceptions defined
10. and/or probably with only one per line, as in
if on_beeper() and facing_north():
11. not
12. assert
13. del (to remove robot from the world)
14. OOP notation, as in reeborg.move() and karel = UsedRobot()
15. If I can manage it, simple inheritance using "class"...
16. say("some string") as a useful debugging aid, paralleling the use of "print" but resulting in a "speech bubble" appearing next to the robot.
17. build_wall() to allow reeborg to build an additional wall [e.g. an exercise to close a window might be done using build_wall()]
18. from/import/as which will be limited to one, or perhaps 2 simple modules containing additional instructions (for example: turn_right())
19. global (?)
20. continue (?)
21. pass
22. return (probably only bare return and return None, True or False)
23. in (?)
24. continuation line symbol (?)
25. set_delay(second) - to programmatically set a time delay between each instruction
26. And, of course, all the basic robot instructions and tests found in rur-ple and not mentioned above.
Python keywords I do not plan to implement are: exec, finally, is, lambda, with and yield.
By writing my own (very simple minded) parser, I can do some code analysis and have some meaningful messages about syntax errors - in any human language for which a translation will have been provided. If this is well done, it could be very helpful for beginners (e.g. "This looks like an "if statement" but it is missing a colon ":" at the end). Such syntax errors will also be flagged by highlighting the offending line.
I'm thinking it might be nice to include some other "versions" ... For example, I have read about a Karel the robot clone that could "paint" squares different colors. I'm also thinking it might be nice to plant_tree() (and have nice pictures) rather than put_beeper().
Another interesting site is
http://billmill.org/static/canvastutorial/paddle.html where I linked in a "middle" page on purpose as it shows the inclusion of a "library" tab. This could be done to show a library module that could be "imported" from the user's code.
Should I support docstrings - if only to include them in the "library", illustrating good programming practices? ...
Does anyone have any suggestions? Note that, due to lack of time, it is likely to take me a few months to complete the parser ... and the UI will probably take quite a while too. However, I am committed to complete it and have put aside all my other projects.
I'll leave it at this for now. :-)
André