IDLE Reimagined

I’ve started a wiki for an IDLE redesign project: http://idle-reimagined.wikia.com/wiki/Idle_Reimagined_Wiki

If you would like to help, please join the mailing list: https://groups.google.com/forum/#!forum/idle-reimagined/

IDLE Reimagined mockup screenshot

From the wiki:

IDLE Reimagined is the code name for a redesign for Python’s default IDLE editor with focus as an educational tool. IDLE’s chief utility is that it comes installed with Python, making it simple for newbies to start programming. But professional software developers don’t use IDLE as their IDE. Instead of turning IDLE into a sophisticated IDE for professional software developers, it can be tooled with features specifically to make it friendly to those learning to program.

Prime Directives for the new design:

  1. IR is designed not for experienced developers or those new to Python, but specifically for those new to programming.
  2. IR is meant to be a drop-in replacement of IDLE, and be installed with the default Python installer.
  3. IR’s code will use the tkinter GUI toolkit (unless a better GUI toolkit is bundled with Python).
  4. IR is fully-featured offline, but also has features for finding help or sharing code online.
  5. “Simple is better than complex.”

These are the features that will distinguish IR and make it a good candidate to replace IDLE:

  1. Single window design, with file editor on the upper pane and interactive shell on the lower pane. (No more confusing separate windows for shell & file editor.)
  2. Tabbed file editor.
  3. Foreign language support. (Though Python’s keywords and standard library will still be in English, IDLE itself can be multi-lingual.)
  4. Tutorial plugin system for Codecademy-like tutorials.
  5. Integrated pip installer.
  6. Integrated pastebin feature. (Easily share code with those who can help you.)
  7. “Plain English” error message translations. Instant Google-search for error messages.
  8. Detects and warns if you are trying to run Python 2 code on Python 3.
  9. Lightweight real-time lint tool that will point out missing variables and syntax errors. (Checks for errors, but does not check for style or PEP8.)

Read More

Call for Translators for 3rd Edition of “Invent with Python”

Work on the 3rd Edition of “Invent Your Own Computer Games with Python” has begun, along with translations of the book to Spanish, French, Chinese, and Swedish all foreign languages (these were just the languages that have been started, but I appreciate translators of any language). The 2nd edition came out in 2010. Since then, I’ve written three more books and gained experience from teaching programming to kids and adults. The 3rd edition will not have new content, but has two major aims:

  • Renewed copy editing efforts to make the text easier to read (especially for younger readers) and reduce the word count by 20%.
  • Translate the book into other languages through volunteer efforts.

I’m currently looking for volunteer translators of all experience levels to commit any amount of effort. Please contact me at [email protected].

The translation efforts will be coordinated on the GitHub repo for the 3rd edition. Even if you do not have experience using git, I can work with you to get your translations checked into the repository.

All proceeds from sales of translated books of “Invent Your Own Computer Games with Python, 3rd Edition” will be donated to the Python Software Foundation.

These proceeds will be published on GitHub.

I make similar donations to the EFF, Tor Project, and Creative Commons nonprofits from sales of my other book, “Hacking Secret Ciphers with Python”. I publicly post an accounting of these donations.

All translators will get attribution credit on the book cover, in the PDF, and on the website.

I appreciate the efforts of the translators to bring programming knowledge outside of the English-speaking world. I want them to know that I do not plan to personally profit off of their labor.

Read More

No, Seriously, Why Should I Learn to Code?

The geeks have inherited the earth. A couple decades ago if you talked with friends in a chat room, you were cast as a socially-awkward nerd. Doing the same today just means you’re a typical Facebook user. Broadband Internet connections and smartphones have taken the Information Age that technically started in the 1970s with PCs and pushed it into daily mainstream life.

Along with this culture change is a social anxiety: Should I learn to code? Is coding the new literacy? Will I program or be programmed? This is not a new anxiety. Here’s a New York Times article, Personal Computers; Does Everyone Need to Learn Programming? It was written in 1984.

Like with all panics, entrepreneurs and pundits (including myself) come out of the woodwork to offer their opinions or push their products. Software developer Jeff Atwood gives a plea to not learn how to code (a position I sharply disagree with). There are many websites and bootcamps (ranging from free to overpriced) to teach beginners programming. Most of them (in my opinion) are terrible.

Don’t get me wrong: You should learn to program. But lost in this hype is a plainspoken reason: NO, SERIOUSLY, WHY SHOULD I LEARN TO CODE?

Here are bogus reason you should learn to code that you’ll find in most everyone-should-learn-to-code rhetoric:

  • To become a software engineer and make six-figures. If you are interested in becoming a developer, by all means follow up on it. But if you enjoy your current career, you don’t have to leave it. The world needs more than just software developers.
  • To make the next Facebook or Flappy-Bird and become a millionaire. Most startups fail. Software startups require much more programming skill than a run through of Codecademy can provide, and programming is not the most important skill to have when starting a business.
  • To build critical-thinking and problem-solving skills. Ehhh… sort of. But people who give this reason often leave out what exactly that means or why coding provides it.
  • You can put in on your resume. Ehhh… again, true, but how coding applies to most non-developer jobs is left unstated.
  • To build a website. HTML is not a programming language, and web design is a different skill set to coding. But anyway, if you just want a website presence, sign up for a free WordPress blog.
  • Because other people are saying you should. This is a terrible reason to do anything.

