Teaching Julia to Children

Thanks for mentioning this, I was not aware that Julia had a turtle graphics implementation. It looks amazing and should allow starting the students with a small vocabulary, then provide a smooth transition to programing constructs (loops, functions) and perhaps Julia proper.

I think that turtle graphics is the best introduction to programming for children. Simple, visual, self-contained, with little distraction but still space for creativity. And the @step macro should help a lot.

2 Likes

IMG_8071

Luxor.jl has had turtles for years :joy:

7 Likes

Apologies for the noise, but I can’t help but plug Processing again in this context.

My first ever program was this:
size(400,400);  stroke(225); strokeWeight(3);
line(100,200,300,200);
//line(100,100,300,300);
//line(300,100,100,300);
line(200,300,200,100);
 fill(35,150,25,25);
 ellipse(200,200,50,50);
ellipse(200,200,75,75);
ellipse(200,200,100,100);
ellipse(200,200,125,125);
ellipse(200,200,150,150);
 ellipse(200,200,200,200);
 ellipse(200,200,250,250);
 ellipse(200,200,300,300);
 ellipse(200,200,350,350);
 ellipse(200,200,400,400);
 
 fill(25, 185); noStroke();
 ellipse(350,300,15,3);
 ellipse(350,300,3,25);
 ellipse(120,270,20,5);
 ellipse(120,270,5,30);

I didn’t yet know about loops, or scope, or functions, or strings, or really anything. That was literally made on my very first day of programming. All of those functions I used were on a printed piece of paper for reference. I just kept typing ellipse(...) and more circles appeared on the screen!

Knowing a decent bit of math by that age (20-ish) it was easy to make more complicated sketches by the end of week, once I looked up how to loop (I remember thinking after all that copy-paste “There’s got to be a better way!” – there was).

Later that week
size(600, 600);
background(140,20,50);
noStroke();

int max = 400;
float inc = 11;
float cx = width/2;
float cy = height/2;

for (float i =0; i<max; i=i+inc){
  float r = max-i;
  
  float col = pow(-1,r);
  
  fill(45,160+(col*150),160,70);

  pushMatrix();
  translate(cx,cy);
  rotate(radians(i));
  ellipse(0,0,275,width-50);
  popMatrix();
}

for (float i =0; i<max; i=i+inc){
  float r = max-i;
  
  float col = pow(-1,r);
  
  fill(155,20,30+(col*50),130);

  pushMatrix();
  translate(cx,cy);
  rotate(radians(i));
  ellipse(0,0,30,275);
  popMatrix();
}


noFill();
stroke(200);
ellipse(cx,cy,275,275);
ellipse(cx,cy,width-50,width-50);

A couple of weeks in, I had been making a few animations and interactive sketches as well:
FloatList x1 = new FloatList();
FloatList y1 = new FloatList();

void setup() {
  size(1200, 720);
  smooth();
  strokeWeight(5);
  stroke(0, 60);
  frameRate(60);

  for (int i=1; i<12000; i++) {
    float r = random(width/2 + 200);
    float l = random(50);
    x1.append(-l);
    y1.append(r);
  }
}

int blah = 0;

void draw() {
  fill(255, 20);
  rect(-10, -10, width+10, height+10);

  for (int i=0; i<=5000; i++) {
    float l = x1.get(i);
    float r = y1.get(i);

    pushMatrix();
    translate(width/2, height/2);
    //rotate(random(2*PI));
    rotate((-blah));
    line(-l, r, l, r+l);
    popMatrix();
    blah++;
    blah = blah % 360;
  }
}

Screen Recording 2025-02-07 at 4.55.25 PM (1)

And following along with the Youtube channel I linked in my earlier message, I tackled some “advanced projects” over the first few months too. As I recall, this one was my first “big project”, which I basically recreated line for line https://www.youtube.com/watch?v=BjoM9oKOAKY

For the record, 10 years later, I’m an ML engineer who writes a lot of code (mostly in julia and python). I still think Processing (or these days “p5” maybe) is the single best language to learn for any beginner. I think the simplicity and the resources are incomparable.

8 Likes

I don’t have any reason to believe you are doing this (though I haven’t read the whole thread), but as with anything made for children, it’s worth cautioning against infantilizing them. Take my experience with a grain of salt because I’ve never been an educator or education researcher, but I’ve noticed that computer-related education tailored to kids with eye-catching graphics and games actually had less staying power.

True, gamification does its job of grabbing attention in the short term, but the game often distracted from learning a lifelong skill, and it’s perfectly natural to lose interest in most games after a short time. Dryer tutorials actually kept our interest longer because they tend to do a better job of communicating how these skills could be useful. For a very dated example, the video game The Typing of the Dead was fun and gave us some practice, but only a fraction of us were interested enough in shooting zombies to even beat the short game. However, credibly informing us with a demonstration that we could on average type several times faster with nearly effortless digital backup than handwrite was enough to convince most of us to practice computer skills in other classes on our own. After all, that gave us more time to play other games for fun.

Can you think of more up-to-date examples that can convince children that programming in general and Julia in particular can be useful for them now or soon? Each example doesn’t need to convince them all at once, but they should add weight to the notion that “this can help me.”

5 Likes

Thank you for all your replies!

I will have to thing well about this.

Just one minor caution about using Pluto. I think it’s an excellent learning environment, however it has one small problem with regards to learning programming. The reactive nature of its notebooks encourages students to think in terms of variables as global and Observable. When I once used Pluto in a Programming for Beginners course, I discovered too late that the students had internalised this idea to an extent where they had great difficulty coping with important programming ideas about scoping, encapsulation and the sequentiality of algorithms. Sorry, Fons!

10 Likes

I’ve been teaching kids programming for 12 years, including some Julia, in a group we’ve named “Beta Group”.
The number one attraction is the ability to modify games. The small games of Gamezero.jl are relevant there. Check my modifications for Breakout for some ideas.

They’ll need to know the basic syntax, and from there it is searching your way while doing.

From there go with whatever project they find interesting.

By the way, I prefer C as a first language, because its pesky, so moving from it to more modern languages on a later stage gives a motivation boost of “Oh, tht’s easy!”. Starting with Python, by the way, gives the opposite effect and makes people give up on more advanced programming since “It’s not as easy as I thought”.

These materials I’ve created might also help, although in Hebrew, Just use machine translating to understand it:

  1. Challenges and general information on the way we do it in “beta group”.

Challenge sites such as Exercism.org would do a similar effect, except for the beta group social context which gives a very strong frame for not giving up.

  1. My unfinished guide on Julia for the Beta group members

There’s also such a guide for working with Linux. These guides work by making them smile.

And that’s the secret: Enjoying it. If it’s fun, they’ll learn by themselves.

4 Likes

Thanks for your reply! So basically you teach kids C before Julia?

Python is not on my list of goals to teach. When I decided to learn Julia, I abandoned a Python tutorial I had started because Julia is better by design. It was like - before investing time in Python, I needed to research the best option. And Julia was it. (I studied economics.)

For Linux there is the official beginner’s handbook from Debian, which is a good start with it’s nearly 300 pages. The Debian beginner's handbook

Can you explain more about your experience teaching kids to code?

Coming at this from the perspective of a homeschool Dad, I would look at it from the perspective of relationship and purpose. We should have a good relationship with those we teach. As a grandparent I have had my 8 & 10 year old grandchildren on my lap a few times showing them a few things on the REPL. The 8 year had a lot of fun with strings and variables while I tried to get those concepts embedded. I don’t think I succeeded in teaching the concept but there was relationship and fun. Some of the posts above mentioned purpose which is also worth thinking about.

1 Like

Indeed C first. With C you better understand how the computer does things, the more productive languages hide that. (And things that C hides or makes fuzzy can become clearer with assembly, if needed.)

My technique is to present an interesting goal and let them work their way to that goal. In many cases they won’t get to the goal, but they’ll learn a lot on the way (We all have these unfinished hobby projects).

The hard part is to find the thing which makes them go “Wow, let me try”, this one might be different with each child.