Log in

No account? Create an account

Previous Entry | Next Entry

To all programmers: What do you personally think of Python, the programming langauge?

1. Is it a good teaching langauge?
2. A good general-purpose language?
3. Is it "better" than C/C++ or Java?

How so, and why or why not?

In other news:

Dragon Dynasty: Well, that played a bit fast and loose with Marco Polo's biography and the history of the Yuan (Mongol) Dynasty, but think of it as "all the evil of Dragonslayer and all the cool CGA of Dragonheart" and it's rather fun. Legend of Earthsea remains unchallenged for meaningful dragons who aren't just big Reign of Fire creatures.

By the way, CGA quality is proceeding apace for tanelos, if I ever manage to complete and submit the manuscript, or produce a screenplay.



( 29 comments — Leave a comment )
Jul. 24th, 2006 11:57 am (UTC)
Personally, I find Python a bit... peculiar. On one hand, I think a teaching language should not have a garbage collector. Students have to learn that you should clean up after having a party. If you make them used to languages with garbage collectors, later it will be very hard for them to write in languages which do not have them. Like people who learn Java and then try to write something in C++. Syntax is very similar, inheritance rules are almost the same, everything's right and then... "err, what do you mean by a memory leak"? ;) On the other hand, for a person who learned C++ first, switching to Java is quite simple.
Also, I'd like to point out that I think it's a good practice to teach languages with a C-like and Pascal-like syntax first. These two are the most common among programming languages.
As for the second and the third point: IMHO, Python is good as a general-purpose scripting language, and in this field it can compete with Perl, Lua, and sometimes PHP. For big stand-alone applications I think C/C++ and Java are a better choice.
Jul. 24th, 2006 12:51 pm (UTC)
i use python extensively and had to pick it up pretty much for my current job.

it is an excellent language for prototyping functinality. it can be very wasteful and stupid (well... some of its libraries can) but you can sit down and in half a day crank out most of what an application should look like and show it to the customer and ask "like this? no? ok."

it suffers from the same things java does in doing far too much for you. it does even more, if people learn about the way python deals with serialization, rmi, and threading. there being hidden global locks on all resources when you write threading applications (or if there aren't, someone was telling me lies, but i know i've definitely put racy stuff into python applications thinking 'i'll debug this later' and never had to...)


1. Bad teaching language beyond a very, very introductory level.
2. Bad general purpose language.
3. It's it has an advantage over C/C++ and Java in rapid turnaround time. It's the poster boy language for extreme programming, and for that i hate it.
Jul. 24th, 2006 12:52 pm (UTC)
oh that and you rapidly lose all of your affinity for python when in tracking down a bug you make a commit in which you only delete four lines of whitespace. whitespace-delimiting languages are evil and should be put down.
Jul. 24th, 2006 03:22 pm (UTC)
An alternate viewpoint
Well. It is just not true that you lose your affinity when tracking down a bug.

IME, people who dislike white-space delimiting are people who use bad style. Good style demands consistent indentation. It's a logical step for the parser to demand it and make use of it. In practical terms, white-space delmiting is a huge advantage in code legibility, it cuts down on line count, and makes debugging go faster by removing certain kinds of syntax error.
Jul. 24th, 2006 03:53 pm (UTC)
ws = sin
White-space should be thrown out at parse time; good style comes from discipline and a language should not try to restrict ones style.
Jul. 24th, 2006 04:02 pm (UTC)
Re: ws = sin
Uh. So, that's a nice grossly generalized and unsupported claim you have there. And an appeal to the moral high ground, too!

It's handy when a debate opponent shoots himself in the foot.
Jul. 24th, 2006 04:48 pm (UTC)
Re: ws = sin
1) Write a parser : 99% white-space is thrown out. It makes code that easier to type and flexible. Play around with C++. Bracketed code is easier to work with than un-bracketed (hence, python)

2) Discipline is required for programming; we must exercise it at every step. If you sloop code down, then you most likely are producing shitty code.

