-   Programming (
-   -   Python - worth learning? (

vharishankar 07-03-2005 12:30 AM

Python - worth learning?
I just have a question. I am beginning to learn Python, but so far I've not been impressed with the language structure. It resembles BASIC too much and it's syntax is quite awkward for me coming from a C, C++ background. Also I am uncomfortable with the loose typing (no variable declarations) and so on.

But I have heard many good things about Python. My question to experienced Python programmers is : Is it worth learning Python?

I am familiar with PHP and find it much more comfortable although I haven't really had too much to do using it so far.


redhatrosh 07-03-2005 12:36 AM

I dont really know much about Python and haven't learnt it. But becoz Python is a Object Oriented Programming I feel it is an important language to learn and develop things much better.
Well, I also have one question!

Is Python Cross platform oriented like Java...or how is it functioning actually...(again to all the programmers who are experienced!)

vharishankar 07-03-2005 12:38 AM

Python is an interpreted language and it is cross-platform (to the extent that systems with Python interpreters will run any python program).

I really don't know whether it's object oriented capabilities are superior to Java. At first sight Python's lack of structure or strong typing seems to be pretty much against it.

NCC-1701&NCC-1701-D 07-03-2005 05:13 AM

Every language is worth learning. Pyhton can help you create very good apps, cross platform and it's easier than C/C++/Java. If you have a look at sourceforge you'll see that many projects are in python. Give it a try!

phil.d.g 07-03-2005 05:45 AM

Whilst I don't know python, I know a few friends who do and they love coding in python and think its a great language, I intend to learn python, but one thing at a time - I'm learning C at the moment.

vharishankar 07-03-2005 06:10 AM

Maybe it's just my basic aversion to any language that does not have formal and compulsory variable declaration... :D

Also maybe I am just used to ending all statements with a semicolon :p

Python looks good, but I don't see what it offers beyond Java to be honest. But I'm going to learn it anyway and see what I can do with it.

Any ideas for a good project with python?

Michael Johnson 07-03-2005 07:41 AM

Try a programme to organise you photographs. This will test almost every aspect of your capabilities apart from mutlimedia (unless add sound).
Second thought turn your photographs into a movie and really test your skills.

jlliagre 07-03-2005 09:14 AM


Python looks good, but I don't see what it offers beyond Java to be honest.
You can try Jython or Groovy, for the best of both worlds ...

carl.waldbieser 07-03-2005 12:53 PM

Python is definitely worth learning. It is becoming more and more prevelant as the scripting language of choice in certain areas (e.g. the Ubuntu distro makes use of Python considerably to provide various add-ons like their menu editor project).

The fact that variable types are not decalred is often met with reservation by folks who come from a background of languages that require lots of type declarations. For example, I have a C++ background. I was a little concerned that not having the types of variables explicitly declared might lead to some headaches. But I found that in practice, not declaring the types just saved me a lot of extra typing on the keyboard. A parallel I like to draw is that in modern practice, a lot of emphasis in C++ is being placed on the practice of using templates and meta-programming techniques. The idea is to get the compiler to infer and generate types for you. It turns out that the actual type of an object isn't so important as th fact that it conforms to a set of behaviors that operate on it. It turns out that in Python, this is exactly what you get. Here is a quick example:


template<typename T1, Typename T2, Typename T3>
T3 add(T1 t1, T2 t2)
  return t1 + t2;

def add(t1, t2):
  return t1 + t2

What is interesting in both these cases (C++ and Python), is that the types of the operands are not particularly significant. What is important is that you must be able to add the first and second parameters together and return the result. In C++, the compiler will catch this problem at runtime if the types don't support the addition operator (+). In Python, the error is caught at runtime with a nice, built-in stack trace. The fact that I can focus on coding the problem at hand rather than focusing on the syntax of what I want to describe more than makes up for the early constraint checking, in my opinion.

Also, Python is considered a very straightforward language with very few surprising idioms. This makes it easy for someone who does not have a lot of hard-core programming experience to work with the language.

johnMG 07-03-2005 08:12 PM


I'm not a huge fan of Python either. You wrote:

> Python looks good, but I don't see what it offers beyond Java to be honest.

and I'm inclined to say that I don't see what it offers beyond Java either.

In general, scripting languages are for gluing together command line apps and for dealing with text. bash does this pretty well, Perl does it too, and Python can do it well enough also. When you want a general purpose programming language though, I'll head straight for Java. It's not flashy and it's a bit verbose, but for large apps, I think it's the way to go. It seems to me that Pythonistas try to sell Python as a general purpose programming language, but I don't buy it. My hunch is that lack of static type checking at compile time just sets you up for hunting hard-to-find bugs later on at runtime.

BTW, Python is in fact a strongly typed language. Types matter -- it's just that they matter at *runtime*, rather than when you actually compile the code (yes, Python is compiled, just like Java or Perl -- it happens quickly first thing when you run the script). Python is strongly typed, but also *dynamically* figures out the types of objects when required.

vharishankar 07-03-2005 09:16 PM

JohnMG thanks for that interesting bit of info.


vharishankar 07-04-2005 05:53 AM

Success. I learnt two new things today. :D :D

Python and ncurses with Python.

I developed a tiny little 'thought for the day' program using it, reading lines from a file and randomly displaying any one of them in a terminal window.

It is a bit like fortune program, but this is displayed in an ncurses window with a blue screen.


Python tends to grow on you. But I still am not convinced of its true 'object' oriented nature though.

carl.waldbieser 07-04-2005 12:55 PM

Not sure what you mean by "...true 'object' oriented..." nature. I have observed the object-oriented model is somewhat vague and open to various interpretations. There are certainly commonalities throughout various languages, but it is hard to say "here is archetypical example of object-orientedness".

Python provides multiple avenues of approaching programming. OOP is one valid approach, but I have seen procedural and functional approaches used as well.

Tinkster 07-04-2005 01:03 PM


Originally posted by carl.waldbieser
"here is archetypical example of object-orientedness".

I'd most certainly say that smalltalk does deserve that title ;)


YaHu 07-04-2005 03:25 PM


Originally posted by carl.waldbieser
[B]Python is definitely worth learning. It is becoming more and more prevelant as the scripting language of choice in certain areas (e.g. the Ubuntu distro makes use of Python considerably to provide various add-ons like their menu editor project).

Python's nice, but if you don't need the Python libraries I prefer Ruby.
OTOH, Pyrex is a nice extension to python, that lets you easily blend Python, where you want flexibility, with C where you want performance. (Note that there is, as one would expect, overhead in the connection, but if you properly divide things that can be minimized.)

Python doesn't have much in common with Basic...actually, I feel that it has less in common with it than C does. It's mode of structuring code through indentation can take getting used to, but really isn't THAT bad once you get used to it.

Relatively speaking, Python is a slow language. It's certainly no faster than Java. OTOH, writing the code is a lot faster once you get used to it. (There's LOTS of libraries to make some things easy, and slow things fast.)

Worth learning? Depends on your purpose. Languages I currently find worthy are Ruby, Python, D (Digital Mars D == dmd). On the fringe are Eiffel, Ada and Smalltalk. I don't consider either C or C++ as worthwhile because of the mess they cause with their insistance on pointers everywhere. A compiler should HIDE that garbage from you, for two reasons:
1) It's quite easy to make mistakes
2) It makes garbage collection difficult to impossible.
(Note that all of my top tier of languages have garbage collection built in. If you're into hard real-time programming, then you have considerations that make these languages a poor choice.)

It's not that I can't program in C (and a doggerel of C++), it's that I despise doing so. My disgust with pointers didn't come quickly, but only through bitter experience...and trying to figure out what someone's code was doing when he cast a int to a pointer...without decent documentation, and with obscurely named variables.

(All that said, I do prefer C over Basic, but it's a close try...and I prefer Java over either, but even Java didn't make it into the top two levels of what I consider a good programming language. [P.S.: My comment about Eiffel is a couple of years old. The language appears to have been going through a bunch of redesigns recently, and I don't know what the current version is like. The rumors haven't been encouraging, so perhaps it should be moved down below the second tier...but it DOES have garbage collection.])

All times are GMT -5. The time now is 07:36 AM.