# \[WSS19\] Wolfram Language using Scratch Blocks

**URL:** <https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364>\
**Category:** Staff Picks\
**Tags:** education, external-interfaces, interface-construction, ui-ux-and-ide, staff-pick, wolfram-summer-research-institute, wolfram-engine\
**Created:** [July 10, 2019, 4:41pm UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364 "2019-07-10T16:41:40Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![x](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/x/32/3399_2.png) [@x](https://community.wolfram.com/u/x)\
**Post date:** [July 10, 2019, 4:41pm UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/1 "2019-07-10T16:41:40Z")

</div>

![ScreenShot2019-07-09at7.03.34PM.png](https://global.discourse-cdn.com/wolfram/original/2X/0/027bc6f9eabaa64e55fd04c8abd843e12ce07e16.png)

* * *

## Introduction

Scratch is an Open Source Project that has as the main objective to teach children about programming from a very early age, its design paradigm comes from the idea of kids playing with Lego blocks, in the same way, that a specific LEGO® set may come with its instructions to let the children build its own toy, the kid can then disassemble and turn everything into something else. This is translated into this platform as having tutorials that help the kids realize what every code block does, so they can build something more complicated by their own.

The goal of this project was to create a web application to teach programming using Wolfram Language and Scratch Blocks as an interface. Among the main objectives of the project were:

- Create a useful design experience for the kids, so that it’s intuitive and interesting enough for them.

- The ability for them to use their previous outputs to evaluate them using other functions, just like in a regular Mathematica Notebook.

- Create a persistence layer, so that the web application maintains its state and can communicate correctly with the WL server.

* * *

## Features:

### Friendly Interface

- Visual outputs, Functions focusing on visual stuff.

### Tutorials

- Ability to create tutorials so the kids can follow along

![ezgif-1-1c89ee044663.gif](https://global.discourse-cdn.com/wolfram/original/2X/e/e18f6a689d583e0b726651dd7df5f57967cad70e.gif)

### Challenges

- Ability to import challenges and check them on the backend

- Challenges include blocks and instructions to be solved.

![ezgif-1-1a8b9d305b00.gif](https://global.discourse-cdn.com/wolfram/original/3X/4/8/48fd8f8d04b8af1938437ca9dbaee2355201170c.gif)

### Reusable Outputs

- Just like a regular Mathematica notebook, you can apply further transformations to the last output

- You can also put the id of the output you want to use

![ezgif-1-7badf58c2eee.gif](https://global.discourse-cdn.com/wolfram/original/3X/1/d/1dda83f403cd9f0d98abb241e55c60d8ea347974.gif)

### Scalable

- It is possible to add new Blocks, Tutorials and challenges easily

* * *

```
 (* This code adds additional challenges and has the ability to check them in the back end*)
CheckAnswer[resp_, problem_] :=
    With[{answers = <|
        ButterflyString :>
            SameQ[resp,"Pneumonou..."],
        MostCommonLetters :>
            SameQ[Sort[resp], {"d", "e", "g", "s", "y"}]
        (* ... *)
        |>},
      If[answers[problem], Style["Correct!", Green, 20],
        Style["Wrong!", Red, 20]]];

```

* * *

## Conclusion

This Project was a great opportunity to showcase the abilities of the Wolfram Web Engine, and additionally learn to use some functions interactively to have an idea of the potential that this platform can offer to teach Children about the Wolfram Language, that’s also the main reason why I tried to focus on activities that could only be done using it. I have always been amazed by how you can make awesome demonstrations and graphics with it writing very little code, having such potential accessible for children especially at a young age makes them spark an interest in pursuing STEM fields, and there is nothing like the feeling that has in them to build something functional and see it working for the first time. And with the infinite capabilities of the Wolfram Language, I can’t wait to see what they will create.

## Future Work

- A method to have the blocks look less cluttered horizontally is still needed.

- There is a potential for anyone to add additional WL functions and definitions, and they should work just as well, the same thing with additional tutorials and challenges. there is also the possibility to have everything in the cloud, so the user just needs to log in to get their project anywhere.

- There is also the possibility to package everything as a standalone app for Desktop or Tablets.

* * *

## Download

You can download the full code here, it is self contained (however you must have some kind of Wolfram Language Engine installed, like Mathematica Wolfram Desktop, etc.)

## [GitHub - Mackaber/BlockyWL: BlockyWL is a project based on Scratch 3.0 to teach kids Functional Programming using Wolfram Language · GitHub](https://github.com/Mackaber/BlockyWL)

## References

- [https://scratch.mit.edu/](https://scratch.mit.edu/)
- [Lifelong Kindergarten · GitHub](https://github.com/LLK/)
- [Wolfram Engine](https://www.wolfram.com/engine/)
- [Client Challenge](https://pypi.org/project/wolframwebengine/)

---

<div class="post-metadata">

**Author:** ![arbenk](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/arbenk/32/647_2.png) [@arbenk](https://community.wolfram.com/u/arbenk)\
**Post date:** [August 7, 2019, 7:56pm UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/2 "2019-08-07T19:56:07Z")

</div>

This is really cool, and I’d love to play with itI’ve downloaded the source from github, but I can’t get working (and neither can a few others I’ve spoken to). Would it be possible to get some guidance here on a fix, possibly with the help of [@Kyle Keane](https://community.wolfram.com/web/kylek) ?

Thanks!

Arben

---

<div class="post-metadata">

**Author:** ![x](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/x/32/3399_2.png) [@x](https://community.wolfram.com/u/x)\
**Post date:** [August 7, 2019, 10:53pm UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/3 "2019-08-07T22:53:26Z")

</div>

Hi Arben, I just put the project in a separate directory and make sure it works as a new installation.  
Also, I included instructions on how to add new Functions/Challenges/Tutorials.

You can check it here: [GitHub - Mackaber/BlockyWL: BlockyWL is a project based on Scratch 3.0 to teach kids Functional Programming using Wolfram Language · GitHub](https://github.com/Mackaber/BlockyWL)

---

<div class="post-metadata">

**Author:** ![arbenk](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/arbenk/32/647_2.png) [@arbenk](https://community.wolfram.com/u/arbenk)\
**Post date:** [August 8, 2019, 8:10pm UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/4 "2019-08-08T20:10:10Z")

</div>

Hey Miguelthanks! I’m woefully unfamiliar with git, but I think you to set the permissions for the project to public? I get a permissions error when trying to use git clone via terminal. Failing that, I downloaded the zip, and I get the same problem as previously when trying to run npm install from the BlockyWL folder…

---

<div class="post-metadata">

**Author:** ![x](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/x/32/3399_2.png) [@x](https://community.wolfram.com/u/x)\
**Post date:** [August 8, 2019, 10:09pm UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/5 "2019-08-08T22:09:34Z")

</div>

Sorry for the inconvenience, This project makes use of submodules (separate projects to keep the code organized) you may need to generate an ssh key and upload it to Github, you can follow this guide: [Generating a new SSH key and adding it to the ssh-agent - GitHub Docs](https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) Alternatively you can download [GitHub - Mackaber/scratch-gui: Graphical User Interface for creating and running Scratch 3.0 projects. · GitHub](https://github.com/Mackaber/scratch-gui/) and [GitHub - Mackaber/scratch-vm: Virtual Machine used to represent, run, and maintain the state of programs for Scratch 3.0 · GitHub](https://github.com/Mackaber/scratch-vm/) separately and put both of them into the “client” directory.

Hope this solves the issue.

---

<div class="post-metadata">

**Author:** ![murray](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/murray/32/39879_2.png) [@murray](https://community.wolfram.com/u/murray)\
**Post date:** [August 11, 2019, 7:33pm UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/6 "2019-08-11T19:33:28Z")

</div>

Your method of obtaining and running your Scratch with WL just does not work for me.

First, I made sure I had a github ssh key, was logged in at github, and had ssh-agent running. Still, the `git-clone` command failed. So finally I just did a direct download using the “Clone button” on your project page, then unzipped (and removed the “-master” appendage to the name of the resulting folder.

But now, `npm start` generate errors:

```
> blockywl@0.0.1 start /Users/murray/Downloads/BlockyWL
> concurrently 'npm:wl-*'

sh: concurrently: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! blockywl@0.0.1 start: `concurrently 'npm:wl-*'`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the blockywl@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
...

```

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [August 11, 2019, 9:39pm UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/7 "2019-08-11T21:39:42Z")

</div>

Murray,

Did `npm install` succeed?

---

<div class="post-metadata">

**Author:** ![murray](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/murray/32/39879_2.png) [@murray](https://community.wolfram.com/u/murray)\
**Post date:** [August 12, 2019, 1:22am UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/8 "2019-08-12T01:22:41Z")

</div>

Ooops…I forgot to run `npm install` in the `BlockyWL` directory. I now did that, and I think it’s stuck in an infinite loop: been running about 10 minutes, keep seeing “Installing Scratch VM dependencies”.

---

<div class="post-metadata">

**Author:** ![arbenk](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/arbenk/32/647_2.png) [@arbenk](https://community.wolfram.com/u/arbenk)\
**Post date:** [August 12, 2019, 2:33pm UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/9 "2019-08-12T14:33:14Z")

</div>

That’s precisely what happens for me, yes.

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [August 14, 2019, 2:14am UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/10 "2019-08-14T02:14:09Z")

</div>

I think `git clone` is required so that the submodules are also cloned. On Mac OS.

```
eval "$(ssh-agent -s)"
ssh-add -K ~/.ssh/id_rsa
git clone --recurse-submodules git@github.com:Mackaber/BlockyWL.git
cd BlockyWL
npm install

```

No infinite loop, but fails with

> No matching distribution found for wolframwebengine

Expected because I have not installed

> **[Client Challenge](https://pypi.org/project/wolframwebengine/)**

---

<div class="post-metadata">

**Author:** ![wolframcommunity](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wolframcommunity/32/8335_2.png) [@wolframcommunity](https://community.wolfram.com/u/wolframcommunity)\
**Post date:** [September 13, 2019, 11:34am UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/11 "2019-09-13T11:34:38Z")

</div>

![2015-11-02_10-07-11.png](https://global.discourse-cdn.com/wolfram/original/3X/5/0/50e59c9ead62f729e7130d3ea1482555a75602b6.png)

- Congratulations! This post is now featured in our [Staff Pick](http://community.wolfram.com/content?curTag=staff+picks) column as distinguished by a badge on your profile of a [Featured Contributor](http://community.wolfram.com/web/x)! Thank you, keep it coming!

---

<div class="post-metadata">

**Author:** ![anon21378091](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@anon21378091](https://community.wolfram.com/u/anon21378091)\
**Post date:** [September 13, 2019, 2:39pm UTC](https://community.wolfram.com/t/wss19-wolfram-language-using-scratch-blocks/14364/12 "2019-09-13T14:39:31Z")

</div>

Has anybody been able to get this to successfully installed and working with Mathematica on a Mac? And if so, exactly how?
