Every time I do a user test with a beginning programmer, I remember how hard computers are, how unforgiving the tools are, and end up wanting to apologize for how annoying and strict programming is. We are making progress with teaching people how to code, but it's still really hard.
For example, if you are just getting started with Python, here's a short list of problems you might face when trying to set up Flask, which is by far the easiest Python web server to set up.
- Learning how to cd in the terminal
- How URL's requested by a user map to actual code
- How to read and write things from a database
- Installing Flask, so learning how to use
- Python telling you your file is no good because it mixes tabs and spaces.
- How to run Flask locally
And that's not even counting the stuff that's so obvious to us we forget to mention it. Most quickstart guides also fail to help people make incremental progress.
Game designers are great at teaching new, hard things. They have to be, or no one will play their games. You will notice that games don't start with you battling Ganon in an epic death match; they start with you learning how to use the character and perform actions like make a kick, or open a door. Through a series of incremental successes you become an expert in the game and can tackle more and more complex tasks.
It bugs me to see so many Python tutorials mention
virtualenv as a requirement
to get started. (
virtualenv is a tool for sandboxing your Python apps, so
each Python project on your computer is using its own set of packages). The
biggest advantage of
virtualenv is that you can have different versions of the
same Python package (like Flask or requests) that are required by different
projects, whereas if you install them system-wide you can't.
virtualenv just adds another thing you have to do
before you can see pretty lights on the screen, and represents another possible
opportunity for people to lose interest, and start doing something else instead
of learning how to get a web server set up.
It also introduces a significant opportunity for confusion; the "It was working
yesterday, why isn't it working now?" problem. You need to remember to source
virtualenv file in every Terminal shell where you're running Python, or
your terminal will tell you it can't find the library you literally just
installed. Needless to say this is confusing, the Terminal won't tell you
how to solve the problem, and Googling for the answer isn't likely to give you
the solution you need, because it's such a generic error message.
I've never seen beginners run into the problem of needing conflicting
versions of a Python package for two different projects. I was comfortable
dumping everything into site-packages for over two years of Python development;
only when I started working at Twilio did I need to start installing
virtualenvs for every project.
As a community, I believe we should stop recommending that beginners install
virtualenv. The faster we can get beginners to a Holy Shit, I Wrote Code That
Made Something Happen moment, the better, and
virtualenv is a big block for
getting to that point. Instead I'd recommend installing
pip using the one
line curl program in the second paragraph here.
virtualenv is something
that's more appropriate to learn about and use once you have a few Python
projects under your belt.
Liked what you read? I am available for hire.