I recently finished a series of three posts (here, here, and here) on how my background in Art History has influenced my teaching. Now I’m moving on to why I think Python is an excellent first choice of language for teens and adults.
What are characteristics of a great first programming language? Another way to phrase that question is “What is it we owe our students when we teach them to code?” For adult and teen students, I think there are five key things.
5 things students need from a 1st language:
- A great experience on Day 1. Much like the first page of a book, students need to be ‘hooked’ early on to have the excitement and curiosity to persevere in the face of the inevitable frustrations of learning something new. This can be especially important for those who haven’t been exposed to programming from a young age.
- The ability to (eventually) program on the Web. Increasingly, the Web is critical to the profession and craft of programming and students should have Web frameworks available when they’re ready.
- The ability to program desktop applications. While trends are moving more of what we do onto the web, there’s nothing like the immediacy of making and running your first local program.
- An eventually marketable professional skill. While academic or recreational programming is excellent, the skills we teach should also be usable in a professional context should students choose to use them in that way.
- A supportive and welcoming community surrounding the language. Once again this is crucial for those who haven’t had exposure to coding from a young age.
Other instructors or students might disagree on the correct desiderata for a first programming language. But in my opinion and experience there’s no language that excels on these five counts like Python does.
1. A great first experience
The traditional first program a user writes is something that prints the words ‘Hello World’. There are many other components to a successful first experience, but Python’s ‘Hello World’ is amongst the simplest of any language. Students can simply type this into the Python interpreter and press enter:
This example is interactive – try it yourself!
Python’s focus on readability makes it an excellent choice, especially when compared with languages like Java that have verbose and conspicuous syntax:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
After writing the program above, students must compile it and run it on the command line. The inevitable hiccups in doing so can convince students that programming is too hard for them. Students who typed in print("Hello World")
and pressed enter, meanwhile, are ready and have the confidence to learn more.
2. Web programming
Python is at home on the web, unlike a low-level language like C. Frameworks like Django, Pyramid, and Flask give students the ability to create real web applications that have the same power as the sites they use every day. Flask is my personal favorite for teaching because, in combination with a free Heroku account, students can have their own Simple blog deployed in under an hour. And adding their first route to a web app is simple as well:
@app.route("/about")
def about():
return render_template("about.html", now=datetime.datetime.now())
This code isn’t trivial but is readable by students after only a few sessions. Knowing how to route web applications in even the most basic way is a huge step forward in terms of confidence and curiosity. Read more about the Simple blog and how to teach with it here.
3. Desktop applications
Languages like PHP or Javascript that are designed for the Web limit students to web development, while Python is also at home on local machines. Pygame, wxPython, and other libraries for windowed programs let students explore building and running their own desktop apps. Katie Cunningham has written what I’d consider to be the definitive guide on teaching with Pygame. I’ve used Pygame to teach teens and graduate students and it’s tons of fun. Here’s a game called Starpusher I’d recommend for teaching:
The game is available from pygame.org here or I’ve included it in a Github repo here. It also comes pre-installed on Raspberry Pis.
4. Professional skill
Unlike teaching languages like Scratch or Logo, Python is used extensively in the professional and academic communities. It’s a language that students can both start with and grow into. Students who need to go lower level will find a tight integration with C. Students who want to explore another high level language like Ruby will find the transition smooth. Students who want to take tighter control of their Web applications will find that Javascript skills mesh nicely with Python Web frameworks. And students who want to explore paradigms like Functional Programming will find they can do so without learning a new language.
Most importantly, though, students who have a good experience with programming from the start will have the dedication and curiosity to evolve their professional skills as best fits their goals.
5. Supportive community
I’ve written before how Code is Cultural. This is no more apparent than when students are attending meetups, as mine are required to do (more about that here). The Python meetups are inevitably the most welcoming, which makes them the perfect place for beginners to learn the ropes and meet future colleagues.
As an example of where the rubber meets the road is the Turtle module, built in to Python, which provides an easy and effective way to teach the basics of Python visually. The Turtle metaphor was first used by MIT’s Seymour Papert and others in the late 1960s and informed the design of the Logo language. In this talk you can see an introduction in 2009 of the new features of the module. trinket makes the turtle module easy to use and teach with; see more about this in the interactive example on our homepage.
Get teaching with Python!
My next post will be all about the best interactive resources for teaching Python. In the meantime, I made a list below of resources the community has provided for beginners as well as posts from others describing why Python is a great first language. Hope you find it useful!
- The Python Software Foundation maintains a Beginners Guideand Tutorial, which are both characteristic of their support of those new to the language.
- There’s a Special Interest Group for Python Education
- There’s a great set of links to great Audio-Visual resources kept on Python.org.
- A research paper on transitioning from Java to Python at a University. *Thanks to UNC masters student Michael Head for this one.*
- Lifehacker article where Python took first place in a reader poll on the best first language.
- Jessica McKellar’s recent PyTennessee keynote laid out the case for Python education in schools and several specific action steps we can take to support it.
- The Hello World Program‘s take on why Python is a great first language.
Also, tools like IPython notebooks make it much easier to teach python.
You’re exactly right! They’re one of our 3 favorite Python teaching technologies: http://blog.trinket.io/interactive-python-tools/
javascript/html/css can be used on the desktop just like python. Also PHP is a much better language that also can be used to program desktop applications.
These are great reasons, Elliott. There are many worse languages than Python to have as a first one, and Trinket goes a long way to make it as available as BASIC was on the 8-bits.
No language is perfect, though. With Python/trinket, there’s still a bit of explaining to do:
· Why does it think a student’s name is a syntax error if they are called Zoë or 지훈? ASCII isn’t for everyone.
· If you’re first taught that 3 ÷ 2 = 1½, there’ some unlearning to do when faced with Python’s 3 / 2 = 1.
What you say about division is true under Python 2.6. Under Python 3, 3/2 = 1.5 (int/int = float). See http://www.informit.com/articles/article.aspx?p=1439189 .
You’ll be glad to hear the syntax changed in Python 3.x.
so 3/2 = 1.5 and 3//2 = is the old integer rounding.
Yes, but I was talking about trinket, under which 3/2=1. Python 3 has broken/threatened deprecation of too many things I find useful (f”rinstance: print as a command, % and C-compatible(ish) formatting, ‘*’ for grouping) that I won’t use it.
And don’t forget micropython for embedded microcontrollers. So you can write in the REPL from your computer while the program runs on the embedded cpu, like an interactive Arduino but in Python. Yay Python.
http://micropython.org/
That’s really neat! Hadn’t seen that before
As you can program hardware by usb com port – maybe trinket coudl be used in this way directly to program and interact with pyboard ?
Contact Damien at micropython – or on forum – to see if its useful to do.
Python is a great language because of its simple grammar. Its formatting requirements cause my students to become accustomed to associating formatting with the logical structure of their programs. As a result, they have good formatting habits when they learn Java and C.
Python is a amazing programming language, here is a link to something i programmed in it, 😀
http://www.revealed.xyz/programming/torrent-scraper-python!/
its easy to use, free and best of all open source
here is my view on python
http://www.revealed.xyz/programming/why-python-is-the-best-programming-language-for-beginners/msg58/?topicseen#new
Enjoy your python 😀
Thanks for your informative article on software testing. Your post helped me to understand the future and career prospects in software testing. Keep on updating your blog with such awesome article.
Python Course in chennai
I also started Python Language as my first. It’s awesome. I also
started my website for Python Programming. Have a look –
http://pythonlovers.net/
Python is a good first language because it’s easy to learn, teaches good coding style, etc. But if you’re going to be seriously getting into web programming, just learn a web coding language like php. (Along with xhtml/css/javascript etc.)
First AND last language. It’ simply the best and cleanest language, very powerful. There’s a reason most penetration testing applications are written in it.
Python has genuine compactness highlights and can be utilized over a large number of stages; its adaptability and extensibility make it cherished by developers….Thanks for sharing these types of informative…
Hi, I am trying to solve an issue with the movement of the code and would love some helphttps://trinket.io/python/d42f313749
Hi,
Very useful article. Your post helped me in to choose python for build desktop applications except using php.
Easy to learn.
Thanks for sharing useful information Here.