4 ms·
I've been teaching programming to many people, for many years. The majority of my students are experienced programmers, but no small number are new to programm
by reuven 13y ago
I've been teaching programming to many people, for many years. The majority of my students are experienced programmers, but no small number are new to programming beyond very simple stuff. I've found that Python has a number of aspects that are ideal for first-time programmers:
- It's dynamically typed. Say what you want about static vs. dynamic typing, but this is one less thing that newbie programmers have to get right. There's no chance of an error when they say "i = 'abc'", if you've defined i to be an int.
- It's interactive. The fact that you can "play" with the language within the interactive shell is a huge selling point. IPython and the IPython Notebook are easy to get working, and for people to work with.
- Python's restricted command set and simple, regular syntax let you concentrate on ideas: Yes, many newbies to Python (and to programming in general) get confused by indentation, blocks, colons, and the like. But they're going to get confused by the syntax of nearly any language. Python has a simpler syntax than most other languages, meaning that there's less to learn, and less to remember. This lets the new programmer concentrate on the ideas that they're learning, or the implementation of what they're doing.
- It's cross platform. The fact that people can use Python on any computer they like is a big selling point.
- You can easily teach object-oriented and functional-style programming. Python is obviously object-oriented, but can also be used to introduce functional programming. In this way, you can expose programmers not only to multiple paradigms in Python, but also in other languages.
- You can use it for real applications. People are often surprised to discover that real-life applications are being written and used in this language that they're learning, which seems so simple.
I'm sure that there are more reasons than these. But let's consider the alternatives that the article suggested:
- I would be hard-pressed to think of a worse first language than C. You want to introduce people to the concepts of programming, which means abstractions and high-level thinking. C forces you to think in terms of the computer and its memory, which is just the opposite. The fact that it's compiled to binary form, that you don't have an interactive C shell, and pointers are just three reasons why I think that C would be a very bad choice. Sure, everyone should learn C at some point -- although I often point out that I'm a much happier person since I moved to dynamic, high-level languages many years ago -- but if you want to teach the concepts of programming, C is going to require too much learning just to get simple things done.
- JavaScript has many good points for beginning programmers -- but the chief problem, in my mind, is the language's syntax, which is far too inconsistent and forgiving/flexible for newbies. I think that someone coming to JavaScript from Python will have a very easy time; the mapping of data types is fairly straightforward, and even the notion of passing functions is pretty easy to get. But the learning curve in JavaScript seems steeper to me than in Python, despite the obvious advantages of being able to work within a browser.
- bliti 13y agoIt is also not very verbose (most of the time (I'm looking at you list-comprehensions))
- deleted 13y ago[deleted]
- cjfont 13y agoThe use of list comprehensions is optional, and would probably not be covered in an introductory course anyway.
- the_af 13y ago> There's no chance of an error when they say "i = 'abc'", if you've defined i to be an int. Probably you mean no chance of a compiler/interpreter error, because the program almost surely will not do what the rookie meant, much to his/her surprise. That's an error in my book :) I agree with the rest of the benefits of Python as a beginner language.
- vorg 13y ago> I would be hard-pressed to think of a worse first language than C. You want to introduce people to the concepts of programming, which means abstractions and high-level thinking. C forces you to think in terms of the computer and its memory, which is just the opposite. People should learn two programming languages at the same time, a very high level one such as Python, and a very low level such as C. Combining the top-down and bottom-up approaches to learning, simultaneously, yields the best results for most people. While learning Python, someone can begin to look inside the abstractions and get a feel for algorithmic complexity and such stuff. While learning C, someone can see how to use it to build an OS such as Linux.
- reuven 13y ago> People should learn two programming languages at the same time I find this completely impractical. Programming is hard for people to learn. They're juggling all sorts of new concepts and ideas. It's hard for them to remember the terminology, the data structures, the ways in which functions work, or even when and if they should use functions. Teaching them two languages simultaneously would be far more confusing than helpful. I'm all in favor of learning different approaches and different languages. But for someone without any background to learn two languages simultaneously would be making it more difficult, not less.