3) Where did I shoot myself in the foot? I was trying to shoot yours off for stating “people who dislike white-space delimiting are people who use bad style”. As I dislike white-space delimiting, your voice as truth would state I use bad style. Where as, I the faithful (full fledged computer scientist and mathematician) go “There is a much better way”. Instead of tab\tab\tab\tab, I can enclose my code with a bracket. Now, look at that, I have a structure independent of whitespace. I can be economical and write in any style that allows me to produce high quality code. Now, suppose I have to conform to a community/corporate style. Well, I have structured code; hence, I can format with an auto-formatter. The conclusion : white space delimiting is three steps backwards in language evolution.
Jul. 24th, 2006 05:57 pm (UTC)
Re: ws = sin
I originally learned to code with C++. I understand that C++ is more usefull for development because of it's nature as a compiled language and the extensiveness of its libraries and so on.

But for coding my own projects I switched to Python and never looked back. IME, unbracketed code is much easier to work with than bracketed code.

By "shooting yourself in the foot" I was refering to your WS = sin comment, and the fact that your initial post contains huge general claim with no support.

"As I dislike white-space delimiting, your voice as truth would state I use bad style."

Well, yes. In my experience, people who don't like white-space delimiting are typically people who are sloppy coders. I don't know you beyond this LJ discussion, so I must initially take it as a good bet that you are a sloppy coder.

It is possible you are an exception to my experience.

It is also possible that you actually *are* a sloppy coder, since most sloppy coders aren't willing to own up to that charge. ;)

"Where as, I the faithful (full fledged computer scientist and mathematician) go “There is a much better way”. Instead of tab\tab\tab\tab, I can enclose my code with a bracket. Now, look at that, I have a structure independent of whitespace. I can be economical and write in any style that allows me to produce high quality code. Now, suppose I have to conform to a community/corporate style. Well, I have structured code; hence, I can format with an auto-formatter. The conclusion : white space delimiting is three steps backwards in language evolution."

Aha. I think I see where we differ. I am a person that likes standards. I think such flexibility in code-layout style is a bad thing. One of the desireable features of Python is that the code style is mandated by the language - since all Python code looks much alike, reading and maintaining another person's code is not significantly different from reading and maintaining your own code.

So, flexibility in utility = good thing. Flexibility -> unstructured presentation = bad thing.
Jul. 25th, 2006 12:03 am (UTC)
Re: ws = sin
"One of the desireable features of Python is that the code style is mandated by the language"

you should join the army
Jul. 26th, 2006 05:57 am (UTC)
whitespace-delimiting languages are evil and should be put down.

I'd forgotten about that. I found that aspect of Python annoying.
Jul. 24th, 2006 01:31 pm (UTC)
I had to use it in a graduate school CS course. It was interesting. I thought that the flexibility made it difficult to judge the code by anything other than its output. However, our teacher was laid back and judged it that way. Actually, he hated grading things.
Jul. 24th, 2006 03:13 pm (UTC)
Why Python is Cool
So, as an alternative viewpoint, here is why some people think Python is a great teaching language:

Jul. 24th, 2006 04:12 pm (UTC)
A good teaching language requires discipline; Python, Java, C$, and others are powerful languages that reward students too early. Students need to be punished for carelessness; they deserve segmentation fauls/general protection errors when they mess up. With medieval thinking, would you let a youngster drive a hummer first? No, you let them drive a wagon, a ford fiesta, or a geo metro; they will learn that their driving influences whether or not they live or die. They will learn that others (library writers) influence there living potential. They learn because they are in a constant state of alert.

Powerful languages throw exceptions telling a student where something bad happened; that is too convenient. Students need to learn how to bisect code to find errors. Students need to know the costs of allocating resources. Students should know that if they open a file, then they should close it. Students need to learn how to walk in the path of giants to grow up to become a giant.