Before I go into the real reasons you, your friends, your neighbors, your cat, and everyone should indeed learn to code, consider this anecdote:

A math teacher is giving a lesson on logarithms or the quadratic equation or whatever and is asked by a student, “When will I ever need to know this?”

“Most likely never,” replied the teacher without hesitation. “Most jobs and even a lot of professions won’t require you to know any math beyond basic arithmetic or a little algebra.”

“But,” the teacher continued, “let me ask you this. Why do people go to the gym and lift weights? Do they all plan on becoming Olympic weight lifters, or professional body builders? Do they think they’ll one day find an old lady trapped under a 200 pound bar bell and say, ‘This is what I’ve been training for.'”

“No, they lift weights because it makes them stronger. Learning math is important because because it makes you smarter. It forces your brain to think in a way that normally it wouldn’t think: a way that requires precision, discipline, and abstract thought. It’s more than rote memorization, or making beautiful things, or figuring out someone’s expectations and how to appease them. Doing your math homework is practice for the kind of disciplined thinking where there are objective right and wrong answers. And math is ubiquitous: it comes up in a lot of other subjects and is universal across cultures. And all this is practice for thinking in a new way. And being able to think in new ways, more than anything, is what will prepare you for an unpredictable, even dangerous, future.”

Learning to program a computer, even if you don’t plan on becoming a software engineer, has three similar reasons to pursue it:

  1. Learning to code is also great practice for precise, disciplined, and abstract thinking. A program either works, or it doesn’t. It could have bugs, straightforward or subtle, that require analysis and concentration. But unlike math, a program does something immediately practical. (Mathematicians, please don’t shoot me for saying this.)
  2. Programming transforms your computer from a home appliance to a power tool. Whether you have an office job, are a student, or just go online a lot, people use computers to get stuff done. But some tedious, lengthy computer tasks are so specific or context-dependent that no one has produced software to do it. (My next programming book addresses exactly these kinds of problems.) Even without deep programming knowledge, coding becomes a large productivity multiplier. Computers are everywhere; they should be tools, not appliances. A tool is something you sharpen, an appliance is something you replace.
  3. Learning to program is great practice for learning itself. Professional software developers use Google daily to answer questions or find documentation for their work. During the course of coding you will come up with several questions that will require you to seek out an answer. Googling is a skill in itself: figuring out which keywords to use, identifying useless advice and generic platitudes on content-farm sites, knowing how to ask a question. (The last one is so complex it has its own 24-page FAQ.) These aren’t arbitrary word problems or Sudoku puzzles you are answering. Learning to code involves learning how to find real help for yourself.

Cory Doctorow wrote an article that even before learning to code, we should be teaching kids how to use regular expressions. “Regexes” are ways to specify a pattern of text. Your word processing software most likely lets you use regular expressions for its find-and-replace feature. Regular expressions can be used for an app’s search feature. This is a skill that magnifies your power as a user. And once a populace is literate in regular expressions, software developers will increasing make use of them in more capable and powerful apps.

The same can be true with programming. Imagine what software could be like if the populace were literate in basic programming. Instead of apps, we could have APIs. Users could tie together the different services and programs they use. It would tear down the walled-gardens that Facebook, Apple, Twitter, and Google have erected to maintain their monopolies. It would pave the roads for improving the Information Age the same way the printing press improved literacy.

There are plenty of skills people can learn to become well-rounded human beings: Playing an instrument, public speaking, budgeting, first aid, growing plants, persuasive writing, babysitting, identifying scams, et cetera, et cetera.

But programming is unique among these skills. Programming is a practical skill on a tool you already use every day. Learning it provides abundant, but not pointless, intellectual hurdles to train your brain. It can save you time on computer-based tasks while opening your eyes to accomplishments that were previously unfeasible. That is why you should seriously learn to program.

Read More

Free Physical Books with Amazon Review

UPDATE: I’ve had to stop this offer since I’ve been flooded with emails! Thank you so much!

I’m mailing out a free copy of my books to anyone who writes an Amazon review of my books (available online for free at inventwithpython.com). This is no-strings-attached: even writing a 1-star review will get you a book. Due to shipping costs, this offer is only available to US residents for now.

(UPDATE: And to clarify, the book would be sent out after your review is posted. The ebook versions are freely available and identical in content to the physical books. Due to the low response rate when I’ve previously sent out review copies first, I can’t really afford to send out books before the reviews are written. Sorry.)

