Forum Moderators: coopster & phranque

Message Too Old, No Replies

Python, who's using it and why

Looks like Perl & Java glued together

         

mdharrold

9:36 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



I decided to see what Python was all about and have read several tutorials. I also read a Perl vs. Python tutorial but have yet to find anything that says "Perl is best for this while Python is best for that".
So,
What is everyone here using Python for?
Is it better than Perl for anything? If so, What?

bird

10:37 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From a low level technical point of view, Python is very similar to Perl. The probably biggest technical difference is that the object oriented features of Python are more integrated into the language, while they more feel like tacked on from the outside with Perl (5.0x). Java has bigger differences, as it absolutely enforces object orientation whether it makes sense or not, while Python and Perl can both be used in a purely procedural way as well.

All three are general purpose languages that compile the source code into a platform independent bytecode format. While Java forces you do that compilation manually before you can run anything, Python does that automatically on execution and also stores the resulting bytecode for later resuse, and Perl only uses ist bytecode internally without ever showing it to the user (that I know of, anyway).

There are very few things that couldn't be done with any one of the three languages by principle. The main difference is in the style of each of them, and in the types of developers that are attracted to them. Java attracts the corporate drones that fall for all the popular buzzwords, Perl is for people who want to feel like l33t h4x0rz, while Python is mostly used by those who simply want to get their job done. I hope my bias doesn't shine through too heavily here... ;)

The primary advantage of Python is that it is extremely easy to read, understand, and learn. The main design goals were simplicity and elegance. The object orientation is fully integrated into the language, without standing in your way when you don't need it (the same is true for other advanced features). It is also very easy to combine Python with other languages, and to write extensions in C or C++ when some parts of your application need more performance than an interpreted language can deliver, both of which can be a pain with Perl and Java.

In other words, your last question is likely to remain unanswered. The more interesting question is rather whether your mind is ready for the pythonic way to do things. The Python culture [python.org] makes programming easy for those who enjoy contemplating the following design principles, and hard for those who don't:

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!

[edited by: bird at 11:01 pm (utc) on July 15, 2002]

mdharrold

10:50 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



Thank you, Bird.

bird

11:06 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh, and to answer your other question, I use Python for pretty much everything. I sell a software product that consists (among other things) of almost 40k lines of Python code, and interfaces with large commercial and noncommercial third party software packages.

It is also interesting to note that Python is a very "expressive" language, which means you need very little code to implement a certain amount of functionality. On average, the functionality of one line of Python would require something between 5 and 10 lines of C/C++ (similar ratios are probably reachable with Perl, but not with Java).

volatilegx

11:35 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I got a real kick out of that list, bird... I'm a born again Perl programmer and I have to say that I might have to look into Python after your description :)

scotty

10:23 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



I have been using Perl since around '95, however I first tried Python early last year in the company I am working for now, and I am not looking back! It is a very clean and expressive language, that nearly everything is a hash table, and everything is a reference! Unlike Java, where there are primitive types and objects, in Python everything is a reference to objects, and you can even override the methods for an integer in Python 2.2. And unlike Perl (and PHP), where you have deal with value/reference mess - did I pass it in as a value or as a reference? "Everything a hash table" makes introspection easy to do.

The main product we are selling has around 60k lines of Python code (and around 40k lines of C++ and other Java stuff) in the financial planning sector. Python has a nice integration with CORBA using OmniORB, and it allows us to write different components in different languages. However we end up writing most of our stuff in Python because it is so easy to use :)

Lisa

1:01 am on Jul 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To answer your question "who's using it?", one company that uses it is Google. :)

Josk

8:57 am on Jul 17, 2002 (gmt 0)

10+ Year Member



Have you seen Jython? It *is* Java and Python glued together!

Birdman

4:12 pm on Jul 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can anyone recommend a good beginner tutorial on Python.

Knowles

4:26 pm on Jul 19, 2002 (gmt 0)

10+ Year Member



Birdman just a quick search on google came back with "Python Tutorial [google.com]" I cant really comment on how good they are since I have never used any of them. Maybe you can read over a few and report back to us.

bird

5:13 pm on Jul 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The official Python web site has a very rich and complete documentation [python.org] section, with both on site material and external links.

The ODP also has a long list of FAQs, Help, and Tutorials [dmoz.org] to chose from.

Unfortunately, I have no basis to reccommend any of those from own experience. It's a while that I was a newbie, which makes it quite hard to judge the quality of introductory tutorials myself... ;)