5 ms·
That's interesting. The semantic white space is part of what made me fall in love with the language[1]. What kind of problems do your learners have with it? [
by Kim_Bruning 6y ago
That's interesting. The semantic white space is part of what made me fall in love with the language[1]. What kind of problems do your learners have with it?
[1] (You should be indenting to indicate your block structure anyway. A lot of beginners I've seen get their indents mixed up with the actual block structure. Not so with Python: The code runs like how it looks.)
- jampekka 6y agoI'm really starting think there are a lot of people who think "programming" is mindlessly copypasting snippets off somewhere until something works. And they don't like significant whitespace because it reduces the chances of randomly copypasted stuff doing something.
- newen 6y agoThis is what is generally called a straw man logical fallacy. The issue is that something as simple as copying and pasting code (say from one file to another, both of which the programmer has written) is made excessively complex due to whitespace being significant. Call it code smell or developer smell or keyboard smell or whatever you want but this issue simply does not exist for programming languages that do not have whitespace significance.
- bobbylarrybobby 6y agoThe correct solution to this problem is an autoformatter. You should be indenting your code to match its structure, yes, but if you use Python you have to do so, whereas if you use a brace delimited language you don’t, as it’s handled for you (by the autoformatter). In both cases, your code looks right before you run it, but the editing experiences differ drastically. In Python, a simple cut/paste is nontrivial to get right and it’s difficult for editors to infer how to indent a line when you press the return key. In a brace delimited language, these problems simply don’t exist.
- Kim_Bruning 6y agoI don't think anything will save you if you mess up your block structure. You can mess up your block structure with indents, or you can mess it up with braces. Personally I think it's easier to spot mess-ups with indents. Some people think braces are easier. I won't fight with those people today :-). But I don't think randomly cut&pasting code anywhere is a good idea. If you do paste code, you really should understand what the code is doing first.
- kortex 6y agoThis is absolutely true. If I paste some c++ into my IDE with unbalanced braces, it can throw the whole file off. The real key is: treat excess indentation and nesting as a code smell. Python should aim for 5 tabs deep max, imho. Anything else should be refactored into functions.
- belorn 6y agoI would add that the same is true for braces in c++. Debugging the differences between }}))} and }))}} can be quite difficult , as nested scopes is never easy in any language.
- BadInformatics 6y agoI agree WRT block structure, but having TA'd a Python course that "should" doesn't survive contact with a real world classroom. Students will use anything from IDLE to Notepad to PyCharm, and usually shut down completely instead of trying to work things out when the code snippet they've spliced into their program from StackOverflow fails to run because of mismatching indentation. I'm not sure why few try to understand the SyntaxError messages, but it's like they don't exist! Part of me wants to forbid all "dumb" text editors for introductory programming courses and make everyone use an AST-based one that only allows you to create syntactically correct programs. Unfortunately there's zero chance of that happening any time soon...
- Kim_Bruning 6y agoPossibly you've had more students in one go than I've ever had for all the languages I've done put together then. That said: Here's a weird thing that seems to work (especially while learning): Instead of copy-pasting code, type it into your program by hand. For some reason this helps a lot when trying to understand or debug the code that you are entering. This works equally for those of us who started learning using BASIC on 8-bitters, all the way to Python, Java, or odd things like Siemens SCL. Wrt editors: the times I've taught people, I actually went completely the other way: requiring the first few programs to be written in notepad or nano (depending on OS) . This tends to take the magic out of what the IDE is doing, and makes everything after it much easier. Both of the above would seem to be relatively time-consuming. But oddly enough in practice they can save more time than they consume.
- majormjr 6y agoThis is one of the key parts when starting to learn programming. Just typing out everything manually really helps you see the small details that are important when writing code that can get lost when copying from elsewhere. Courses like Learn Python the Hard Way focus on this method and I think it's the best way to go for absolute beginners.
- BadInformatics 6y agoAbsolutely, I find this approach gets the right mental gears turning as well. The problem comes up most often with take-home assignments though, where students are more likely to copy-and-paste a couple lines from somewhere because you haven't given them a full program. If anything, an IDE might be better because it'll give more localized feedback and people are more likely to react to the red squiggles :)
- ywei3410 6y agoI teach adult learners; my own experience suggests that there are multiple issues. First, is that in no other text form, does white-space change meaning such that the text becomes "unreadable" (sure your docs may be formatted a little weirdly, but hey someone can still read it). Simple python is close enough to prose that people get confused. Second, is that they haven't learnt to grok compiler messages - the program either works or doesn't work. Coupled with number 1, it basically means they can't /see/ any issues or fix them.
- Kim_Bruning 6y agoInteresting, are there other languages that they find easier to read and write? And ... very interesting... what are the pain points when interacting with compiler/interpreter messages, in your experience? Are they introduced early on?
- ywei3410 6y agoI haven't found one; and I hypothesize that if one were to exist it wouldn't be useful. Ironically, the GPT code generators are probably the closest - where the syntax is inexact and ambiguous. I'm not entirely sure - but the terseness of the message and the out of the way location meant that the students... mostly ignored the errors. I think having a pedagogic IDE [1] which would /massive/ highlighting and really verbose errors may have helped; but that's entirely my speculation. [1] Example of a pedagogic IDE which has arrows: https://i.stack.imgur.com/CwKQG.png https://i.stack.imgur.com/CwKQG.png