4 ms·
This supports a very tiny subset of Scratch - basic control flow, variable assignment, and arithmetic operators. It's also an "incorrect" implementation, becaus
by Retr0id 4y ago
This supports a very tiny subset of Scratch - basic control flow, variable assignment, and arithmetic operators. It's also an "incorrect" implementation, because Scratch arithmetic operators are supposed act on double-precision floats.
"Real" Scratch is much harder to compile to a native language, firstly because Scratch has a very weird concurrency model (unofficially documented here [1]), and secondly because it has weird dynamic type conversion rules, much like JavaScript. E.g. the scratch expression (("0x1" join "4") + (2)) would evaluate to 22.
I'm just being pedantic though, this is still a cool project.
[1] "Scratch and its inner workings" https://docs.google.com/document/d/16SFYkk9dWpMhYaZNnLTE_kTmgJF91RjzxWYnEScQe6c/edit https://docs.google.com/document/d/16SFYkk9dWpMhYaZNnLTE_kTm...
- freedomben 4y agoThat document you linked is amazing! I don't know much scratch but my son has gotten deep into it building games, and he's frequently asking me questions about how it works and I'm always forced to speculate. This is fascinating indeed. Thank you!
- fooker 4y agoI have heard scratch described as a 'Domain Specific Language for writing Race Conditions'
- Wowfunhappy 4y agoIt's certainly easy to end up with race conditions in Scratch, but I don't think it's any easier than in something like Javascript?
- candiodari 4y agoThe kernel does not save the state of the math coprocessor when context switching. This means floats are off-limits in the kernel.
- Retr0id 4y agokernel_fpu_begin() / kernel_fpu_end()
- smitty1e 4y agoMy 11yo likes Scratch. This might be a good gateway drug.
- kaladin-jasnah 4y agoIt was mine (not because of this though)! Although in my case I learned "an actual programming language" since my parents discouraged Scratch as an abject waste of time, so I learned Java out of spite. I was hooked onto making video game recreations in Scratch.
- Wowfunhappy 4y agoI'm glad it worked out for you since you learned Java, but hearing stuff like this makes me sad. Scratch needs a "make me feel like an adult" visual setting which darkens the colors or something. I was actually showing Scratch to an adult non-programmer friend last weekend. She was very impressed, saying that if she ever wanted to learn coding, she thought Scratch would be a great tool for her. Programming in Scratch is programming. The only real difference is that instead of typing instructions, Scratch users drag them out from a list of options. I think we would all agree that memorizing syntax isn't a major part of programming, but it's a major source of cognitive load for beginners. Scratch removes that barrier. My company sometimes describes Scratch as "learning to talk before learning to spell." I think that's a great analogy.
- kaladin-jasnah 4y agoTbf, I'm not denying that it is a programming language, but rather that I was discouraged from using it because my parents did not view it as programming.
- Wowfunhappy 4y agoRight, your parents were the ones making that assertion (implicitly if not explicitly).
- sitkack 4y ago
- abbix 4y agoAuthor here - Yes I am somewhat aware of these issues and I am working on a better output with a runtime to do stuff in a less cursed manner. Note that the freestanding subset of it is just a joke and shouldn't be taken seriously. I hope that the hosted one will be more complete and true to Scratch's official implementation.
- a9h74j 4y ago> shouldn't be taken seriously Are you trying to supply material for future Linux Sucks lectures? :) Edit: I see that Lunduke agrees it is awesome. (Outside of DSLs, Scratch impresses me as the one visual language to invest confidence in.)