logoalt Hacker News

Moving Scratch generation to Python on browser

52 pointsby kushaldaslast Friday at 8:29 AM14 commentsview on HN

Comments

njoyablpntingtoday at 3:59 AM

This is super cool! Would love to see how you hooked up Ruff and ty.

Just curious, why not use Pygame?

Scratch abstracts away a ton of stuff to allow the student to focus on logical building blocks that mirror the mental model one might have when writing a real program. I'm wondering if keeping a lot of those abstractions when transitioning to text programming is educationally useful?

For example, it might not be clear that @on_forever is really just a loop, etc. One thing I've noticed when teaching beginners is that when you introduce a library/framework at the same time as a language, they start to form a model of the language that often wrongly includes parts of the library.

This is why I think Pygame is so useful for education, it sits at just the right level of abstraction for learning. In Pygame, your game loop is just a loop, handling input is just conditions in your loop, etc.

Regarding rewriting the AST to avoid async/await, do you have some experience or evidence to suggest that these should be abstracted out? I can see an argument for both sides, so just wondering how exactly you arrived at that decision.

Also, I tried a program with an infinite loop and the UI became unresponsive and I had to close the page. This indicates to me it's running on the main browser thread. Kids (and sometimes senior engineers) write infinite loops occasionally, so I highly recommend executing the user's code in a worker to prevent the harsh experience of losing your work suddenly.

show 1 reply
chuliomartineztoday at 8:04 AM

Look really cool.

Only suggestion, if at all possible avoid special characters like @ and _ . In my experience, kids have a hard time to find them and it get even more complicated for non-english keyboard layouts.

show 1 reply
Noumenon72today at 5:40 AM

One possible consequence of generating Scratch by writing code is that you can ask an LLM to generate your Scratch. I worry that this could take away the fun of Scratch the same way I can no longer maintain any interest in going to Python night, because the computer can do it all.

stefankatoday at 8:41 AM

What about Godot? It’s not Python but it’s a simple written language. It also allows growing by generating more complex games in 3d

show 1 reply
scelerattoday at 10:34 AM

Very helpful comments in much of the example code.

conartist6today at 3:50 AM

I like the direction youre moving. Would a drag and drop editor for Python syntax be useful for a project like this?

hdndnjdtoday at 6:47 AM

Nice idea! However I would like to smooth the transition by also having a Scratch layer with a "peek behind the curtains" button to see the equivalent python code

varun_chtoday at 5:06 AM

See also!

Leopard[0] translates existing Scratch projects JavaScript with a a library for creating games with a really nice API for 'rendering sprites, collision detection, audio, and more'

and on the other side, goboscript[1] is a text based programming language that compiles to Scratch projects. It lets users write Scratch projects with text syntax that you can write in an IDE and version control etc.

maybe both of these could be interesting stepping stones? personally when I 'graduated' from Scratch as a kid I just dumped into writing HTML/CSS/JS websites, which is a very different environment entirely. It actually took a while before I realized where the overlap was with what I learned through Scratch.

[0] https://leopardjs.com/ https://github.com/leopard-js/leopard

[1] https://github.com/aspizu/goboscript

BiteCode_devtoday at 12:03 PM

The music "boss_battle" rocks. Where does it come from?

bgilroy26today at 2:13 AM

I have loved Scratch for many years. This looks cool! Thank you for sharing!

soferiotoday at 2:56 AM

Looks fantastic.