7 ms·
This has me reflecting on how I learned to program, compared to how people learn to program today. I learned to program using BASIC when I was between 5 and 10
by japhyr 9y ago
This has me reflecting on how I learned to program, compared to how people learn to program today.
I learned to program using BASIC when I was between 5 and 10 years old. My dad was a software engineer at DEC, and he had a kit computer in our basement that he let us play with once in a while. My first program was a number-guessing game, and it went something like this:
10 NUMBER = 23
20 PRINT "I'm thinking of a number."
30 INPUT "Make a guess: " $GUESS
40 IF GUESS < NUMBER THEN
50 PRINT "Too low!"
60 GOTO 30
70 ELSEIF GUESS > NUMBER THEN
80 PRINT "Too high!"
90 GOTO 30
100 PRINT "You got it!"
That was pretty straightforward, because everything about it was linear except for the GOTOs. You can think about each step with very little planning, and when you need a break in program flow you can use a GOTO. It also means when teaching, you can introduce each new concept as the need arises: store a value, print a statement, prompt for input, check a condition, and go back to a previous statement.
Let's see the same program in Python:
number = 23
print("I'm thinking of a number.")
guess = 0
while guess != number:
guess = input("Make a guess: ")
guess = int(guess)
if guess < number:
print("Too low!")
elif guess > number:
print("Too high!")
else:
print("You got it!")
The overall program logic isn't much different when you read the code. But to write this code, you need to know a number of things in advance. You need to know how you're going to approach the problem. You need to know what a loop is, and specifically what a while loop is. Conceptually, especially for a young person, a while loop is much more abstract than a GOTO statement.
I am happy that people get to learn a language like Python as their first language today. They can do much more interesting things, in a shorter amount of time, than they could in basic 40 years ago. But the very first programs people write seem fundamentally different, and that's not a bad thing.
- yoz-y 9y agoVery well put. I remember writing gotos everywhere when I learnt to code. Interestingly enough my first program was almost the same as yours. Great thing about a goto is that it is a single command which can emulate any of the other constructs. Also one thing I remember from back when was that if there was a problem I did not understand (I was mostly learning by modifying example programs that I somehow got) the only way to solve them was to try more things and harder. I did not have any books and internet was a luxury. Eventually I have understood more of the code and got better. Nowadays it is way easier to remain ignorant and still be productive.
- laumars 9y ago> Great thing about a goto is that it is a single command which can emulate any of the other constructs. The thing is BASIC does have other constructs. GOSUB[0] has been around in the 70s and that worked like a GOTO except when a RETURN statement was hit the code would then jump back to the point where it GOSUB'ed - effectively behaving as a rudimentary subroutine (hence the name, "GoSub"). There was also the FN[2][3] statement that allowed you to write basic functions, albeit you were limited to 1 liners. But by the 80s some dialects of BASIC were supporting more complex procedures[3][4]. [0] http://www.hoist-point.com/applesoft_basic_tutorial.htm#string_functions_gosub http://www.hoist-point.com/applesoft_basic_tutorial.htm#stri... [1] http://www.cpcwiki.eu/index.php/Locomotive_BASIC#FN http://www.cpcwiki.eu/index.php/Locomotive_BASIC#FN [2] https://www.c64-wiki.com/wiki/FN https://www.c64-wiki.com/wiki/FN [3] http://www.bbcbasic.co.uk/bbcwin/tutorial/chapter16.html http://www.bbcbasic.co.uk/bbcwin/tutorial/chapter16.html [4] http://www.bbcbasic.co.uk/bbcwin/tutorial/chapter17.html http://www.bbcbasic.co.uk/bbcwin/tutorial/chapter17.html
- int_19h 9y agoAlso, didn't the FOR..NEXT loop show up really early on?
- cicero 9y agoIt was in Integer BASIC and Applesoft BASIC on the Apple II. You could say something like this to count to 10: 10 FOR I=1 TO 10 20 PRINT I 30 NEXT I
- laumars 9y agoYup. Also WHILE/WEND loops and some basic error control with ERROR (raise), ON ERROR (capture). BASIC certainly had it's faults but it was a reasonably complete language. However it can't have helped the number of different dialects there were in the 70s and 80s. Each brand of consumer electronics seemed to ship with a subtly different list of statements which meant I think lead people to often stick with the core basics of, erm, BASIC.
- laumars 9y ago> I am happy that people get to learn a language like Python as their first language today. They can do much more interesting things, in a shorter amount of time, than they could in basic 40 years ago. How much is down to the language and how much is that to do with the capability of computers then vs now. A fair few dialects of BASIC could manipulate the hardware directly but the capability of those machines were always quite limited. However with the hacker community going strong for retro hardware, you can now get all sorts of cool mods, like the WiFi addon I have on my Amstrad CPC 464 which allows me to even make HTTP GET requests, from BASIC. Ok I'm still limited by 64K of memory but that just forces you to think more creatively. I'm not denying that Python teaches better programming principles than the early dialects of BASIC, but again how much of that is down to age given than newer dialects of BASIC can be structured very much like a typical imperative program. ie no requirement for line numbers, proper functions (though some dialects of BASIC have supported this since the 80s), etc. Sometimes though, I think the simplicity of your environment can count for a lot. I remember reading an interview with a dance DJ turned producer who commented that he regretted buying lots of hardware when he was starting out as it slowed his learning curving (too much tech to learn in one go) and thus he would have been better off buying one synth, mastering that, then moving onto another synth. I wonder if programming can be like that for youngsters these days. I wonder if they get crippled by the vastness of the options out there and all the layers of the stack involved in even the simplest of "Hello world!" programs. Yet BASIC on the micro computers of the 70s and 80s offered a simple, no hassle, interface to that allowed our young imaginations to fly. I think we were very lucky to grow up in that era.
- keypress 9y agoDefo, my Mum's partner had an Atari ST with cubase etc. and a couple of keyboards and he used to have fun and make music. Ever since he bought his first PC, he has made no music whatsoever, he spends his time in the Internet wormhole and optimising his hard drive (no kidding). Very easy to focus on your tool set and not actually use them.
- Jare 9y agoHehe the guessing game was my fist too, way before I even had a computer. I think what we have lost from the old 8-bit computers and their BASIC, was the ability to instantly have something show on the screen, like the classic Sinclair Spectrum spider web: 10 FOR n=0 TO 31 20 PLOT n*11,0 30 DRAW -n*11, 175-n*8 40 NEXT n (or something like that) That stuff got me hooked.
- hexane360 9y agoThis is a niche I think Scratch (https://scratch.mit.edu/ https://scratch.mit.edu/) does a pretty good job of filling
- Turing_Machine 9y agoYou can get pretty close to that with JavaScript, especially with all the CodePen-like sites out there -- but even without those, the JavaScript console is pretty similar to the old BASIC prompt in terms of immediacy and ubiquity. JavaScript also has this in common with BASIC: the language bigots hate it. :-)
- wruza 9y agoI like BASIC, C, D, Objective C, Perl, Lua, 8080 and x86 Assembly (no code for around 15 years, but still) and probably few others catched my eye, like Io, LISP, Haskell, but I had no time to master these, only done a bunch of snippets discovering their power. But I hate js (and php) with all of my soul’s strings, no matter how much time I spent learning or fixing it. How about that single data point. Otoh, I bet most js bigots only know one language very good, guess what it’s name is.
- Jare 9y agoIndeed! I defended JS for this exact purpose after the 2D canvas became truly ubiquitous. Still a minor amount of boilerplate but you can be drawing stuff in no time. With an integrated editor it would be perfect!
- foo101 9y agoYour code does not work for me. I get syntax error in line 20: https://imgur.com/a/mqI29 https://imgur.com/a/mqI29. What did I do wrong and how can I get it to work?
- steveklabnik 9y agoI learned exactly this way, with GWBASIC, with the same program. It's why I chose this program as the start of "The Rust Programming Language", honestly. Similar to your point about Python, it's more complex. Then again, so are computers... I'm lucky enough to still have the book for my first computer, my second encounter with BASIC. I tweeted some photos of it last year https://twitter.com/steveklabnik/status/721471207883808769 https://twitter.com/steveklabnik/status/721471207883808769
- int_19h 9y agoI've learned my BASIC with Turbo BASIC on DOS, which already had WHILE/WEND. I don't recall any trouble with this concept. When I moved on to QBASIC, which had a wonderful DO..LOOP construct which generalized loops with positive and negative pre- or post-conditions, also allowing for no conditions at all, it was really awesome and just felt "right". I also remember how befuddled I was by GOSUB/RETURN, having seen it after learning DEF FN and SUB. The idea that you could just fall through the "end" of a procedure by not returning from it seemed nuts.
- wruza 9y agoI think this snippet is missing either ENDIF at 95 or the fact that IF ... THEN <x> ELSE <y> accepts either a single statement or a line number to go to as <x> and <y>. So, in dialects where ENDIF doesn’t exist at all, it was actually a bit harder than just writing or thinking WHILE-style. When I moved from ZX spectrum-clone basic to gwbasic and tbasic/qbasic, it felt much easier. (I was also more advanced by the time, so can’t tell how it changed my view on the old style.) Edit: formatting
- d0mine 9y agoBy introducing a couple of functions: say() and audio_input(), you could make it into a talking game: number = 4 say("I'm thinking of a number") while True: try: word = audio_input("Make a guess: ").lower() except RuntimeError: say("Try again") else: say(word) guess = word2num.get(word) if guess is None: say("Not a number") elif guess < number: say("Too low!") elif guess > number: say("Too high!") else: say("You got it!") break Complete code example https://gist.github.com/3b3f26602e31198d399c643c8053b8b6 https://gist.github.com/3b3f26602e31198d399c643c8053b8b6
- underwoodley 9y agoI don't see these programs as fundamentally different. The only material different is that one uses a GOTO and the other uses a while loop. But I don't think either of these is more intuitive. When you learnt how a GOTO works, you probably learnt immediately afterwards how to use it to loop. This loop is a 'pattern', one which you would have to grok as a single idea before you could write a program like the above. This is similar to learning about a while loop, and then knowing you would need one when you wrote the Python script.
- hammock 9y agoI'm pretty sure you can write the program in BASIC without GOTOs. Doesn't BASIC have WHILE loops?
- hnruss 9y agoI also learned to program in BASIC, but I learned by creating games on the TI-83+ graphing calculator. The limited nature of the platform led me to learn quite a lot in addition to the basics: performance optimization, garbage collection, matrices, lists, UX, maintainability, keyboard shortcuts, and how to read documentation. Would I recommend this platform to someone else? Only if they needed to learn to program while pretending to do math homework.
- Kagerjay 9y agoMy first programming course was in fortran and i got away without using alot of built in loop logic using goto statements. Now i never use any goto statements ever