3 ms·
I've been thinking about this a lot lately, and I agree Python is way better than Pascal or Java which it replaced as an introductory language. But I'm not sur
by beagle3 6y ago
I've been thinking about this a lot lately, and I agree Python is way better than Pascal or Java which it replaced as an introductory language.
But I'm not sure it's better than old basic. Python is definitely more readable - but it is less helpful than e.g. line numbers in helping form a mental model of a running program; and from my experience, "goto" and then "gosub + return" are easier to explain than funcs with local scope.
If I had to teach newcomers today, I would definitely teach Python -- because, once they do get it, it is actually useful for whatever they need to get done tomorrow morning. But I suspect e.g. BBC Basic (which has goto, gosub but also proc and local) would be easier for them to learn, and would get them farther in understanding programming in a shorter time.
- 8fGTBjZxBcHq 6y agoI have taught newcomers quite a bit and until you've done it you probably shouldn't trust your intuition about what non-programmers will and won't get hung up on. Also like you mentioned, in even the medium-short term the thing that will get people learning the fastest is the thing that gives them a reason to code. Pretty much always right now that's going to be JS or sure maybe python.
- beagle3 6y agoI have taught GW-BASIC, and also Python, C, Fortran and a couple of other languages through the years. But I don't trust my experience because it spans three decades, in which my experience changed, my student's backgrounds changed, etc. Looking backwards, it is my experience that line-numbers and goto/gosub clicked more quickly and more deeply than function calls. But, as you say, and as I alluded to in my first post, motivation to write code tomorrow morning is likely a better thing to optimize for. I would refuse to teach JS, though; it has way too many warts one can't avoid, creating damage that would take a while to undo.
- int_19h 6y agoGOSUB/RETURN may be easier to explain, but of course it also doesn't cover many things that functions with local scope do. Explaining functions and recursion is tricky in general, but necessary for other things to make sense. There are ways to do so that might be more intuitive for a newbie to grasp. For Python specifically, take a look at https://thonny.org https://thonny.org - it's particularly well suited to forming a mental model of a running program, including function calls, in a very visual way.
- beagle3 6y agoOh, of course. GOSUB/RETURN are easier to explain, but only as a stepping stone towards functions; I like them because unlike functions+locals, which are much more "all or nothing" - whereas when I taught basic, I would start with "GOTO" which is trivial for everyone to understand; then go to GOSUB+RETURN, which is just a tiny bit harder, but still very capable - my complex gosub+return example was flood fill[0]: 9000 REM F=FOREGROUND COLOR, X AND Y ARE COORDINATES 9010 IF POINT(X,Y)=F THEN RETURN 9020 PLOT(X,Y,F) 9030 X=X+1 : GOSUB 9000 : X=X-2 : GOSUB 9000 : X=X+1 9040 Y=Y+1 : GOSUB 9000 : Y=Y-2 : GOSUB 9000 : Y=Y+1 9050 RETURN Which does recursion, visually, with only gosub/return, lets me touch on stack overflows (trying to fill too big an image would on most interpreters). I have never had the chance to teach BBC Basic, but if I did, even though it has PROCs and LOCALs, I would still go the GOTO -> GOSUB/RETURN route, and only then proceed to DEFPROC / LOCAL. [0] This would also be introduction to multiple statements - I would show this with one statement per line and multiple statements per line and discuss pros/cons