In the same way that math majors start from the beginning and work their way up, computer science majors should start at the beginning (assembly or C) and work their way up (to, C# and Ocaml).

If anything, we may want to use a powerful language to persuade potential students into joining the ranks of the faithful. This trickery can produce false hope at the later levels (as we hath seen).

It is a daunting task for a teacher to try to explain the eccentricities of C to a novice. It is a daunting task for a student to try to understand a language like C/C++. But, since when have the faithful ever been shy about daunting tasks?
Jul. 24th, 2006 04:26 pm (UTC)
I disagree that students should work strictly low to high level. In my opinion, they should learn both a low-level (C or assembler) and a high-level language (scheme or lisp) at approximately the same time, such that they can be mentally flexible enough to use whatever language is appropriate to the task. There are certainly some very powerful ideas that they should master that are poor to communicate in C or assembler.
(Deleted comment)
Jul. 24th, 2006 04:35 pm (UTC)
Re: to an extent.
The risk is that they don't realize the need for a new language. One is not only cultivating skills, but cultivating taste.
Jul. 24th, 2006 05:00 pm (UTC)
Re: to an extent.
it is the responsibility of an instructor to make the student go 'crap', this would be a waste of time to do in this low language and then introduce a new language that solves the problem.

There are definite reasons for using a functional language over C# (or Java). And there are reasons for using C# over C++, etc... etc... Its important for students to understand the role of languages (and hence, language theory) in computer science.

At the end of a 4-year program, I believe that any student should be able to
1) write a basic compiler tool (reg-ex to DFA conversion, grammars)
2) write an compiler for a C'like language
3) write an interpreter for an ML’like language

If a student can’t do 1-3, then they are not a real computer scientist. A programmer has the luxury of having a taste for a programming language; a computer scientist must have the discipline to make a programming language well.
Jul. 24th, 2006 05:14 pm (UTC)
Re: to an extent.
I am not at all interested if a student could do any of these tasks by rote, or had actually done them before. They should upon assignment, be able to complete them with a reasonable quality, and in a reasonable period of time. They should be able to find the resources necessary to solve them. They should also be able to do new tasks with a sensitivity towards what consititues a good solution. It is not enough to see ugliness: they should be able to imagine elegance.

Jul. 24th, 2006 05:38 pm (UTC)
Re: to an extent.
you should be! once we have basic concepts down by rote, we are able to freely associate and think without needing to find resources. In essence, we become a resource. Once you have a language and some concepts down by rote, you can ask questions as to why the languages are they way they are. Why the concepts are. These are crucial to understanding the evolution of languages. The more facts we can stuff in our head - the better our understanding becomes. This way, we avoid the 'fan-boy'/taste of a language.

I want to encourage my students to be able to learn a language within a day, but that is impossible without a good grasp of range from low to high languages and evolution of such. When you get frustrated with C, you remember. When you blow your leg off with C++, you remember. When you study language theory, you will see why the choices were made the way they were. Once you see that, its not a story some professor tells you; its an experience and thus you learn.

I want to encourage my students to be able (by rote) to write an interpretter in a day from scratch. The techniques and concepts involve are rewarding in and of themselves, and they migrate to every aspect of programming. Superior programmers don't confine themselves in one language, they embrace an internal language that dictates how a problem must be solved. If the problem demands Lisp, then so be it, Lisp. If the problem demands C#, ...
Jul. 24th, 2006 05:45 pm (UTC)
Re: to an extent.
Hmm, I do agree that there is a power that comes from fluency. Certainly, being able to use a tool where having the right action always comes to mind is nice. It is essential to know what is there, why it is there, and what the alternatives are. Such comparisons are the basis for synthesizing new solutions and evaluating them.

At the same time, strict rote learning still seems unnecessary, and also a barrier that would irritate me. So, if I forget the parameter to a library function? So what? I look it up and life goes on. But having it demanded? Screw it, I'll work for people who care about my taste, not what I've memorized.

