Python is the new BASIC.

This is the basic problem with learning how to program computers these days:

public class Hello
{
    public static void main(String[] args)
    {
        System.out.println("Hello World!");
    }
}

The above is the Hello World program for Java, arguably one of the most popular programming languages. Encapsulated in the above three lines are several different concepts ranging from static functions to return types to stdout and to the entirety of object oriented programming in general.

Below is the Hello World program for BASIC:

10 PRINT “Hello World!”

One line. Simple. Back in the days of the Commodore 64, simple software was forgivable, it was expected. The expectation that computer programming is achievable by kids and mere mortals still existed. And BASIC came with most home PCs as well. Writing simple programs and games was a large part (or at least, larger part) of owning a computer.

These days, with physics engines, 3D graphics, MMORPGs, and professional artwork, that expectation is gone. Text-only games with ASCII art are considered obsolete, and the replacement for BASIC has mostly been game creation kits that offer drag-and-drop, point-and-click interfaces to tie together multimedia elements into games that mostly follow fit the same genre. Behind all the graphics and menus and wizards, the art of programming is lost.

The replacement for BASIC has been clumsy at best. How do we introduce fancy GUIs, graphical animation, and ‘splosions to beginner programmers? Visual Basic? HTML/Javascript? Some random, closed source “4 kidz” programming language whose company will fold in three years? NO!!! You can’t be serious!!!

That entire approach of Big Complexity Up Front fails entirely. Forget classes and interfaces. Forget graphical user interfaces. Forget clip art and animated GIFs of flaming skulls. The answer has been in that 10 PRINT “Hello World!” line the entire time. We need the same old style of programming that the C64 generation grew up with: simple textual input and output, created through line-by-line programming. What it lacks in graphical sophistication it makes up for by directly relating the textual input/output and the data values the program handles.
Of course, even if you did find a pirate version of Qbasic 4.5, that doesn’t mean you should use it. GOTO is considered harmful, and the lame IDEs and limitations of BASIC make it outdated from a technical perspective. So what is to replace BASIC?

Python is the new BASIC.

Python is the perfect candidate. Python has a gentle learning curve, a readable syntax, and HELLO WORLD is one line long. The “batteries included” aspect leaves plenty of room for expansion for advanced students, with a solid community and third-party libraries. Python can start with simple textual input/output, then graduate up to object oriented programming, then incorporate GUI toolkits and network programming. Python, in the educational context, scales. Yet Python is a serious language used professionally by Google, NASA, et al.

What about the other languages?

  • Visual Basic is not the new BASIC. Weird syntax, the combination of the GUI designer + written code, the Windows-only platform, and the large rift between VB 6 and VB .NET makes Visual Basic a poor candidate.
  • HTML, CSS and JavaScript are not the new BASIC. Learning a markup language, DOM architecture, and cross-browser dependencies make DHTML a poor candidate.
  • PHP is not the new BASIC. Combine the HTML/CSS/JavaScript arguments above, and throw in setting up Apache and a thoroughly bloated namespace. PHP is a poor candidate.
  • Perl is not the new BASIC. A great language for sys admins, not so much for beginners. Perl would be a distant second to Python as a replacement for BASIC. There’s More Than One Way to Do It, and most of them are unreadable, unless you are The One, in which case you can plainly see blonde, brunette, redhead…
  • Java is not the new BASIC. Hey, it’s better than C++, but that really isn’t an excuse. Java is great for applications development, but not so much for students. The initial learning curve for this (99%) pure object oriented language is huge, and even most Java programmers don’t overcome it (hence why the Singleton design pattern sees so much use.)
  • Flash and ActionScript are not the new BASIC. A huge financial cost up front, a proprietary format, and many of the same problems with Visual Basic’s GUI editor make Flash unbearable as a replacement for BASIC. Photoshop is not a programming language.
  • Ruby probably is not the new BASIC. Ruby and Python are very similar, and I can’t discount it because I don’t know Ruby. But Python’s community and libraries are far wider than Ruby’s, and thus preferable for the beginner.

Even if you prefer the GUI, pyglet, pygame, wxPython or any of the other graphics engines or GUI toolkits are available.

20 GOTO 10

Alas, the classic books that demonstrated games programming in BASIC such as the old Atari books are long gone. So where does a computer newbie or geekish 9-year-old learn Python programming? You can start with several books, but I would like to plug mine. “Invent Your Own Computer Games with Python” is a free book distributed under a Creative Commons license. Unlike other Python programming books, instead of teaching programming principles and concepts and leaving application up to the reader, each chapter of IYOCGwP (eye-yawk-gwip) presents a different game’s source code, and then explains the programming principles straight from the examples. All the games are text-based with ASCII graphics, and the longest is just 400 lines (including whitespace). Give it a look at http://inventwithpython.com

I’m also constantly seeking feedback for future versions of the book, so please contact me if you have spotted something or have some advice/criticism.

EDIT: I think I misspoke when I said Perl was a distant second. I think that if Perl were a distant second, then Ruby would be a closer second. I don’t know enough Ruby to make a definitive Python-wins-over-Ruby argument, and my ignorance does not make a programming language suck. I will say that what is important for people (and kids) new to programming is having a large pool of documentation and libraries to draw upon. Python beats Ruby in this sense (and Perl beats Python too, but I still don’t like the syntax enough to thumbs-up it for newbies.) All three are good to learn programming from (more than Java or C++ by far), but I think Python wins in the end.

EDIT: When I say that Python is the new BASIC, I mean it as a compliment, to say that Python is in the best position to become a lingua franca for non-programmers to learn programming. I didn’t mean to imply that Python was an inelegant kludge. In fact, I discovered when writing this book that tasks that would be complicated in BASIC are much simpler in Python, and without the spaghetti code.
EDIT: When I say that Flash and ActionScript have a financial cost, I mean that a license for Flash CS3 or MX is in the range for hundreds of dollars. I know that the Flex SDK is freely available, but there’s still have a lot of complexity up front.

FINAL EDIT: Without any sarcasm, if you guys disagree with me (that Python is the best language to teach programming to non-programmers, especially kids), then please write a complete tutorial or book of your own in your specific language. I completely encourage anyone to produce works that make programming (programming, not using point-and-click game/app creation systems) more accessible, which is something that I feel we have lost in the last few decades.

One Response to “Python is the new BASIC.”

  1. Chris Says:

    I want to know how can you run a file by python.
    For example I want to make a file protected by password and I thought

    pass=input()

    if pass = “secret”
    run “secret voice.mp3″

    Something like that
    Can you please send me the instructions on my email?

Leave a Reply

free blog themes