3 ms·
Python has its own issues. Magic `__foo__` methods everywhere. Significant whitespace (there are arguments for or against it, but it's bad for beginners). One-l
by jhpriestley 9y ago
Python has its own issues. Magic `__foo__` methods everywhere. Significant whitespace (there are arguments for or against it, but it's bad for beginners). One-line lambdas, `def wrapper`. Tuples versus lists, `(x,)` syntax. `global foo`. Ongoing split between 2.x and 3.x means that documentation is confusing.
I think ES5 would be a legitimately better first language. Now that ES6 is everywhere though, javascript is a really terrible first language, certainly worse than python... the online learning material for a `for` loop, for instance, is now split between `for(var ii = 0; ...`, `for(let ii = 0; ...`, `for(var x in obj)`, `for(const x of obj)` (but make sure that something called `webpack` is set up with something called `babel` so that all of these will actually work). You'll find similar confusion when approaching variable declaration, module imports, etc.
- cpburns2009 9y agoThe magic methods in Python are used to support common, built-in functionality. E.g., `__init__` is the constructor (you rarely need `__new__`), `__len__` supports the standard `len()` function, `__str__` is equivalent to JavaScript's `.toString()`, etc. Signification white-space should actually help students when programming because it forces code to be properly indented instead of having an indentation disaster or misplaced braces. One-line lambdas and decorator functions are no worse than JavaScript's. The tuple syntax is clunky, but there is an important distinction between it and lists: mutability of the list itself. Frankly no one should be using `global` without a very good reason. The split between 2 and 3 is hardly worth mentioning. 2 is the legacy version. 3 is actively maintained and most major libraries have supported 3 for a while. Very little changed syntax wise between them. The split was necessary because of a fundamental improvement and disambiguation between textual and binary strings.
- smsm42 9y agoSignificant whitespace won't be much of a problem for a beginner that doesn't have a precocieved notion about whitespace not being significant. After all, in humanwrittenspeechwhi tespa cematters, doesn't it? So the concept shouldn't be too hard to grasp. As for magics, don't see why it would be an issue either. For a beginner, it's a magic incantation just like any other, for more advanced student, it's a callback/override just like any other. You can argue that this system has its disadvantages, but if you understand enough to argue about such matters, your education as a beginner is a definite success. 2/3 gap is an issue, yes. Fortunately, one can just teach python3 and leave python2 for advanced studies. It's not like students would be deploying in industrial production right after the class...