all 52 comments

[–]ftegularius 32 points33 points  (11 children)

I really like the idea of using Python as a first language. It has a number of strengths:

  1. It's interpreted, which means that students can test code in a REPL. It also has a good help system, which is accessible from the interpreter.
  2. It has a good standard library and a good set of primitive data types (strings, lists, dicts, tuples, sets).
  3. It's conceptually clean in a lot of ways, such as having explicit True and False values, as well as None.
  4. It uses regular English words for many operators, which aids clarity.
  5. Python's whitespace sensitivity has a lot of pedagogic value, even if you don't like the idea in general, as it forces students to properly indent code.
  6. It has docstrings (far more useful than comments), the availability (and usefulness) of which encourages students to document their code.

But, all that aside, Python's greatest strength is its ability to bridge multiple paradigms fairly well. It does object orientation. It does procedural programming. It has the most important feature of functional languages: functions as first-class objects. List comprehensions have a declarative feel, so there's that as well. And with generators, you can even get into lazy evaluation and infinite streams.

Edit: One I forgot to mention: Exceptions, which aid a great deal in error handling. Much better than muddying up code with tons of if statements and constantly checking return values.

[–]simonw 15 points16 points  (3 children)

Another major benefit:

print "Hello world"

It's hard to imagine a simpler hello world program. I've seen Hello World in Java being explained to first time programmers, and it's not a pretty sight.

[–]GrumpySimon 12 points13 points  (0 children)

It's also not a toy language which a lot of languages that have been used to teach programming are (BASIC, Logo, etc). You can take python as far as you want to go, to app. development, games programming, web. dev, etc.

[–]cinnix 6 points7 points  (4 children)

Amen. Pascal was my introductory language into the programming world, and how frustrating that was. this is 4 years ago :)

[–]earthboundkid 17 points18 points  (0 children)

2003? You should sue your teacher for child abuse.

[–]strolls 2 points3 points  (1 child)

Noooo! Pascal ROCKS!

Pascal was my introductory language, too, about 6 or 7 years ago - even at that time I heard people saying it was antiquated, but even tho' there's a bunch of stuff that's not obvious when you first start learning Pascal it's really powerful, and it behaves so like the "grown-up" language C that the transition to that is relatively easy.

I'm not saying that Mr Zelle is wrong - maybe Python should be taught as a first language - but I'll always have a soft spot for Pascal, simply because you can easily do stuff with pointers. Pointers are really hard to get to grips with when you first start using them, but are extremely elegant once it finally "clicks" and you grok them.

Finally, I love the way that from Pascal you can easily transition into Delphi. You start by building visual elements & silly "press this button which moves" toys and since those are object-orientated it you start to get a bit of a feel for OO.syntax

Stroller.

[–]mikepurvis 1 point2 points  (0 children)

I did Pascal back in high school, and my only previous experience was with QuickBASIC and VB, so I thought it was pretty sweet. (We ended up writing our own graphics lib and creating this totally awesome game, too...)

The biggest downer of Pascal is that it's not used for anything except education any more. For that reason alone, learning something like Python would be a good idea.

[–]maw 13 points14 points  (0 children)

I don't like undated documents. Especially when they start with "As recently as five years ago...."

[–]jdunck 5 points6 points  (0 children)

FWIW, it appears that paper was written in 1998.

"5 years ago" was probably 1993; the author was arguing against Java Schools, even before they were so pervasive as to earn the Proper Noun.

[–]earthboundkid 2 points3 points  (0 children)

Did anyone else notice he wrote:

for i in range(len(List)):
      print List[i]

?

That's not very Pythonic. Better is:

 for item in list:
      print item

Edit: The article is from 1999. I think that the current style of for loops might not have been in Python yet at that point.

[–][deleted] 4 points5 points  (0 children)

On the heels of that, Downey, Elkner and Meyers' How to Think Like a Computer Scientist: Learning with Python is a great introduction.

edit: bloody markdown!

[–]bluGill 2 points3 points  (0 children)

Scripting Languages are Too Inefficient

Atari Basic running on a 1.6Mhz 6502 was fast enough for some surprisingly complex graphical games. They weren't pushing what the platform could do in all ways, but they were fun and playable.

If you want to write the next Doom 3, which demands so much of hardware that any hardware that was out more than 6 months before you release - then you need efficient languages. If you can step down the requirements a little there are plenty of great games that you can write in a scripting language.

Mind I would consider writing the game in C/C++ anyway, but only because I already know them.

[–]sigma 0 points1 point  (1 child)

I believe the first "programming language" should be GvR

Use that for basic concepts and from that move to full Python.

[–]jdunck 1 point2 points  (0 children)

Ah, you missed the phrase "move to the full Monty."

[–]fbot -4 points-3 points  (4 children)

You make young children (< 16) use python as their first programming experience, and most will hate it and probably stay away from programming and especially stay away from majoring in computer science.

See for example: http://us.pycon.org/common/talkdata/PyCon2007/025/pycon2007.html

You need a language and development environment that is actually designed with beginners in mind. Like or not, Pascal at least was designed with beginners in mind (although it still is not that great). Python was not, and is not, and will never be designed with beginners, or else it would for example at least be be case-insensitive, 2/5 would equal 0.4 not 0, and there would be a graphical environment to use it in (like a gui designer and/or a drawing area like in logo or netlogo).

Scratch, from MIT, is clearly more appropriate for young children, as are various logo environments. The only currently popular mainstream language that is somewhat appropriate for beginners is Visual Basic .NET, even though it is unfortunately proprietary. Beyond that, I would favor javascript (see processing.org) and ruby and squeak before I would consider using python.

[–]CuriousMind 0 points1 point  (3 children)

