Friday, May 18, 2012
When I asked my social networks what they thought was the best language to learn to program with, most said Python. I've always heard great things about this as a first language, so I went along with it. But one person said Processing, a language / tool I have been using for a while. After learning a few basics of Python, I'm wondering if Processing really would be a better choice.
I started learning Python from the official beginner's guide (specifically, the Python Tutorial), designed for those who know how to program. They also have a list of tutorials for non-programmers, but I didn't look at any of those. Almost right away, I found myself thinking, 'Really? This is supposed to be easier for beginners?' The tabbing to define blocks, the somewhat frightening look of the official interpreter, the strange syntax with colons and range functions in loops... I just imagined myself saying, "Trust me, you'll understand this later" to an awful lot of things.
But, to be fair, I was looking at the documentation for experienced programmers. Maybe if I read a source for beginners I could see the value a bit more easily.
So I put a copy of Invent Your Own Computer Games With Python on my Kindle and started reading. This book aims to teach programming from the ground up in the context of games. Considering how most programming books work, this one seems to approach things in a more interesting way. Even still, the author has to pause from the context of the game being made and discuss the programming concepts for pages. And he still has to note that certain syntaxes are beyond the scope of the book, or that you'll understand some particular thing later on.
I thought Python was supposed to get rid of this problem!
You could argue that Python is a good choice because it lets you do things quickly. But I'd argue that Processing lets you do things even faster. That games programming book? So far I'm more than halfway through and nothing has moved beyond text-based games. But in Processing, your first program is almost certainly going to be entirely visual. I love that with very little code you can get up and running in Processing right away and have something feels like an accomplishment.
Furthermore, I think that the syntax of Processing is more straightforward in many ways. You can do a lot with some basic math, one or two types of loops, and standard method calls. You can add literally one line of code to your project and get a visual result right away (as seen in this beginner's tutorial). Yes, you will need to implement a method or two to really get going (setup and draw), but these actually make sense in a logical way, more so than the main of many languages.
It's true that Processing isn't interpreted like Python is, potentially introducing some issues with compiling. But the compile and run process is abstracted quite nicely with the play button, so it's not all bad. You can get errors in either type of language, of course.
I admit that I may be biased at this point since I'm not a Python expert yet, potentially making the comparison unfair. On the other hand, now is really the best time for me to analyze Python fairly given that I don't know it well at all, just like other beginners. Either way, I'll have a chance to learn more about how well Python works as a beginner's language as we work on our book on CS for beginners, since that's the language we've decided to include.