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.

60 Responses to “Python is the new BASIC.”

  1. dude Says:

    I’ve had much better lucky teaching programming with Ruby than with Python due to the more consistent syntax.

    Say you have a list, how is a beginning supposed to follow/comprehend the bigger picture when faced with code like this:

    mylist = [1,3,2]
    print len( mylist )
    print sorted( mylist )
    print mylist.sort()
    print mylist.reverse()
    print mylist[0]

    Honestly, what is going on here? Why different syntaxes for slightly different ideas? In Ruby the exactly equivalent lines are:

    mylist = [1,2,3]
    puts mylist.length
    puts mylist.sort
    puts mylist.sort!
    puts mylist.reverse!
    puts mylist.first

    I know which one is easier to word explanations to :P

  2. Dennis Krueger Says:

    On the money article.

    As we see the start of the convergence of the applications and presentation spaces, this seems to be a reasonable middle-ground somewhere between java-script and the, never mentioned, I noticed, C# of the web domain and the C++ and VB of the desktop app domain.

    As an aside, you might take a look at an exemplar, but neglected, solution which presented an extremely low bar to application development, Pick Basic and the Pick Operating system. Most applications for the Pick OS were developed by the application users, not by professional programmers alone.

    Also, good sharp summary of the various languages.

    Thanks,

    — Dennis

  3. Eric Larson Says:

    @dude

    That is a pretty good example and makes your point, but how about this:

    for line in file(‘my_file.txt’, ‘r’):
    print line

    Compared to:

    open(‘my_file.txt’, ‘r’).each do |line|
    puts line
    end

    open(‘my_file.txt’, ‘r’).each { |line| puts line }

    for line in open(‘my_file.txt’, ‘r’)
    puts line
    end

    Again, you make a good point, but I think as you move forward with Ruby and Python, there is a more consistent pattern in the Python world that can be helpful in how you move forward. This is probably more of a personal opinion than fact, but having one way of doing things makes life simpler and gives you an opportunity to understand why. When you have more options, it can be difficult to see why decisions are made outside of personal preference.

    A good example in Python is list comprehensions. When you realize they are limited to one expression and that they are faster b/c they are performed at the C level, it makes for a good place to consider more complex ideas. You can start to see why itertools is such a good module as well as understanding that optimizing loops is an effective means of improving algorithms. And yes, I realize that is probably well beyond most beginners, but that is the point. Python can grow with you while keeping the majority of the early (simple) ideas easy.

    Just my two cents.

  4. Andy LeClair Says:

    I think I’m going to have to agree with “dude.” You state categorically that Ruby can’t be the new BASIC because you don’t know it and because it has less libraries? I think that’s more than foolish, it’s misleading. Ruby is very suitable for beginners, and HacketyHack, which you’ve taken issue with apparently, although I can’t tell what your issue is, is very easy to get started with, and it does a very good job of giving beginners a gentle introduction to programming. I’ve done the HacketyHack tutorials, and not only are they easy to understand and follow, it provides an easy to use sandbox for those who are done with the tutorials and are feeling adventurous.

    Python is nice, but is Python really the future and nothing else?

  5. dude Says:

    Fair enough. But I don’t see the point in teaching someone a TOWTDI programming style these days. It’s just not true. There are so many ways to do it. I would teach that the ‘correct’ solution is to do whatever makes the most sense at any moment.

    All 3 of your ruby snippets look great to me (with the first two being arguably identical). I’m not sure why I would want to limit someone to only one of the ways.

    List comprehensions are a great feature of a lot of languages. But they’re also (as you say) way over the head of your average beginner. In that sense the Ruby way would be greatly preferable since you just write it as you think it.

    python:

    [ x * 2 for x in xs ]

    ruby:

    xs.collect { |x| x * 2 }

  6. jafraldo Says:

    Come on. The difference is minuscule, and anyone could understand either of those examples.

    If there was an argument to be made, it would be on libraries available to either language.

  7. dude Says:

    jafraldo:

    I don’t think so. We’re talking about explaining things to a beginner here. The Ruby example (with collect) is just a method call like any other. It’s very similar to .each and .inject, and lots of others that take ‘blocks’. It’s a Ruby idiom that helps apply knowledge from one type of problem to another.

    You end up on a massive tangent when you try explaining list comprehensions. So much so that you might as well not bother and just make it a for loop instead:

    doubled = []
    for x in xs: doubled.append( x * 2 )

    You do have a point though. Python’s libraries are superior in many ways, if only because they are more mature. The Ruby community is working on this. But I’d argue that the beginner isn’t going to have especially crazy requirements as far as libraries go. The core language needs to be straight forward, predicable, and fun, otherwise they’ll never get to the libraries in the first place due to frustration :) (not saying Python has this problem, of course).

  8. Ruby fanboys Says:
  9. dude Says:

    Newflash, this just in!

    Civil discussion is now considered fanboy territory.

  10. markus Says:

    I agree with you somewhat.
    But first to be fair, let me say I am a ruby guy :)

    I encourage people to test ruby and python and use what they want. Personally I have a few problems with some python design decisions – I will not mention them here – but on the other hand people can find some errors in ruby too. I would probably agree on some. But the thing here is this:

    Ruby and Python are VERY similar. They fill a very similar niche. And I hope in the end that BOTH will benefit.

    You can’t imagine how difficult it is to convince the perl guys to stop using perl. Especially old C hackers love perl. But we have:
    - php
    - python
    - ruby

    Why still stick to perl? It is by far the most unreadable of them all. (Anyone does not believe me, please have a look at the file “autoheader”. It is part of GNU autoconf package. It is such a horrible horrible mess – and I know because I am rewriting it currently in ruby – that I wonder why ANYONE is still using perl.)

    To me, neither ruby or python are the BEST language possible yet. I actually like that you can omit the “end” in python. I think that should be optional, so that I could keep my ruby files (or that new language file) in a indent-fashion I choose.

    If both ruby and python manage to attract new people, then we have won a LOT.

    PHP as a language will always leave some things undesired, and I predict that PHP will not grow as much as both ruby and python will (because, let’s face it, PHP code is almost as unreadable and unmaintanable as perl code is).

  11. Josh Says:

    I switched from Perl to Python, and then from that to Ruby. I personally find Ruby to be much cleaner. Why I have to send “self” as the first parameter to a class’s method, I’ll never know. It just feels bolted on (though not as bolted on as PHP’s object-orientation!).

    In any case, I’ll probably teach my kids Ruby, and you teach your kids Python. I don’t *like* Python, but I would never call it abuse.

  12. Yitz Says:

    I don’t really use Python or Ruby on a regular basis, though I’ve used both for a couple of projects. Libraries are a non-issue – a beginner’s requirement of esoteric crypto libraries seems unlikely, and both Python and Ruby have very good coverage of anything a beginner could want to do (although if you can give me some examples of beginning tasks where Ruby libraries fall short, I’d be interested). I think the two languages are going to be mostly equivalent, but it smacks of willful ignorance to say, “Well, I don’t really know B but I think A is better.” Each language has ups and downs – beginners often have trouble with stringent syntax requirements, now explain to them why interleaving spaces and tabs causes their Python to break. (Not saying whitespace-sensitivity is bad – no need to open that flaming kettle of fish – but an argument can be made either way about its ease of use for beginners.) The documentation argument is specious at best – a cursory google for “ruby ~introduction” or “python ~introduction” (and various permutations on that theme) seems to give me similar figures for both, so I’m guessing you’re going off of “gut feeling” rather than… evidence, for instance. Which is fine, and you’re entitled to your opinion, but I still think it’s worth it for us to invest some time and effort checking our own assumptions. I wouldn’t pick either language for a beginner, personally: I’d teach them LISP. But that’s a whole different story.

    The new BASIC is both Python and Ruby – it just depends on who you ask, and how familiar they are with both.

  13. anonymous Says:

    PHP actually IS the new basic, that is why the web is crawling with amateur PHP applications and copy/pasted code.

    It is available on all platforms and everyones webhost
    You do not need HTML/CSS/JS to use php, you can just print stuff out.
    It is easier to install than any of the other candidates on your basic windows desktop.
    You don’t need apache, and if you decide to use apache later on it is very easy to set up unlike the other languages, just install the module and load your page in a browser.

    No one just learning to program cares about namespaces or how consistent the languages or how clean the syntax is.
    All that matters is can they get a working system by fooling around for an hour, and can they easily see their results and figure out how to get something done.

    PHP’s write/upload/refresh browser cycle has no real competition for ease of use.

  14. dude Says:

    anonymous:

    You’re reaching here because not all new/beginning programmers are just script kiddies trying to ‘get a working system’. Sometimes you want to teach kids to program, for example. And it most certainly matters, in that case, to pick a language that is _very_ careful about organizing things how one would expect, because the best way to turn someone off of programming is to confuse them. If it’s frustrating…

    >>> mylist.length()
    Traceback (most recent call last):
    File “”, line 1, in
    AttributeError: ‘list’ object has no attribute ‘length’

    … it’s not fun.

  15. risomt Says:

    Personally, to me, python is english and ruby is psuedocode. Ruby is often more shorthand and ‘clean’ – making it’s syntax, in most respects, better for programmers. I think for that exact reason it’s actually worse for teaching. It boils down to this question: What’s easier to understand?

    A:
    [ x * 2 for x in xs ]

    B:
    xs.collect { |x| x * 2 }

    I used Ruby for a small project about a year or two back and I honestly don’t know what the pipes specifically mean. It’s a tradeoff of text vs. obscure characters – longhand vs. shorthand – readability vs. writability (speed).

    I think for a begginner the syntax |x| is just going to cause problems. If it’s a programmer new to the language they’ll look it up and shrug it off – a new programmer with the language, however, may be confused unneccessarily. You can’t exactly go help(|) either (I think?), whereas at least ‘for’ gives you a solid idea.

    It’s a pretty tiny hair to split, but I think it makes a huge difference with newbie programmers.

  16. dude Says:

    risomt:

    These points are fair enough. If you think the list comprehension is easier to understand than the method, cool.

    I’m not saying Ruby is easier to _learn_, I’m saying it’s easier to _teach_. Because as a teacher you can explain something (like the block syntax and operation which you are saying you don’t get) once and have it apply everywhere.

    So, you’re right. The fact that the bars go around arguments and why is a bit of a chore to actually explain. But it’s just one extra concept (like, but more difficult than, list comprehensions) which, once understood fully, is a wash with any other ‘property’ of the language. Like declaring variables in C, that’s just how it’s written in C.

    What I’m really saying is that hard is good, confusion is bad. Why is len() a built-in? How can I make my object respond to len()? Not even 2 questions in and we’re getting into double underscores and name mangling!

    As for help(|)… Again, it’s a piece of Ruby syntax just like the colon is at the end of methods in python. Can you type dir(:)? Just get out the rdocs, your textbook or google and look up ‘collect’ to find out how it works, with code samples. In ‘collect’, the stuff after the bars is what happens to the thing in the bars. So you put x in the bars and now x is available on the right side, so just do whatever, and the result of the expression gets added to a list for you. That’s it. That’s simple stuff, and if one is curious you can get into how blocks work right away.

    There’s really nice libraries that make things like: ‘if Time.now > 1.month.ago’ possible.

    Anyway, the point here isn’t to convince anyone to use Ruby. The author just pointed out that he didn’t actually know Ruby, so I’m just posting my observations as a Python and Ruby programmer.

  17. Joe Button Says:

    I’m going to put in a word for javascript (/ecmascript). The syntax isn’t too weird, hello world is “alert(‘hello world’);”, you can do real, useful stuff with it without jumping through lots of hurdles. Not just in your browser (although that’s a pretty useful place), but also on the server and in your scripts (cf. http://code.google.com/p/jslibs/). I agree that python is a great candidate, but I think ecmascript is an even better one.

  18. George Jempty Says:

    One way to think about having to pass self into Python methods, is that methods that don’t accept self as their first parameter, therefore qualify as class methods rather than instance methods. Taken in this light, you might conclude that needing to de-reference self conforms to the “explicit is better than implicit” maxim.

    Ruby on the other hand is just too much line noise: pretty much the next Perl.

    Better than all of the above in my opinion is Lua.

  19. Jules Says:

    “The fact that the bars go around arguments and why is a bit of a chore to actually explain. ”

    You won me there (just joking…)

    I tried to make it into Ruby but ended sobbing on the floor (it reminded me a lot of Perl)

    And anything resembling Perl _not_good_ in my book

    Have to try Lua though

  20. Mark Lee Smith Says:

    Ruby has been called Smalltalk with a more conventional syntax; since Smalltalk was designed for kids I think it may just have the upper hand in this discussion :).

    For the more advanced, as in Smalltalks, new control structures can be introduced into the language easily.

    In the end both languages have a load of design flaws, but they’re fun! I’d encourage the prospective user to learn both and choose whichever suites you (or don’t choose at all).

  21. another dude Says:

    But man Ruby is slow. Granted it’s fast enough for a lot of things but if Python has a whole lot more libraries and is many times faster (relevant for things like games and scientific programs), why not learn Python?

    Save Ruby for the web apps.

  22. daveC Says:

    A factor no one has mentioned (probably because neither ruby or python seems to have any for the learner) is limitations going forward. Both python and ruby are dynamic languages, used more for scripting and rapid prototyping than for “serious” enterprise-class applications. There seems to be an implicit assumption that if the beginner/learner is to get serious later, he would have to learn C++ or Java or some other enterprise-class language. My point is that python has a growing advantage in this respect. Simple use rules (restrictions) make python a good candidate for compilation. Already Restricted Python and compilers like ShedSkin and Psyco are bidding fair to make python not only fun (and productive) to use, but also a language you do not have to abandon in order to get performance as good as C or other highly optimized compiler code. Say what you will about its clean, advanced, object-friendly syntax, ruby is harder to build great compilers for.

  23. Brian Says:

    @Josh (comment 11)
    This is one of the funniest things I’ve read on the internet:

    “In any case, I’ll probably teach my kids Ruby, and you teach your kids Python. I don’t *like* Python, but I would never call it abuse. “

  24. remember Says:

    Lets consider the future of Python 3000 vs Ruby 2.x/3.x… which will be easier to use and learn?

  25. also Says:

    Don’t forget, back in the days of C64, not only was BASIC what you got when you started up, but assembly was often used too. Open up a mag in the day, type in some assembly and whoaa, some cool stuff.

    I think it is very important for kids to at least grok some assembly. It might be over their heads, but it will give them real insight and wisdom on how computers really work.

  26. david Says:

    Basic rocks!!! I loved to program basic and I miss those days!

    I don’t agree on the huge learning curve of Java! You can get started pretty easily with Java. Of course that doesn’t mean you get right from the beginning, but you can get something working in a reasonable amount of time.

    Java has a huge amount of frameworks and libraries and nobody can master them all. That might be scary for beginners, but it also means there’s a lot of stuff available “out of the box”, which is very convenient.

  27. MovGP0 Says:

    VB might be Windows only; VB.Net is not. In fact, almost any language is a .NET language – including Phython, Ruby, VB, C#, PHP, and many others.

    I prefer C#, because it is strict. Phythons dynamic type system is not that strict, which increases productivity, but dynamic typed languages lacks of valiability.

  28. SimonTewbi Says:

    Python & Ruby seem very similar to me. They at least fill the same niche. I’ve played a bit with Ruby, a bit more with Python. With that limited experience, and the fact that I was one of those original kids in the ’80s who learnt to program on BASIC here are my observations:

    1) I agree with “dude” about the arbitrariness of Python. Coming at it from C# where everything is a method, I find it annoying that some things are methods and some are functions. The horrible join method is a crime against humanity (eg “,”.join ). And, yes, I understand why “self” in method calls was that way by design but it still looks ugly.

    2) Python’s significant whitespace is beautifully clean. All other languages (including Ruby) are ugly in comparison. Probably doesn’t matter as far as a language for kids to learn, though. BASIC was ugly in comparison to Python.

    3) I will have to come down on the Python side as far as list comprehensions go. Once again, beautiful and elegant. Reminds me of BASIC as far as readability goes. Ruby’s syntax brings to mind C++ (WTF are all those weird symbols? Instead of code scattered with * and => we have |x|. Been a while since I’ve done maths but isn’t that supposed to represent absolute value?)

    4) Libraries. They do matter. Beginners don’t stay beginners long. Some kids will be content to doodle with a language but some kids will very soon want to move on to pretty complex development. That’s where libraries come in useful and where Python wins: It has a library for everything.

    5) Documentation. Python wins again. I may be unusual in appreciating reference manuals. I have always found reference manuals, and on-line documentation like Microsoft’s Books Online (MSDN), to be a major source of help, even once reasonably experienced in a language. Python’s manuals are great, close to the quality of MSDN, Ruby’s don’t come close.

    In the end I favour Python but I believe Ruby is also BASICesque enough for the job.

  29. dude Says:

    SimonTewbi:

    Personally I don’t get all this Perl bashing… Perl is great. Has even more libraries than Python does!… Anyway.

    (1) string.join is a great example of Python being painful for beginners.

    (2) You can write Ruby in the exact same indentation style as Python, if you like.

    (3) Ruby’s syntax has nothing to do with C++. The bars around block arguments are just that. Arguments around block arguments. It’s just syntax you need to learn, and it’s not difficult. You know how you call a function like funcname( arg1, arg2 )? It’s like that except for a different purpose. There’s no ‘math notation’ (thank the deity of your choice) in Ruby, so it doesn’t mean absolute.

    (4) Yea, Python libraries are plentiful. Ruby hasn’t been in the mainstream as long. Lots of new libraries are popping up all the time. And I’d argue that they are often nicer than Pythons. Datamapper, for example.

    (5) There’s enough decent Ruby and Python books for classroom use. I don’t think this is an issue when it comes to teaching either language.

  30. Gabriel C Says:

    What about JavaScript? Is everywhere! No downloads, libraries, installations, etc., just type something in a .js file and voila! Is also very limited in the amount of input and output you can do… it will felt almost like the old basic days with print/input :)
    On the other hand, to take a totally different approach, I think Squeak (SmallTalk) can be a great initiation language.

  31. dude Says:

    Gabriel:

    Ruby and Python are everywhere too. Just type something into a .py or .rb file and voila! Infact, since you don’t need a web server (and configure it and write html pages to serve the html and all that) it’s arguably even easier.

    That said, I am a huge fan of JavaScript, I write a lot of it. Just as far as teaching goes, it’s pretty useless.

  32. sapphirecat Says:

    When my dad went from the Amiga 500 (!) to Linux, he got a C++ book and tried his hand at it. I supplied a Python book and he’s never looked back. I don’t think he’d enjoy Ruby quite so much because of the blocks; it’s easier to track “this calls that” than “this calls that which magically runs this again, which can reach out and touch this other stuff”. Not that blocks and closure are bad things, but understanding them isn’t free.

    In Python, you don’t have to know about list/tuple comprehensions to get started programming, but Ruby throws blocks in your face as often as it possibly can. Also wrt __len__, you don’t *have* to get into name mangling, because you never need to call its mangled name directly. Teaching is not about being a talking reference manual, it’s about understanding what your students can handle and being their guide.

  33. bdprescott Says:

    All a y’all are right and all a y’all are wrong. Here’s some thoughts:

    - BASIC is the bane of programmers, the world over.

    - A good programmer can write clean, understandable code in any language.

    - Teaching people bad habits from the start as occurred with BASIC doesn’t help our business at all. Using Python, Ruby, Perl, Ada, C, C++, etc the way BASIC has been will only result in BASIC programs written in another language.

    - Programmers who become game programmers don’t because of the availabilty of BASIC like languages. That’s like saying someone became an artist because they had Crayola crayons as a kid

    Most of us became programmers for a lot of reasons that didn’t include language simplicity. Hell, the first language I learned was Cornell PL/I. Someone gave me a 25 page user’s guide and pointed me at an 026 keypunch. A lot of very good, very interesting programmers’ first languages were FORTRAN, C, and Pascal. I know a fair number of programmers whose interest in programming grew out of programming real time computers in assembler while doing a tour in the Navy.

    We don’t need to teach people programming using bad practices in a sweet language like Python or Ruby. We need to start teaching people how to program in middle school, just like we do math and grammar. We need to use languages that have a consistent syntax and that enforce good programming practices. Look at the success Papaert and Kay have had with Logo and Squeak (SmallTalk).

    My $0.02.

    BD

  34. a different anonymous Says:

    So you want to teach programming101? Whatever happened to using boring old pseudocode to represent common language concepts?

    while the glass is not full:
    leave the tap on

    if the room is dark:
    turn on the light

    print “Hello World”

  35. Mark Lee Smith Says:

    DaveC:

    Your problem with Ruby is that you’re not familiar with the syntax, specifically the bars? Bars have been used in this manor for about 40 years. They denote arguments to block literals in a number of languages, including Smalltalk and Self.

    Pythons syntax has proven so problematic that numerous attempts to introduce block literals have failed. Bashing Ruby for doing something Python couldn’t smacks of sour grapes.

    Another dude:

    Ruby is slow? Which implementation are you referring to exactly. There are a number of implementations, on different platforms, with different strengths.

    Both:

    Semantically Ruby and Smalltalk are nearly identical. Keep this in mind when I say that commercial Smalltalk implementations have been blowing Python out of the water forever as far as speed goes. There is absolutely no reason that Ruby can’t be made to run this fast. (Theirs no reason Python can’t be made to run this fast!)

    Lets be honest, neither of you have any real experience with Ruby, you’re just repeating what others have said before you.

    Before either of you proclaim me an uninformed Ruby lover you should know that I have over six years of experience with Python and have used it commercially in the past. I most certainly don’t think Ruby is perfect.

  36. Mark Lee Smith Says:

    DaveC:

    My apology, It wasn’t you who I was intending to reply to. I seem to have copied the wrong name (egg on the face). SimonTewbi, that was at you.

  37. Joel Says:

    The Flash VM, actionscript 3, Flex, as well as the the SWF and FLV file formats are all OSS. Please remove your incorrect statement.

    I agree that actionscript 3 is not ‘the new basic’, but your misinformation needs to be corrected.

    Best Regards,

    Joel

  38. André Roberge Says:

    I think Python is a lot simpler and more consistent for beginners. Have a look at
    http://mousebender.wordpress.com/2006/08/06/the-whitespace-thing/
    and see for yourself.

    P.S. Thanks for writing the book.

  39. Stu Says:

    I think its funny when people start talking about how X has more mature libraries.

    Yeah crufty old libraries written in C, and what your _really_ talking about is that the binding to library Foo in interpreted slow scripting language X is slightly older than in Y.

    Bindings count for nothing as long as bindings exist, thats why SWIG exists.

    Talking smack about python vs ruby is like knowing basic on c64 and apple, they had slight differences but did the same pony tricks.

  40. JB Says:

    I think Python’s great. I used it in conjunction with Panda3D, a free 3D engine. I’d recommend it if you’re looking to do 3D graphics with Python.

    http://panda3d.org/

  41. dude Says:

    Stu:

    I realize your main point is about the library situation… But I think you’re missing a big part of the discussion. When it comes to teaching Python/Ruby/Perl/Whatever in the classroom it’s not just about libraries, the syntax, or anything else specific… It’s the big picture.

    It doesn’t matter how ‘crufty’ the libraries are and it doesn’t have anything to do with bindings. It has to do with keeping your students interested and engaged. You must encourage a love/passion for programming as that is, IMO, the _only_ way one can become a great programmer.

  42. Jules Says:

    Just for this, Python deserves to be teached as an obligatory language for everyone ;)

    The Zen of Python, by Tim Peters

    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren’t special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one– and preferably only one –obvious way to do it.
    Although that way may not be obvious at first unless you’re Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it’s a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    Namespaces are one honking great idea — let’s do more of those!

  43. dude Says:

    Jules:

    I always disagreed with much of ‘import this’.

    And it seems to me all the high profile dutch guys are using Ruby… maybe they know something you don’t? :)

  44. D. Rothlisberger Says:

    I’d probably teach my kids Forth. Fun, simple, low-level enough…

  45. INTERCAL Says:

    “Why I have to send “self” as the first parameter to a class’s method, I’ll never know.”

    It’s in the FAQ.

    “Not even 2 questions in and we’re getting into double underscores and name mangling!”

    Name mangling doesn’t enter into it. Double underscores aren’t any harder to explain than exclamation points or at signs. “How do I make my object do X” comes after a lot more than 2 questions.

    “You can write Ruby in the exact same indentation style as Python, if you like.”

    I think significant indentation is more trouble than it’s worth, but pointing out that you can indent however you like in a language without it is missing the point.

    “Pythons syntax has proven so problematic that numerous attempts to introduce block literals have failed.”

    There’s never been any consensus that block literals (in Python-speak, multi-line lambdas) are desirable. I wouldn’t be surprised if some random person has tried it; I once wrote a codec for braces, just to prove it could be done. There was a PEP for “anonymous blocks”, but they were intended for a specific purpose and rejected for reasons other than syntax.

    “Ruby is slow? Which implementation are you referring to exactly.”

    The stable reference implementation, obviously.

  46. jt Says:

    You know, I took a look at that game book and it struck me how so 1980s the thing was. It brought me down to memory lane.

    Now, looking at the alternative (Squeak), which is fully OOP all the way down to the very menus and icons, buttons, which has a much richer environment and is totally ready for multimedia, along with the derived (written in Squeak) Scratch language, I think it’s very bad that we’re returning to Basic.

    Kids deserve something better in 2008, and we can deliver it, just as long as we keep our prejudice at bay against Smalltalk (because it really is about prejudice and lack of information).

  47. Skitsanos Says:

    Quite lame post. Too many words about nothing. Taking BASIC as comparison point requires some brains and at least some experience in this area, but it seems this bit is missing here…

  48. Terry Says:
  49. phil Says:

    I’ll take your challenge on testing out the book (for 9-12 year olds…) in learning Python. Will let you know how i get on… It’s been 15 years since I coded – I used Turbo C and Pascal… so let’s see if I can catch up. :)

  50. Evets Says:

    “just as long as we keep our prejudice at bay against Smalltalk (because it really is about prejudice and lack of information).”

    Baloney. Most people that investigate teaching kids programming eventually come across Squeak. Squeak as a language and idea rocks–I love it. Squeak the implementation actively turns children away from programming. Have you tried teaching Squeak to a child? Contrast this with PyGame, Pyglet or Gamemaker and it’s no wonder people eventually abandon Squeak.

  51. salubrium Says:

    I am talking from someone who is learning Python and my reasons for it compared to Ruby.

    1. Up until recently Ruby had little existance outside of Rails.
    2. Free Books – Dive into Python, How to think like a computer scientist etc.
    3. Libraries, books and information – wxpython, gtk, pyqt, pygame – there are not only these libraries but also books on how to use them
    4. Python is installed by default on most *nixes
    5. Want to move from interpreted to compiled languages? Boo is a .Net language inspired by Python and runs at almost C# speeds. You also have jython or ironpython for Java/.Net
    6. Django, turbogears, web.py etc. give many choices over Ruby on Rails alone.

    From the little I learned of Ruby, I think the difference of learning Python or Ruby is minimal but I once you move beyond the basics, Python becomes a much more relevant language.

  52. Ronald Loui Says:

    Dennis Krueger #2 — I had to chime in. I had a great time programming in Pick Basic on the Pick OS (actually Microdata or some such thing). Don’t forget the Pick-English database query language.

    jt #46 — this is a real issue. On the one hand, the BASIC era produced people who loved to program in great numbers. On the other hand, textbooks that return to those old days and those old ways, with modern languages, seem like anachronisms. What would John Kemeny say today? Basic was a good teaching language. It is exactly the opposite result that JAVA has had on young programmers, that makes me take such a hard line on Java.

    I really think people should have a closer look at gawk as “clean perl”. You then have to learn something else — C, C++, C#, js, php, python, ruby, perl, or java — but you can keep your gawk for lots of tasks.

    My opinions about languages usually come not from looking at the syntax, the libraries, nor even from doing a lot of programming in each, but from watching programmers do various tasks in them. When you see mass frustration, widespread failure, rigid designs, and projects with generous development times delivered late, you know something is wrong. When you hear people talking about how much they love their language (the Paul Graham test), it’s good to have a listen.

  53. Ben Says:

    IPython is what made learning python so much easier for me than ruby. Irb is quite nice, but it doesn’t just start flowing for me the same way that IPython did. I really would be quite happy if I could combine ruby’s syntax consistency, IPython’s capabilities and mature libraries. Wouldn’t that be wonderful for teacher and student?

  54. jason Says:

    FreeBASIC or PureBASIC are the new BASICs. How can you say that Python is a modern version of BASIC when really its just an alternative to Ruby and not a dialect of BASIC. BASIC is BASIC, which what FreeBASIC is. And you can write any modern application in FreeBASIC (or PureBASIC). Why are programs written in psuedocode any way, its because psuedo is close to English. And which language is closest to English? why BASIC of course. So why not just program in BASIC and skip writing psuedo. Really its ridiculous why BASIC is discarded simply because of its name and the false declarations that modern BASICs are similar to early simple BASIC dialects like QBASIC , when in reality, modern BASIC languages can handle any programming tasks as equally as any other programming language. It is wrong to try and direct people away from true BASIC dialects because of legacy mentality (think BASIC — think QBASIC) and falsely claim that modern BASICs are incompetant programming environments.

  55. seo Says:

    Hi would you mind sharing which blog platform you’re using? I’m looking to start my own blog in the near future but I’m having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I’m looking for something completely unique. P.S Sorry for being off-topic but I had to ask!

  56. Ken Says:

    I have to agree with Jason, Basic is Basic, not Python, not Java, not Ruby, not Javascript (HTML5), and not Flash (Actionscript 3).

    I program in Purebasic, and with it you can write almost any type of program you need. And it is easier to program in than any other language listed here, and faster than any other language here other than C++. I know, I tested them all at one time.
    But yes, it cost some cash to own, most good things do.
    So you want Basic, I mean real Basic, try Purebasic, They even have a demo version.

    You can do games and apps with it, full screen Games, windows Games, hell it even has inline Assembly, if you think its not fast enough for you, With built in Sprite , 3d Graphics, Sound, Windows API, and Mac support., you cant lose, and has a ton of examples, and a great help files.

    And as Jason also stated, you wanna go the free route, then use Freebasic, its good too, though not as well supports as Purebasic is.
    You have to pay to get great support, we all have to eat.

    And no, I am not affiliated at all with Purebasic or anyone there. I just like it and have been using it for years. And I know my basics, my first one was Atari Basic, So I’ve been in this game for a while.

  57. Mark Says:

    Microsoft has responded to this and has now developed a BASIC programming language that serves as a great 1st programming language called SmallBASIC. There website is: http://msdn.microsoft.com/en-us/beginner/ff384126.aspx

    This is far, far easier to learn than Python which uses the ridiculous and complex string counting method of starting at zero (Zero based numbering). Hello Python developers, we in the USA start counting at 1, not zero. It makes programming extremely difficult when you have to count from zero. Sort of like reverse polish notation for calculators. I mean, if you are going to start at zero, then do that for everything, i.e. change IF to HE, since H precedes I and E precedes F. Zero based numbering means you have to talk computer to program, when it should be the other way around. Save the zero based numbering for those poor souls who have to program in Java.

  58. hedergabor Says:

    Good day for everyone here !

    I have written a simple calculation test console program. I started it with Gambas in 2005 but I was confused with the OOP design of Gambas. I simply wanted to write a structured program. I wrote the complete first version in Turbo Pascal 7.
    That is really fast and trustworthy but has a difficult number-string string-number conversion. Than I stared searching for applicable free BASICs or other tools with which I could be easier to develop my program. I tested about more than 12 language/IDE and found that Turbo Pascal 7 was still the best. (The syntax of gentee is also nice but is “only” a core language.)
    Python is quite good BASIC-like language and actually it almost won, but indentation is something highly uncomfortable for any BASIC programmer. I never do this (even not do it in javascript and PHP codes). A self-made Python script is probably slow for beginners, do not know how to speed it up. But the conversion mentioned above was only two lines in Python.
    Theoretically I could write a converter for Python for entering lines without indentation, but please feel the difference :
    I finally tested FreeBasic and it was amazing. FreeBasic can do that easily, and debugging and compiling is about one click in FBIde. An FB app about 2-4 times slower than a C app, or even less. I think advanced Python programmers can do this with Python and even can be faster a Python (or Cython) script than an FB program, and of course pygame is the best, but no way to do this in one hour for a beginner in Python. You can do this in 1 hour with FreeBasic.

  59. ScottInNH Says:

    I have to slightly disagree, a small quibble, and say that “PYGAME is the new basic”.

    Most of us who fondly remember BASIC do so through a prism of making their 1980′s home computer do things with sound and graphics.

    Most computer languages (including Python) consider “sound and graphics” to be out-of-scope to the language. For example, “graphics” are usually conflated with “images” (which they’re not… graphics are drawn by code). And the same with “sound”, which is generated not loaded from a .WAV or .OGG.

    (If anyone’s confused by this, yes yes multimedia audio files have “sound” or rather audio, but that’s wholly different than iterating over an indexed loop and sending the index value to a tone generator. Who didn’t do that as a kid on an Atari XL or C64?).

    Python like old BASIC is very “hands on”, but with old BASIC you could literally touch parts of the computer: graphics modes, sound functions, PLOT commands.

    I see Pygame has line drawing tools, but they’re not often written about and it took some Google digging to get past all the PyGame tutorials featuring how to load raster images. But it does exist. What doesn’t seem to exist is the analogous sound functionality, being able to generate audio within Python/Pygame code. (And perhaps this does exist, and is just even less documented than Pygame line-drawing, which wouldn’t greatly diminish my point that old BASIC made computers more tangible than today’s best efforts at the same)

  60. Alex Says:

    My last basica program was in 1990
    I still remember load save list and run
    I did a naval war game prog compiled as a exe file ( yes basica could compile too)
    Then I switch to qbasic and got stuck there for 20 years because I did never catch the train of the too complicated languages such as c or vba

    /* Hello World program */
    #include
    main()
    {
    printf(“Hello World”);
    }

    Or

    Module Hello
    Sub Main()
    MsgBox(“Hello, World!”)
    End Sub
    End Module

    While qbasic was

    print “hello world”

    Now I see everyone jumping around Python??? Yes python is the new basic. Python is easy
    Python is readable
    Python is simple and therefore beautiful

    But why did they killed qbasic to have python 20 years after. Tell me?
    I am 40 and I fell alive with python,, again

Leave a Reply

free blog themes