Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There can't be such a thing as a perfect teaching language because there are many aspects to learning programming and the way you'd make those things easy aren't always compatible. "Typed" or not? Automatic or manual memory management? Pointers? ...

But when it comes to teaching the core idea of encoding an algorithm with lines of text, the main thing seems to be that the less syntax there is to think about, the better. Parentheses, brackets, semicolons, variable declarations, etc. are all in the way. We have two very good languages for this - Python and Lua. I much prefer Python for many reasons, some of which I explained earlier, but Lua also works very well.

The copy-paste issue is real though, I'll give you that. Modern editors (e.g. PyCharm) completely solve it, but when using less sophisticated tools, it is a pain. Still, I can't imagine teaching programming without indentation being an important part of it and Python conveniently forces you into it. Perhaps Lua with format-on-save would be better in this regard I might try that some day...



I disagree, but let me know if you have experience teaching someone python, Python is replacing say both "{" and "}" with one character a space.

When I teach my son I always tell him "when you open the ( or { always add it's matching closed one (if teh editor does not do it and only after you closed it you add your stuff in.

So for a for I teach him to start with for(){} then fill in the stuff. It makes sense to be more explicit. We did not have issues with types though, it makes sense that int and float are different things and you need to be clear about it.


I have taught a handful of programming intro classes in Python, JavaScript and Java (to mainly high school students). Java was by far the worst, since it has a lot of boilerplate that beginners just need to memorize, which is very discouraging. Starting off with types also made the lessons less focused, but I should've adjusted the pre-programming lessons to fix that. JavaScript was great for the first few programs where the automatic type casting let us have quick and satisfying results, but then the messiness of the stdlib made anything that wasn't self-contained (reading/writing files, drawing...) a pain. In both of these cases, students' code was utterly unreadable and issues were hard to find, despite in one case saying indentation was actually required (was that immoral?). I try to guide students to follow their drawn flowcharts along with the code to see where it goes wrong, but a lot of the time, their code was all over the place, which made that difficult.

With Python, that last issue was basically gone, since the layout of the code is the thing that instructs the interpreter. Getting the syntax correct wasn't an issue in either of the languages, but this time, correct syntax necessarily also meant nice layout. The students' code was much more similar and that made it easier to guide a large group through analyzing their code to find problems.

The way I transition students from flowcharts to code is through an intermediate "step list" notation that they're already used to from procedures they learn in chemistry and other lab classes, as well as generally in instruction manuals. That notation often uses nested (indented) sub-lists, which are almost directly copyable to Python. If I didn't have that step, perhaps the benefit of Python code layout wouldn't be as pronounced, but I think this way of teaching is generally beneficial, even when not targeting Python.

Some notes from the Python classes: the editor should be configured to turn tabs into spaces - no tab character should ever reach the file, even if copy-pasted (I'm 100% on team tabs, but they're horrible for beginners in Python). Skip "idiomatic" things that seemingly simplify code (open file contexts, "or default" expressions, ternaries...) and instead use longer versions - the less knowledge required the better, despite the resulting code being more "complex". Use f-strings and ignore string concatenation for as long as you can. The turtle library is your friend.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: