5 ms·
I help beginner python students. Python might be a nice easy scripting language for bashing out NUMPY scripts, but I'm beginning to suspect it is terrible for t
by bee_rider 6y ago
I help beginner python students. Python might be a nice easy scripting language for bashing out NUMPY scripts, but I'm beginning to suspect it is terrible for teaching. The "what type is this variable, and will this function automatically convert it for me" game is not very fun at all for beginners.
- dTal 6y agoI agree that Python is a bad language for beginners. It is conceptually heavyweight and full of opaque behavior. We lost a lot when BASIC stopped being the "standard" introduction to programming.
- Blikkentrekker 6y agoI feel that Python will be known in the future as the language that caused a generation to have a crippled sense of reasoning about how to design computer programs. It's lack of a normal, standard scoping model alone teaches a very flawed reasoning about computer programs.
- goatlover 6y agoI'd vote for Javascript over Python.
- Blikkentrekker 6y agoJavascript is not so often used as a teaching language. There are many languages which hammer worse practices than either such as POSIX shell scripts, but they are seldom used as a teaching language. Python is in the unique space of having made horrible design decisions but somehow often used as a teaching language. One would assume that programmers are to understand such concepts as block scoping rules and the difference between lexical and dynamic variables. — how is Python to teach them that?
- rsj_hn 6y agoJavascript is too weird to be a teaching language. Lexical scoping, invisible and sometimes unintuitive conversion rules, challenging runtime environments, and asynchronous code are important concepts but I wouldn't put them into an intro to programming class. IMO the ideal programming track would be as follows: Intro to programming track: * Assembly --> to understand the basics of how computers work and learn simple procedural and abstraction rules. * C --> more procedural code, more abstractions, and higher order memory management * Java --> to learn interfaces, object oriented code, and an introduction to functional programming concepts like lambdas, pure functions, the value of immutable objects * {Racket/LISP or Favorite functional language} --> to gain intuition with more pure functional programming Then, I'd have separate tools track: * web dev * database * embedded dev * AI, etc. Then a separate theory track: * context free languages, regular expressions, compiler design * algorithms and data structures * some network theory and fault tolerance results Then I'd have a professional track: * tools: learn source control systems, IDEs, debuggers, profilers, bug management systems, different dev systems, using Jenkins or other CIT tools. * skills: learn about secure coding (best practices for writing auditable code with known failure modes), efficient coding (calculating big O for a given code, fixing performance bottlenecks), maintainable coding (best practices for decoupling code, writing testable code, writing unit tests) * theory: track where you learn advanced algorithm theory, design patterns, hopefully centered around case studies. With elective tracks for things like OS theory, networking, etc. Too many people leave college with lots of information about data structures and algorithms but don't know how to write a unit test, how to use an IDE, how to write unit tests, how to write secure, maintainable code.
- adrianN 6y agoI really don't think you should use C as a teaching language. There are way too many pitfalls, and using libraries is quite cumbersome.
- rsj_hn 6y agoI wouldn't program production code in C if I could avoid it. But sometimes you can't avoid it, and I wouldn't program production code in Pascal, either.
- nerdponx 6y agoIt's lack of a normal, standard scoping model alone teaches a very flawed reasoning about computer programs. Scoping in class definitions is weird, yes. But is that your complaint? What's wrong with the scoping model in general?
- Blikkentrekker 6y agoIt's not merely that. That for-loops work by assignment rather than creating a new scope, or that if-conditions do not create a new scope for their arms is most unusual. Not only does it not teach programmers to properly reason about scope, but it results into subtle bugs that are easy to miss. Consider the following: list = [] for x in iterator: list.append(lambda y: some_code_that_closes_over(x)) This almost certainly does not behave as the programmer intended, for the for-loop does not create a new scope, so all iterations of the loop share the same scope, and thus every closure that closes over `x` handles the same `x`, which will have the value that `x` had at the last loop, thus effectively mutating the closure after appending it to the list, so that the list will only contain effectively identical closures. The proper way do it is by using the fact that functions do create a scope: list = [] def loop_function(x): list.append(lambda y: some_code_that_coses_over(x)) for x in iterator: loop_function(x) Certainly code that looks quite hackey to work around the lack of normal, expected block scoping.
- bb88 6y agoHow about not using lambdas which create accidental closures all over and use partial functions, instead? list.append(functools.partial(some_code_that_closes_over, x)) If you replace a lambda with a function definition in the for loop, it's easier to see the scoping issue is actually a closure. And that makes sense because lambda is shorthand for a function.
- Blikkentrekker 6y agoBecause the code that closes over can be arbitrarily complicated. I simply used code that only called a function with a single argument as a minimal example. Apart from that, your code technically does not do the same thing as it calls the inner function with two arguments, whereas mine simply discards the second argument.
- fulafel 6y agoBeginners to programming don't agonize over variable types, they don't have the mental model of statically typed language in their head.
- DanielMcLaury 6y agoThey may not have "a mental model of statically typed languages," but they sure "agonize" when there are eight different incompatible datatypes that represent a datetime and the library functions they want to use don't even specify which of these they take or return.
- fulafel 6y agoIt's true that compulsory static typing can mitigate documentation bugs. But the effect isn't significant in the programming beginner experience.
- bee_rider 6y agoThey might not "agonize over variable types," but they do encounter agony when they try to add a string to an integer.
- fulafel 6y agoYes. But statically associating types to binding names does not relieve them of making and fixing these mistakes, it just makes it a runtime vs compile time error.