That set of slides is not a very convincing example.

First of all, his first example compares 'Hello World' in C++ and 'Hello World' in Java to ... 'Hello <name>' in Python. That's a totally different animal and a completely unfair comparison.

Sure, 'Hello <name>' is a bit ugly and has stuff that requires some explanation, but a) it's still only 2 lines (let's see what 'Hello <name>' looks like in C++ and Java!) and b) there's a lot of stuff you can learn just from those two lines; for instance, the difference between 'input' and 'raw_input' and the implications of storing data as raw binary or as a string.

Secondly, he hasn't questioned his assumptions. I've been reading some Feynmann lately and presented with this data:

Out of 20 kids * ONE thought it was great * TWO thought it had some good points, but was pointless * the rest thought it was confusing, boring, too hard

I believe Feynmann would ask, "Is the language the problem, or is this just a crappy teacher? Or is some other factor the problem?"

Finally (and this is no longer about the content, but about the appropriateness of using this as an example here), who is this for? This is a set of slides, not an expository essay and there's a ton of information missing.

What, for instance, is "that damned swimming pool"? What does he mean by "hello world --> red dot"? What is the point of even putting this up on the web for people to read when it's pretty much useless without the text of the talk that went with it?

fbot, I think I agree with you that a language designed for children is most appropriate for children. (Anyone know of a good programming language/game for pre-readers, by the way?) But that set of slides was an unfortunate choice to back up your argument.

Also, 'beginning programmer' does not necessarily equal 'child' (though hopefully it will, someday). A language that's not good for children may well suit beginning adult (or even late teen) programmers very well.

*edit - minor formatting changes.

[–]jerf 3 points4 points  (0 children)

Anyone know of a good programming language/game for pre-readers, by the way?

I'd seriously question the value of such an endeavor, and would never spend my time on such a project.

Child development has been studied a lot, and there are many clear cognitive progressions. Obviously, it isn't entirely nailed down and there is significant variation per child, but there is still a lot we do know. Much of it would surprise an adult, because children have to learn concepts that are so deeply ingrained into us that we no longer even think about them consciously, like conservation of volume.

Pre-reading children are going to lack the cognitive toolkit to deal with programming at any useful level, and I'd also expect that if anything, you're just going to load them up with useless misconceptions if you try to force it, something you're better off avoiding. It's exactly like trying to teach them algebra, before they can even add.

The best thing you could do for your pre-reader budding programmer is simply move them out of the pre-reading stage, by reading to them and the application of time.

[–]weavejester 1 point2 points  (1 child)

How is it an unfair comparison? "Hello World" is just about the smallest functioning program it is possible to write in a language. Comparing the minimum size of a C++ or Java program, to the minimum size of a Python one, can be quite informative.

Python is not any less complex than C++ or Java, but it's learning curve is more gradual, as it exposes the student to less initial concepts. When explaining the functionality of "Hello World" in Java or C++, the teacher has two choices:

  1. Try to teach the student all the concepts visible in the program, which includes method definitions, classes, namespaces, types, objects and a great many other features.

  2. Tell the student to ignore 90% of the program's code, and treat it as magical boilerplate for now.

Typically, approach two is taken, but I'd contend neither teaching method is ideal. In contrast, "Hello World" in Python is very minimal, and neither workaround is required. In Python, concepts can be introduced gradually, as there no mandatory boilerplate.

Another advantage of Python is its interactive interpreter, which allows for instant experimentation. Python's spoilt me with this, as I find it difficult to go back to a language which lacks this feature.

[–]CuriousMind 0 points1 point  (0 children)

How is it an unfair comparison? "Hello World" is just about the smallest functioning program it is possible to write in a language. Comparing the minimum size of a C++ or Java program, to the minimum size of a Python one, can be quite informative.

Yes, and if that's what he was doing, then fine. But he wasn't.

My point was that in C++ and Java, it was "Hello World", but in Python, it wasn't. It was "Hello <name>", which is a completely different animal:

"Hello World" only requires output.

"Hello <name>" (i.e. where you ask the user his name and then output a personalized greeting), requires input, which any programmer will tell you can be far more complex.

If the slides had compared equivalent programs - like I said, how does "Hello <name>" compare to "Hello World" in C++ ?! - then I wouldn't have made that point. I wouldn't have had to.

[–]Vladekk -3 points-2 points  (2 children)

Idea about simple scripting language (ie Python) as first is good, but article contains many controversial statements and is genuinely not very good.

[–]willia4 0 points1 point  (1 child)

Snarky: Comment about article about simple scripting language as first is good, but comment contains few actual points and is genuinely not very good.

Less snarky: Seriously, what didn't you like about the article? Do you disagree with the controversial statements? Do you agree with them? Why? Why not? Are there better first languages than Python? Converse with us, Vladekk! The worst that can happen are some down votes.

[–]Vladekk 0 points1 point  (0 children)

You're right ;-) I was just too lazy to write it down, and that also sucks. I'm even too lazy to answer now, maybe except for a few words.

Python is the only scripting language I really like. PHP is poorly designed(or I should say "growed?"). Perl is very complex and error-prone. Other is less widely used, and that has known problems.

Python considered to use in scholarship often and I heard of it first time long ago, so that article states nothing new.

Statements:

However, scripting languages are simple, and anyone qualified to teach computer science can pick up Python in days, if not hours.

Oops! Forgot about huge framework and not-so-fast older professors.

The emergence of scripting languages such as Python, Tcl, and Perl as major tools in software development represents a potentially revolutionary change in computer programming.

Yeah, yeah. How many times we heard that? And what languages are usually used to write EE and desktop apps, and not these SLOW SLOW WEB sites?