top | item 33752734

(no title)

au8er | 3 years ago

While learning, hiding details is important, but Python overdoes the abstraction. `for` loops and iterator based loops have been merged into one thing, and I am sure people write `for i in range(10)` without a good understanding of what the `range` function does. Even strings blur the line between individual characters and actual strings. The lack of clarity at these basic concepts is precisely why Python is not suitable as a first language, since it hides concepts that are prevelant in all other mainstream languages. As a result, I have often seen students develop bad coding habits and poor mental model of why their code works. Instead of learning proper programming concepts, they just know the syntactic sugar and abstractions that Python offers.

I do agree that Python provides a very small startup cost to writing code, the details are sacrificed to acheive this. This may be useful to capture interest/generate motivation and get a quick prototype/"helloworld" out, learning Python is only good for learning Python, not for programming in general.

discuss

order

nicoburns|3 years ago

Frankly I think classic c-style for loops are a terrible abstraction for beginners. Iterator based loops make sense on a high level ("I don't care how it works, I only care what it does"). And while loops make sense on a low level ("I can see how each piece works"). To a beginner, c-style for loops are just an obscure, implicit syntax for while loops.

> Even strings blur the line between individual characters and actual strings

IMO that's better than what C++ does, where it pretends that a character is a single byte. Whereas most code nowadays is using unicode, which means that code will break as soon as they try to store a non-ascii character in it.

last_responder|3 years ago

If you can understand the “for i in” part means then range should not be hard to grasp. I would argue that someone new to programming with even a modicum of logic might be able to guess what range does easily .

tragomaskhalos|3 years ago

Range is horrific for beginners. Try explaining to a kid learning coding why his times table program needs to say ```range(1,13)```. There are excellent reasons for this construction, and to prefer half-open ranges, but providing a good on-ramp for kids ain't one of them.