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:

6 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.

4 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.”

3 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!

6 Likes