Jul. 25th, 2006 12:17 am (UTC)
Re: to an extent.
strict rote learning of a library would be unnecessary. Rote learning of practices and structures of how things operate. Everyone should be able to read code in any programming language. Rote learning on a good set of languages (assembly, C/C++, C#/Java, Ocaml) gives people the ability to see the practices used at each level and to be competent at reading a new language (say, Python) without even looking at the language manual.
Jul. 25th, 2006 02:01 am (UTC)
Re: to an extent.
Ah, I think we are on a common ground, differing only to the degree where we draw a fuzzy line between pure memorization and rigorous grasp of the constructs and their usage.

I am not as committed to standardizing projects, given the requirement that those leaving the program are still able to perform them in nearly the same timeline and quality, particularly if they have additional relevant skills to many of the programming domains in question. For example, if I find a student who can design user-interfaces in any language, do usability studies, rapidly prototype interface, has numerous data visualization projects under their belt, and is otherwise a good all-around developer with solid writing and communicating skills, but has never written an interpreter to a functional language, for the vast, vast majority of projects, I would hire them immediately nonetheless. I respect, although not understand your decision, if you feel otheriwse.
Jul. 24th, 2006 04:33 pm (UTC)
to an extent.
when they learn C/assembler, they would work with simple ideas; they should transition to a new language once they realize the need for a new language. For instance, progressing from
assembler -> C -> C++ -> C# -> Ocaml
would be most instructive as it allows the powerful ideas to be expressed easily in Ocaml but obtain the discipline and basics from harder languages.
Jul. 24th, 2006 04:23 pm (UTC)
1. Is it a good teaching langauge?
2. A good general-purpose language?
3. Is it "better" than C/C++ or Java?

I have hardly used python, but that doesn't prevent me from having an opinion:

1. http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html It's a fine "portfolio" language. I wouldn't use it until the students had both a lower-level language and a functional language under their belt.

Jul. 24th, 2006 07:39 pm (UTC)
A friend replaced a thousand-line Java app (mine, sort of) w/ a 200 Python app... the Python version started up and ran faster, and it ran on NetBSD and XP w/ no problems. It's the reason I'm currently thumbing through the Python tutorial.

IMO, any serious programmer will end up learning Python on their own, so it probably shouldn't be the first language they learn...
Jul. 24th, 2006 09:20 pm (UTC)
1. It depends on the aim of the class. If the aim is to encourage and nuture students, then "yes". Using Python, students can quickly see rewards and have postitive reinforcement. If the aim is to "break" students and challenge them until they get a "eureka" moment, then "no". A compiled language that gives more control over details like C or C++ would be sufficient.

2. As a general-purpose language, I think Python is excellent for prototyping programs. My experience is that 1 line of Python code is equivalent to about 5-10 lines of Java/C/C++. This makes me much more productive. I also like the fact that there is a small set of keywords (about 20). The language is expressive without providing thousands of ways to shoot oneself in the foot (Perl).

3. I think Python is better if the performance constraints fit your task. It is not the fastest language out there, nor does it claim to be. It is what it is. It is great for prototyping or getting a working version running quickly. My experience has been that the performance cost is worth the development time gains.

As a whole, I prefer Python to other languages (for above reasons). The whitespace syntax takes some adjustments, but most common formatting conventions already indent, so it's not that unconventional, although a lot of people do get hung up on it. Just use a good editor and everything will be taken care of. Also, it helps if you set your editor to convert tabs into spaces.
Jul. 25th, 2006 12:46 am (UTC)
Python is a lot of fun for its incredible flexibility and its easy adaptation to a number of paradigms, namely: procedural, functional, and object oriented. The idea that you can mutate all of the properties of a class or module at runtime is very sexy, along with its excellent list, dictionary, and lambda support.

I am doing all of my hobby programming in it at the moment. But then, I do not do anything particularly mind-blowing or sophisticated. I do hope it picks up as more of a web-language than PHP, Perl, or Java. But as someone already posted, it is very easy to do stupid things with it.

I do not think that it is a good teaching language, because I think that C is a good teaching language.

As a good very very high level general-purpose language? Sure -- why not? But better than Java or C or C++? As always, depends on what you are doing with it.
Jul. 25th, 2006 07:42 am (UTC)
Most certainly
1. Is it a good teaching language?

I've found that demonstrating and teaching in Python is fantastic for a number of reasons:

First, emphasis on the important concepts, not the environment. Thanks to the flexible nature of the scripting environment, one can typically explain or demonstrate a concept (regardless of complexity) very succinctly. Often when demonstrating a concept in Java (or C), tangent after tangent must either be tackled or the student told "ignore this and we'll come back to it later", be it additional keywords or boxing or over-engineered libraries.

Second, the enforcement of style. While several posters have lamented the whitespace sensitivity, I find it a huge boon for both readability and collaboration. It's true what the zengeneral says about "finding your style", but the problem is that there are too many different styles and often that individual style can be an impediment to other collaborators reading, understanding, and perhaps contributing-to your code. Also, succinct style is something that comes with mastery, not just experience. A learning language that encourages flexible style appears then to be an oxymoron.

Third, tight keywords set and "plain language" feel. Python has something like 22 keywords, few enough that all of them can easily be kept in ones short term memory. Importantly, Python is very easy to read and understand. Indeed, one can actually read Python out loud with very little personal interpretation and it still makes sense. (Try that with Perl...)

Fourth, perfect examples of many computer science problems and questions. Want to teach about memory allocation? You don't need to scrap the garbage collector, try examples of range(1,999999) and xrange(1,999999). Simple abstract data types make examples of quadratic time and logarithmic time algorithms only a few lines apart. Multiple implementations of library modules like pickle and cPickle show the difference in speed an implementation language can make. Or list comprehensions.

Fifth, features from all of the popular programming styles are present allowing quick and painless introduction to procedural, object oriented, functional programming and even aspect oriented programming. (I've never experienced a general purpose language that encouraged experimentation with functional programming concepts like Python's elegant tuples and sequences, they beg to be map, zipped, and unpacked.)

Sixth, Python's inclusion strongly encourages the student to avoid "reinventing the wheel" at every turn. While writing a string parser in C is certainly an enlightening experience, Python doesn't provide any hurdles for a student to branch out and experiment with any programming problem that are interested in without first having to implement tedious prerequisites.

Seventh, thanks to libraries like the gtk/glade library, even doing things like GUI programming can be handled the "right way" right from the start, instead of horrific code generation routines that are common in software engineering courses based in Java.

Eight, well, I could go one with an almost infinite list it seems... but how about the official Python Philosophy as something students could latch onto:

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

A little tongue in cheek at parts, but still some great ideas.
Jul. 25th, 2006 07:43 am (UTC)
Part 2
2. A good general-purpose language?

Most certainly. Python is a huge win if only on readability and maintainability. Inherited code is often destroyer of productivity, but with Python we've never had that problem. We currently use Python for windows client scripting, clustering tools, web programming, applications with a graphical interface, and more.

Importantly, Python isn't just a prototyping language, evidenced easily by the number of applications deployed that use Python. I think it a huge compliment to say that Python is so easy that it's great for prototyping, only to find out that the prototype code is often good enough for production as well!

Also, since premature optimization is evil, Python provides lots of introspection and profiling tools so that you can later profile your code and see what (if anything) truly needs optimized. Those portions can be written and C and easily snapped right back into place with casually generated bindings. Clearly a best-of-both-worlds approach. Incredible productivity with Python coupled with the speed of C *when necessary*.

3. Is it "better" than C/C++ or Java?

Eh, I hate questions like this because there is rarely a "correct" answer. Every language is designed for a purpose and can excel at that purpose. I think a great case study would be Google. They use C++ where speed matters most, Java where they were not actually running the VM but translating it into another language, and Python everywhere else.

Rarely does a project truly need the speed of C++ like Google does, and rarely does a project need to translate into another language in order to be used. So I would say that the General Case makes Python a great choice. And of course, following the Python philosophy: "Special cases aren't special enough to break the rules."

Travis Bradshaw
Jul. 25th, 2006 11:47 am (UTC)
1. Good for teaching OO concepts - though since it has garbage collection it may teach some bad habits as well. I'd suggest it's a much, MUCH better teaching language than e.g. Pascal or C++ though :D

2. Definitely. Even for games! Our core systems (core AI loops, renderer etc) are implemented in C++, and all of the game code is Python. Nice.

3. I would say yes, it's better than C/C++/Java, outside of areas where those ones shine in particular. The rapid development is a huge advantage, particularly in an age where programmer time is generally more valuable than saving a few cycles or a bit of memory.
( 29 comments — Leave a comment )

Latest Month

December 2008

KSU Genetic and Evolutionary Computation (GEC) Lab



Science, Technology, Engineering, Math (STEM) Communities

Fresh Pages


Powered by LiveJournal.com
Designed by Naoto Kishi