The simplest analogy to programming is a recipe. Add X, Add Y, Do Z till Z is in Q state. So while/for loop imo are really simple to get. Function calls are a bit harder but not much. Accomplishing tasks with recursion ? That's utterly counter-intuitive imo. A given person can learn it but feels like a trick. Maybe a cool trick they're cool for having learned and maybe a weird trick someone is pushing on them. Recurs…
Reconsidering the way I explain programming (2020)
11–20 of 49 posts
Re: Reconsidering the way I explain programming (2020)
#12The simplest analogy to programming is a recipe. Add X, Add Y, Do Z till Z is in Q state. So while/for loop imo are really simple to get. Function calls are a bit harder but not much. Accomplishing tasks with recursion ? That's utterly counter-intuitive imo. A given person can learn it but feels like a trick. Maybe a cool trick they're cool for having learned and maybe a weird trick someone is pushing on them. Recurs…
I try to avoid recursion, I don't want to blow out the stack. Personally I think it should not be used for implementation, I consider it to be a security risk. It's ok for high-level pseudocode.
For some, it’s practically the only way to loop.
Re: Reconsidering the way I explain programming (2020)
#13The simplest analogy to programming is a recipe. Add X, Add Y, Do Z till Z is in Q state. So while/for loop imo are really simple to get. Function calls are a bit harder but not much. Accomplishing tasks with recursion ? That's utterly counter-intuitive imo. A given person can learn it but feels like a trick. Maybe a cool trick they're cool for having learned and maybe a weird trick someone is pushing on them. Recurs…
I find recursion can be just as simple to explain. Start with a basket of tomatoes and a bowl. If there are no tomatoes in the basket, you’re done. Otherwise: Take one tomato. Dice it. Put the output in the bowl. Recur.
Re: Reconsidering the way I explain programming (2020)
#14The simplest analogy to programming is a recipe. Add X, Add Y, Do Z till Z is in Q state. So while/for loop imo are really simple to get. Function calls are a bit harder but not much. Accomplishing tasks with recursion ? That's utterly counter-intuitive imo. A given person can learn it but feels like a trick. Maybe a cool trick they're cool for having learned and maybe a weird trick someone is pushing on them. Recurs…
"Do X then do Y" style programming is natural for some people - mainly those who first learned programming that way. Mathematical expression style is more natural for other people, and recursion is very natural in that context.
Re: Reconsidering the way I explain programming (2020)
#15For me, there’s no better explanation possible than the description of software behavior in Specifying Systems by Leslie Lamport: > Formally, we define a behavior to be a sequence of states, where a state is an assignment of values to variables. We specify a system by specifying a set of possible behaviors—the ones representing a correct execution of the system. Programming is creating an executable description of a…
The Lamport quote does the same thing, but to software. The thing died in the process.
Re: Reconsidering the way I explain programming (2020)
#16Re: Reconsidering the way I explain programming (2020)
#17The simplest analogy to programming is a recipe. Add X, Add Y, Do Z till Z is in Q state. So while/for loop imo are really simple to get. Function calls are a bit harder but not much. Accomplishing tasks with recursion ? That's utterly counter-intuitive imo. A given person can learn it but feels like a trick. Maybe a cool trick they're cool for having learned and maybe a weird trick someone is pushing on them. Recurs…
I try to avoid recursion, I don't want to blow out the stack. Personally I think it should not be used for implementation, I consider it to be a security risk. It's ok for high-level pseudocode.
> I consider it to be a security risk.
Again, non-issue if your language handles recursion properly (and in some languages like Haskell, "blowing the stack" is not a thing that happens).
[0] https://en.wikipedia.org/wiki/Tail_call#Implementation_metho...
Re: Reconsidering the way I explain programming (2020)
#18One of the best ways is to teach them the basics of Logo. to square forward 100 right 90 forward 100 right 90 forward 100 right 90 forward 100 end is a square.[1][2] Then you can do: forward 100 square forward 100 square etc... Any child can get this. I did when I was 10 years old, with a bunch of other pre-teens. Got it right away and absolutely loved drawing various geometrical patterns. Of course, Logo is based on…
△ n = [ ↻ 30, ↑ n, ↻ 120, ↑ n, ↻ 120, ↑ n, right ]
When programming routines in Haskell: square :: Float -> Turtle ()
square n = do
penDown
moveForward n
rotateTurtle 90
moveForward n
rotateTurtle 90
moveForward n
rotateTurtle 90
moveForward n
rotateTurtle 90
penUp
Recursion is forbidden and all loops are bounded.[0] https://github.com/siraben/vpl/blob/4b5d39cbf8d16a988218e62f...
Re: Reconsidering the way I explain programming (2020)
#19The simplest analogy to programming is a recipe. Add X, Add Y, Do Z till Z is in Q state. So while/for loop imo are really simple to get. Function calls are a bit harder but not much. Accomplishing tasks with recursion ? That's utterly counter-intuitive imo. A given person can learn it but feels like a trick. Maybe a cool trick they're cool for having learned and maybe a weird trick someone is pushing on them. Recurs…
I try to avoid recursion, I don't want to blow out the stack. Personally I think it should not be used for implementation, I consider it to be a security risk. It's ok for high-level pseudocode.
Re: Reconsidering the way I explain programming (2020)
#20The simplest analogy to programming is a recipe. Add X, Add Y, Do Z till Z is in Q state. So while/for loop imo are really simple to get. Function calls are a bit harder but not much. Accomplishing tasks with recursion ? That's utterly counter-intuitive imo. A given person can learn it but feels like a trick. Maybe a cool trick they're cool for having learned and maybe a weird trick someone is pushing on them. Recurs…