Let's say you want to draw a hypocycloid (spirograph) with a turtle.
-
golang just looks like some kind of java variant to me (presumably with less strictness to make it less annoying for new programmers?)
What really makes it different? I judge a lot about a language based on how it formats loops and functions.
I find that for young programmers python is easier. A lot of them REALLY struggle with managing braces correctly. (Although, I'm working on ways to address this.)
@futurebird @glennsills https://processing.org/ or https://p5js.org/ might be fun
-
@futurebird @glennsills https://processing.org/ or https://p5js.org/ might be fun
We use p5js. I like it MUCH more than the blocks.
But, there is still that whole issue of relative vs. absolute positioning.
-
@futurebird @glennsills https://processing.org/ or https://p5js.org/ might be fun
What has golang got that p5js is missing? They seem like kind of the same general idea to me.
-
Let's say you want to draw a hypocycloid (spirograph) with a turtle. I use a parametric equation for each of the circles and combining them to find the x and y position of the points on the curve then telling the turtle to goto(x,y)
This works fine, however it is NOT in the intended "spirit" of drawing with a turtle. Drawing with a turtle is about "relative" navigation. Consider two ways to draw a circle:
for 0<t<2pi:
goto(rcos(t), rsin(t))repeat 100:
forward 2
right 2Another way to think about this: if you are drawing "in the spirit" of turtle drawing your turtle is facing in the dy/dx of the curve you are creating at all times and simply going forward. So I could take the derivative of the curve and use that to turn the turtle (relative to its previous position!) a little for each step in the drawing.
This sounds even more needlessly complex than what I was doing before but I keep hoping something dead simple will just fall into my lap.
-
F myrmepropagandist shared this topic
-
golang just looks like some kind of java variant to me (presumably with less strictness to make it less annoying for new programmers?)
What really makes it different? I judge a lot about a language based on how it formats loops and functions.
I find that for young programmers python is easier. A lot of them REALLY struggle with managing braces correctly. (Although, I'm working on ways to address this.)
@futurebird Oh no! Go is what happens when a bunch of good language designers decide Java and C# (and F# and C++) have fatal issues and decide to start from scratch. The idea is to make the compiler so fast it seems like scripting but compile to machine code (instead of a virtual machine - like Java or C#)
-
@futurebird Oh no! Go is what happens when a bunch of good language designers decide Java and C# (and F# and C++) have fatal issues and decide to start from scratch. The idea is to make the compiler so fast it seems like scripting but compile to machine code (instead of a virtual machine - like Java or C#)
This sounds like it wouldn't have much impact on what I'm concerned with, which is simply getting young people to write functions and loops without getting so frustrated they give up... but also with enough understanding of what they are doing they can apply it to ANY programming language some day and do whatever they want.
Basically I'm very happy to avoid teaching about syntax... up to a point.
-
What has golang got that p5js is missing? They seem like kind of the same general idea to me.
@futurebird @pikesley To be fair I was kidding old guy curmudgeon style. I would teach high school kids Golang before I teach them C. It is probably too much as an intro to programming.
That said, starting off with scripting can lead to some pretty bad habit. Just look at the average web page.
A good middle ground would be Python.
-
Another way to think about this: if you are drawing "in the spirit" of turtle drawing your turtle is facing in the dy/dx of the curve you are creating at all times and simply going forward. So I could take the derivative of the curve and use that to turn the turtle (relative to its previous position!) a little for each step in the drawing.
This sounds even more needlessly complex than what I was doing before but I keep hoping something dead simple will just fall into my lap.
@futurebird I think the only "perfect" solution is an analog computer with a vector display.
And I'm reminded of an obsession I had for a while on figuring out if you could make all possible sizes of square by intersecting lines that had to go through at least two (so infinite) integer coordinate point in the plane.
I think the answer is no and that I could prove it by relating it to countable vs uncountable infinities.
-
OK one more way to draw a circle.
for -r<x<r:
goto(x, sqrt(r*r-x*x))for -r<x<r:
goto(x, -sqrt(r*r-x*x))We could even use the distance formula again for this one. But everyone knows sin and cos are the most elegant.
@futurebird what language ?
-
@futurebird what language ?
python, scratch, java, p5js
-
@futurebird @pikesley To be fair I was kidding old guy curmudgeon style. I would teach high school kids Golang before I teach them C. It is probably too much as an intro to programming.
That said, starting off with scripting can lead to some pretty bad habit. Just look at the average web page.
A good middle ground would be Python.
I think python is perfect for education. It’s easy to get started and as you want to do more complicated tasks you don’t discover the walls of the sandbox constraining your growth. The only reason I don’t insist we do everything in python is my commitment to teaching programming concepts in a “language agnostic way” — this makes me think exposure to many languages is good. Even exposure to the blocks.
-
@futurebird what language ?
That is to say I don’t think the language is that important to this question of “relative” vs “absolute” drawing.
Relative drawing is used in education because it’s much more intuitive. Writing commands like directions gets kids going. Then at some point (often without ever explaining the change) you start just using coordinates— I think some kids get lost in that transition and if I can understand it better— if there is a lesson in making this change it could help.
-
That is to say I don’t think the language is that important to this question of “relative” vs “absolute” drawing.
Relative drawing is used in education because it’s much more intuitive. Writing commands like directions gets kids going. Then at some point (often without ever explaining the change) you start just using coordinates— I think some kids get lost in that transition and if I can understand it better— if there is a lesson in making this change it could help.
outside of education, relative drawing is used all the time as well, because things move; first you do relative drawing, then you apply rotations, translations, and perspective transforms.
-
That is to say I don’t think the language is that important to this question of “relative” vs “absolute” drawing.
Relative drawing is used in education because it’s much more intuitive. Writing commands like directions gets kids going. Then at some point (often without ever explaining the change) you start just using coordinates— I think some kids get lost in that transition and if I can understand it better— if there is a lesson in making this change it could help.
@futurebird @GezThePez I can confirm that this was something that confused young teenaged me. Not so much the transition but the fact that there wasn't a transition. It wasn't until I learned about affine transforms (a tiny bit at A level, most at university) that I realised that it even was possible to take something from one form of expression and mechanically translate it to the other.
This is often also a special case of the distinction between imperative and declarative programming.
You wrote both of these as imperative, but, from your original example, the
goto
is unusual. The way that this is normally written (when introducing children to it) is declaring that a line exists which is drawn for all rho wheresin(rho) = cos(rho)
, whereas the second form is explicitly imperative (you're giving commands to a turtle). I wouldn't normally write the first form withgoto
, I'd write it just setting pixels.Your third example is also interesting because it's very much a declarative form: a circle is defined as all points that are equidistant in a 2D plane from a defined point. And realising that lets you derive your first form because the first form is 'just' the definition of all possible triangles where the hypotenuse length is a constant. But all of these are forms that provide continuous functions that specify the locations of all of the points on a line, whereas the turtle one is a set of instructions.
You can turn the declarative forms into equivalent imperative forms (as you did) by saying 'for each point in some discretised form, draw a line segment or pixel that approximates it'. But transforming it to the imperative form for the turtle is much harder because the quantisation becomes more explicit.
And this might be why I haven't done computer graphics since I finished my PhD.
-
The second method is "in the spirit" of turtle drawing... but it's not obvious what the radius is, or even if it will be a full circle or not. I discovered I could reconcile it and made a big mess. (I'm trying to be open minded about programming with blocks but I lowkey hate it. I can't type equations! I have to make them like little snowmen.)
I guess what I want is a procedure to convert from relative drawing to coordinate based drawing like when you go from parametric to functions of x.
I think there might be something in using “mod” for steps with a constant turn (to draw spirograph like patterns) but one of my students got very distracted and made this mess. Delightful isn’t it.
-
I think there might be something in using “mod” for steps with a constant turn (to draw spirograph like patterns) but one of my students got very distracted and made this mess. Delightful isn’t it.
@futurebird oh which tool is this?
-
@futurebird oh which tool is this?
Snap! Build Your Own Blocks
The Snap! Community. Snap! is a blocks-based programming language built by UC Berkeley and used by hundreds of thousands of programmers around the world.
(snap.berkeley.edu)
-
I think there might be something in using “mod” for steps with a constant turn (to draw spirograph like patterns) but one of my students got very distracted and made this mess. Delightful isn’t it.
@futurebird LOVE doing spirographs in block-based coding! With middle schoolers we teach it as a repeated shape off-by-one (so turn 121 degrees to do a triangle spirograph instead of 120 for a repeated triangle, 361 for a square, etc). https://scratch.mit.edu/projects/13505540/editor/
-
@futurebird LOVE doing spirographs in block-based coding! With middle schoolers we teach it as a repeated shape off-by-one (so turn 121 degrees to do a triangle spirograph instead of 120 for a repeated triangle, 361 for a square, etc). https://scratch.mit.edu/projects/13505540/editor/
@bensk Gotta check this out later— are you able to make identical designs with the toy? that’s part of the big idea in all of the activities for grade 5 — connecting physical drawing machines to programming in the hopes that the code ends up feeling like something more tangible.
-
I think there might be something in using “mod” for steps with a constant turn (to draw spirograph like patterns) but one of my students got very distracted and made this mess. Delightful isn’t it.
@futurebird Reminds me of the Euler spiral