Skip to content

Comment on Logo Programming

Comments

I myself learned programming with logo, at my school when I was 8 or 10. And it was a delight, I am so grateful it existed.

But quite surprisingly, when later during my Ph.D. part of my time was dedicated to give exercises to students. And we used logo instead of the more usual programming languages. And I think it really helped them to really internalise programming a lot better. Typically, the latest exercices introduced recursion which is immediately visible as fractals.

    HIDETURTLE
    
    PENUP
    SETXY -200 0
    RIGHT 90
    PENDOWN
    
    to dragon :degree :size
        setpensize 1
        if :size>5  [setpensize 2]
        if :size>10 [setpensize 3]
        if :size>20 [setpensize 4]
        if :size>40 [setpensize 5]
        ifelse :degree=0 [
            fd :size
        ][
            left  45 dragon (:degree-1) (size/4)
            right 90 dragon (:degree-1) (size/2)
            left  90 dragon (:degree-1) (size/4)
            right 45
        ]
    end
    
    dragon 6 3000

if you want to give a try :)
Typically, the latest exercices introduced recursion which is immediately visible as fractals.

I well remember the epiphany I felt while learning Logo in elementary school, at the moment I understood what recursion is. I don't think the fact that the language I have mostly written code in in recent years is Emacs Lisp is unrelated to the above moment.

small correction - use `:size` in the three lines near the bottom (rather than `size`)

I tried it on https://www.calormen.com/jslogo/ and saw this small typo

cheers!

p.s. same as you, I was introduced to Logo around the age of 8 and I remember writing programs on paper when I was home, stepping through them line by line... it was inevitable I'd gravitate towards programming, ha :-)

I'd also recommend `:degree <= 0` as the check, rather than `= 0`, just in case someone passes `5.01` to the function (which would cause an infinite loop as you'd never hit exactly 0). But yes, if that was just coded into the comment box then it looks pretty good.

I should have scrolled down to your comment first! I spent 10 minutes debugging.

Nice work GP if that was air-coded, though.

I was also introduced to computer programming using LOGO back in 1989. I remember drawing houses and stick figures in it.

Fast forward around 2010, I gave Agent Based Simulation workshop courses to PhD students using NetLogo , which at the time was very popular in the Social Sciences.

It was very interesting to teach programming to non-tech very intelligent people. Some of them came up with really cool simulation ideas. I loved that part of my career.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.