The process is:

  1. Have an Amazon account, or someone who can post your review on their Amazon account.
  2. Send me an email to [email protected] to tell me you intend to write a review and of which books.
  3. Read the book! Free ebook versions can be read at inventwithpython.com. Take your time, there’s no deadline to read the books, but within a month or two would be nice. Or, if you’ve already read the books, just go ahead and…
  4. Write a review on Amazon at least 200 words. Give it an honest rating.
  5. Email me again with a link to the review and your mailing address.
  6. I’ll mail you the physical book, no matter how high or low your rating and review were.

I can send out a max of one copy of each book you write a review for, but you can write reviews for as many of the books as you want. Thank you very much in advance!

Invent Your Own Computer Games with Python, 2nd Edition [PDF]

Making Games with Python & Pygame [PDF]

Hacking Secret Ciphers with Python [PDF]

Read More

“Let’s Create Software” Tutorial: Bus Routes Overlaid on Google Maps

The “Let’s Create Software” series covers the creation of small, complete software projects from start to finish. The entire process and code is explained to give beginner and intermediate programmers an idea of what it is like to not just program, but create an entire piece of software from scratch.

There’s a large PDF system map of all the Muni bus routes in San Francisco (as well as maps of the individual Muni routes). If I need to find directions, Google Maps’ mass transit instructions are fine. But sometimes I’d like to just browse all the routes throughout the city. However the large PDF is slow to render on my laptop (moreso on my phone). Scrolling the PDF also results in a lengthy wait for redrawing.

So I had the idea to use Google Maps’ API to draw out a map of all the Muni routes. This would have the benefit of the system map PDF but also be easier to load and navigate. I have no experience using the Google Maps API and am vaguely aware that there’s public data about Muni bus routes, but I’ll learn along the way.

The completed SF Muni Google Map.

To follow along with this tutorial, it helps to have a bit of Python or JavaScript knowledge, or know a little bit about programming. I’ve tried to keep this as straightforward as possible, even for non-programmers to roughly follow.

This project will involve writing a few “throw-away” scripts to parse and extract data, and my preferred language is Python. While I do all the scripts in Python 3 (note: Python 3 has some backwards incompatibilities with Python 2. My scripts might not run on Python 2), you can use whatever language you like. The final software will be done with JavaScript since it is a web page that uses the Google Maps API. (The final result is here: http://inventwithpython.com/sfmuni/

In general, by “throw-away” script I mean a script that is written in order to be run once to perform a task. Software such as Firefox or Angry Birds I want to keep around to run again and again, but a throw-away script I just need to automate a certain task. I’ll still keep this script; I won’t actually delete this script once I’ve run it, but I most likely won’t ever need it again.

A note to beginning programmers who might feel like this project might be too advanced for them: even though I have years of experience programming, I still made many mistakes and went down a few blind alleys while putting this code together. Although it looks like I just sat down and typed out this code, just remember that this tutorial is the polished outcome of quite a bit of tenacious work. Don’t be discouraged or intimidated, just keep at it!

(more…)

Read More

Why Is HTML Not A Programming Language?

HTML is not a programming language. While some may point out that HTML is a “markup language”, this doesn’t clarify how that is different from a programming language. I’d like to provide a simple reasoning that is easy to understand by the layperson. (This isn’t meant to be a thorough argument, but rather a brief explanation that goes just a bit more in detail than “HTML isn’t a programming language but instead a markup language.”)

Here is a point I’d like to make: HTML is no more a programming language than Microsoft Word is. With Word (or any other word processor software), you can write out text and format it with different fonts, sizes, and colors. Images and tables and bullet points can be added as well. This is all done through the word processor’s graphical user interface.

An HTML file is similar, except it does not have a GUI. Instead, it is entirely written out in plaintext, so all the formatting instructions must be typed out as HTML tags (for example, <b> or <center>.) This “language” of tags is how we can format the appearance of a webpage.

Programming languages, on the other hand, can process data and make decisions. You can store data such as text strings and integers, and then manipulate these values to perform calculations. For example, doing some math or sorting text alphabetically are kinds of data processing that you cannot do in HTML.

Programming languages can also make decisions about what instructions they should execute. Depending on if a certain condition is true or false, a set of instructions may be executed or skipped by a program. Here is a Python example of such code:

if password == 'rosebud':
    print('Access granted.')
else:
    print('Access denied.')

Programming languages also have ways of executing instructions over and over again in loops. Loops, if-else statements, and other such instructions are called flow control statements. All programming languages have these flow control statements, but HTML (and Microsoft Word) do not.

JavaScript is a programming language. It has all these features of flow control and data processing. While JavaScript is used in many web pages, it is a distinctly separate thing from HTML. You can write HTML without JavaScript, and you can write JavaScript code without HTML.

Because HTML lacks these features, it cannot be called a programming language. One does not “program in HTML” nor could one “write HTML code”. You should never list HTML on your resume under “programming languages”.

The difference is not just a snobbish opinion of elitist software developers. While this post is by no means the definitive and complete reasoning of what a “programming language” is, it is good to know the general difference between a programming language and HTML.

Read More