Python compared to other language

S

scott

Hi all,

I have been looking at the various programming languages available. I
have programed in Basic since I was a teenager and I also have a basic
understanding of C, but I want something better.

Can anybody tell me the benefits and weaknesses of using Python?
 
B

Beliavsky

Hi all,

I have been looking at the various programming languages available. I
have programed in Basic since I was a teenager and I also have a basic
understanding of C, but I want something better.

Can anybody tell me the benefits and weaknesses of using Python?

That question has been asked hundreds of times here -- read the
archives of this group and language comparisons on the web, for
example the one by Eric Raymond at http://www.faqs.org/docs/artu/languageschapter.html
..

Even better, try the language and draw your own conclusions.
 
L

Larry Bates

scott said:
Hi all,

I have been looking at the various programming languages available.
I have programed in Basic since I was a teenager and I also have a basic
understanding of C, but I want something better.

Can anybody tell me the benefits and weaknesses of using Python?
Search the archives, this question has been covered many times.

That said I'm going to list some benefits below:

Python is Portable - C is probably the only more portable language

Python is Powerful - You can write everything from simple scripts to
daemons, Windows Services, Windows COM objects, web frameworks, GUI
or console programs. Again only C has that much range. On Windows,
Delphi comes close, but try to move a Delphi program to Macintosh or
even to Linux. I've merely copied Python programs from one OS to
another and they have run without so much as a single change.

Python has strong standard library - The standard library contains many
modules that you would have to purchase with other languages. This
adds to portability because many features are standard and don't
require additions.

Python is maintainable - Python coerces you into writing better code.
From the required indention of blocks to the rich built in data types
it provides a programmer with tools that you use over and over. I've
gone back to programs that I wrote 5+ years ago an it was remarkable
how quickly I could remember what I was doing.

Python is a strongly typed but dynamic language - I have always hated
the fact that you have to define everything in other languages. In
Python you define something when you need it and the definition is
implicit in hat you point to with a variable name. The introspection
that Python provides also lets you do some really powerful things
because you can make your code self-aware. While compiled languages
have their place, give me Python for my daily work. If I find myself
needing more performance in my code, I isolate that code into an
external C library and call it from Python. The data types that are
provided by Python (lists, tuples, dictionaries) are exactly what
programmers need. If you don't have a datatype that you want, its
easy to create one using Python classes.

Python has strong group of helpful users - This list is amazing. Post
a question and you get not one but several answers to even the most
complex of inquiries. This list provides the BEST technical support
of any language I've ever used in my 30+ years of programming many
different languages.

Python allows me to get really good at one language - Since I can do
almost anything that I can dream up in Python, I find I write almost
100% of my code in Python. This means that I am getting better at
Python not learning lots of other languages which I will never know
well.

I hope you find the information at least helpful.

Regards,
Larry
 
C

Cameron Laird

That question has been asked hundreds of times here -- read the
archives of this group and language comparisons on the web, for
example the one by Eric Raymond at
http://www.faqs.org/docs/artu/languageschapter.html
.

Even better, try the language and draw your own conclusions.

"... [T]ry the language and draw your own conclusions" is better
advice than the original questioner might realize, for he doesn't
yet know how low is the cost to get started with Python <URL:
http://www.awaretek.com/tutorials.html >.

In the meantime, <URL:
http://wiki.python.org/moin/LanguageComparisons > might be of
interest.
 
S

Stef Mientki

scott said:
Hi all,

I have been looking at the various programming languages available.
I have programed in Basic since I was a teenager and I also have a basic
understanding of C, but I want something better.

Can anybody tell me the benefits and weaknesses of using Python?

hi Scott,
coming from Basic, I think Python might be a very good (maybe even thé best) choice.

I've been searching for the past few years for a universal language,
in which I can do everything, whether it's
- a normal (graphical) user application,
- a program which is downloaded in a small micro-controller
- an interactive webpage design
- performing educational / scientific calculations
now this can all (well almost) be done in Python.
(a year ago I thought it was PHP,
but it can't do small micros and scientific work)

The major disadvantage of Python,
(at least if you compare it with Visual Basic, Delphi, Kylix, Lazarus),
is the somewhat limited (or more difficult) building of a graphical user interface.

I've rewritten a few pieces of code from both MatLab and Delphi (comparable with Basic),
into Python,
and it's really great,
number of sourcecode lines decreased to about 30% !!

But as others said, try it yourself.

cheers,
Stef Mientki
 
S

scott

Thank you everyone for your help. I will make sure to check the
archives, something I should have done first :)

--
Your friend,
Scott

Sent to you from a 100% Linux computer using Kubuntu Version 7.04
(Feisty Fawn)
 
W

walterbyrd

Python is Portable - C is probably the only more portable language

Small quibble: IMO, although C runs on many platforms, I don't think C
code is typically portable between platorms. Unless you are doing
something very simple. If you write something with Visual Studio to do
something fairly advanced on Windows, I don't think the same,
unmodified, code will usually run on UNIX, or MS-DOS. Maybe if you use
pure ANSI C, but I don't think many people do that.

I'm just learning Python. FWIW: my opinions about Python:

- good for many things, but probably not the most popular for any one
thing. For example: PHP is more popular for web-dev, Perl is more
popular for sys-admin.

- IMO: the most comparable language to Python, is Perl. Both are
scripting languages. Both are free, multi-platform, and multi-purpose.
Both are also very popular.

- although good for beginners, Python is also used for some very
advanced stuff.

- IMO: people are more likely to switch from Perl, to Python, than the
other way around.

- Python is generally considered to be more readable than Perl, and
thereby, more maintainable.

- I have managed to be fairly productive with Python in a very short
time, if I get good at Python, I think I could be very productive.

- although Python is considered one of the most popular languages,
jobs as python programmers seem to be very rare. I think Python is
often used as a tool by people who specialize in other things: data
analysts, scientists, systems administrators, database administrators,
software testers, etc.

- some will tell you that you don't need to know anything about object
oriented development to use Python. But, I don't think you will get
far without some OO.

Just my $0.02
 
S

Steve Holden

walterbyrd said:
Small quibble: IMO, although C runs on many platforms, I don't think C
code is typically portable between platorms. Unless you are doing
something very simple. If you write something with Visual Studio to do
something fairly advanced on Windows, I don't think the same,
unmodified, code will usually run on UNIX, or MS-DOS. Maybe if you use
pure ANSI C, but I don't think many people do that.
Surely the fact that Python is available on so many platforms implies
that C is a fairly portable language. I realise that you have to take
platform specifics into account much more than you do in Python, but I
do feel you are being somewhat unfair to C.
I'm just learning Python. FWIW: my opinions about Python:
[ ... ]

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------
 
A

Alex Martelli

walterbyrd said:
- IMO: the most comparable language to Python, is Perl. Both are
scripting languages. Both are free, multi-platform, and multi-purpose.
Both are also very popular.

I think that Ruby, which roughly speaking sits somewhere between Python
and Perl, is closer to Python than Perl is. Judging popularity strictly
by the number of hits on search engines, it seems to be in the same
ballpark as Python and Perl.


Alex
 
W

walterbyrd

Surely the fact that Python is available on so many platforms implies
that C is a fairly portable language.

Unless it's the same C code, I don't see how that means anything. If I
write an app on Windows with C, and I rewrite the same app on UNIX
with C - that doesn't mean the C code has been ported.

My guess is that some of the C code used to develop Python is the same
between the different Python distros, but much of the code is unique
to the particular platform. If that is the case, then the C code may
not be very portable.

But, I can often take the same python code, and run it on MacOS,
Linux, FreeBSD, and Windows. Often I can do this even if the app has a
gui interface.
 
W

walterbyrd

I think that Ruby, which roughly speaking sits somewhere between Python
and Perl, is closer to Python than Perl is.

I don't know much about Ruby, but it does not seem to be commonly used
for anything other than web-development. It may be that Ruby could be
used for other purposes, but I don't seem to see it happen much.

I know that PHP can used at the command line, and could be used for
the same sort of sys-admin tasks for which, Perl and Python are often
used, but I don't seem to see that happening either.

I'm not sure if Ruby, or PHP, are as general purpose as Perl or Python.
 
G

Gabriel Genellina

My guess is that some of the C code used to develop Python is the same
between the different Python distros, but much of the code is unique
to the particular platform. If that is the case, then the C code may
not be very portable.

Well, your guess was wrong. The core CPython code is the same on all
platforms; of course it uses #define/#ifdef/etc. where appropiate, but
it's not a mess, and not so much code is conditionally compiled.
The Python developers take special care on portability - the C language
itself (C89 is currently used) is pretty standard, but you have to be
careful on how you write your code.
But, I can often take the same python code, and run it on MacOS,
Linux, FreeBSD, and Windows. Often I can do this even if the app has a
gui interface.

Because someone has taken out all the differences, so you don't have to
struggle with them yourself. GUI toolkits: some libraries "draw" the whole
thing and manage all the user interaction themselves so they're basically
portable but never have the native "look&feel" (tcl/tk); other rely on the
native buttons and controls for each platform, but providing a homogeneous
view for the programmer (wxWidgets). Anyway, they work across platforms
because "someone" has already worked on the differences for you - using C.
Both menctioned libraries are written in C (wx in C++), and Python
provides a convenient wrapper for them.
Even on the Python side, some libraries do one thing or another depending
on the platform (cf: subprocess). The good thing is that *you* as a
developer, don't have to worry about the differences; many are managed by
Python itself internally, and many are worked on by other people on top of
this. webbrowser.open('your favourite url') "just works" and does "the
right thing" because of these efforts.
 
S

Steve Holden

walterbyrd said:
Unless it's the same C code, I don't see how that means anything. If I
write an app on Windows with C, and I rewrite the same app on UNIX
with C - that doesn't mean the C code has been ported.

My guess is that some of the C code used to develop Python is the same
between the different Python distros, but much of the code is unique
to the particular platform. If that is the case, then the C code may
not be very portable.

But, I can often take the same python code, and run it on MacOS,
Linux, FreeBSD, and Windows. Often I can do this even if the app has a
gui interface.
Perhaps you could try a more constructive approach in future.

The reason you can do this with Python is precisely because the
developers have ironed out the wrinkles between platforms by putting the
requisite conditionals in the C source. Which, by the way, is open in
case you ever feel like answering your own questions.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------
 
A

Alex Martelli

walterbyrd said:
I don't know much about Ruby, but it does not seem to be commonly used
for anything other than web-development. It may be that Ruby could be
used for other purposes, but I don't seem to see it happen much.

I know that PHP can used at the command line, and could be used for
the same sort of sys-admin tasks for which, Perl and Python are often
used, but I don't seem to see that happening either.

I'm not sure if Ruby, or PHP, are as general purpose as Perl or Python.

PHP was definitely born _for_ webpages; Ruby wasn't, just like Perl or
Python weren't, it just became very popular for webpages when Rails
appeared.

so i tried search queries for [ intitle:X intitle:Y ] where X is each of
various languages and Y one of two words connected with non-web
traditional application programming, and these are the number of hits I
saw:

Y==scientific:
perl 334
python 703
ruby 452
php 423
java 2370
c++ 3340
fortran 3200

Y==payroll:
perl 81
python 1
ruby 8
php 176
java 382
c++ 101
fortran 1

From these numbers it would seem that Ruby (and PHP) aren't really more
web-specific than Perl (and Python).

In general, these days, when you're interested in how popular each of a
certain set of technologies / subjects is, search engines can come in
handy (with due precautions, of course: for example, "php" appears in SO
many web pages (2.5 billion, vs e.g. 282 million for java) that you need
to restrict it cleverly (e.g., I used the intitle: attribute -- that
gives 20.1 million for php vs 21.4 million for Java, and biases numbers
towards pages that in some sense are "about" that technology rather than
just happening to mention it as an aside, a part of an URL, etc:). "c"
is very hard to search for because many occurrences of that single
letter have nothing to do with the language (here you may try quoted
sentences such as "c programming": without precautions, "c" has 2.86
billion hits, but "c programming" 1.22 million vs 1.09 million for "java
programming", which again puts things in better perspective). I say
"technology" because this doesn't apply to just programming languages:
e.g., "COM", a classic Microsoft technology for component
interconnection, is swamped by the homonimous occurrence of ".com" in
URLs, so you need the intitle: trick or something like that.

An interesting alternative would be to use search engines which do
semantic annotation, but I'm not very familiar with those, myself; I'd
be interested in details if anybody does try that.

Anyway, if you're interested in popularity issues, I believe these
techniques, for all their defects, will work better than asking a few
people or trying to generalize from unsystematic observations.


Alex
 
W

walterbyrd

The reason you can do this with Python is precisely because the
developers have ironed out the wrinkles between platforms by putting the
requisite conditionals in the C source.

But that is my point. With Python, the language itself takes care of
the platform differences, so the same Python code will run on
different platforms. I realize that, at a lower level, everything is
done is C. But, from the developers point of view: developing code in
C requires more attention to platform specifics, than does developing
code in Python.
 
W

walterbyrd

From these numbers it would seem that Ruby (and PHP) aren't really more
web-specific than Perl (and Python).

Excellent find, nice work. However, if it is found that there are "X"
many PHP programs running payroll applications, does that mean that
those PHP programs are *not* web applications? I don't think that it
does.

I was surprised to see Ruby in the same catagory as Perl and Python,
when it came to Scientific apps. I always thought of Ruby as being
used for database oriented web-based stuff. Just goes to show what I
don't know.

I can tell you this much for sure: when it comes to UNIX system
scripting, Perl is the leader, with Python as a solid second. Unless,
maybe, you count bash & bourne, which I don't because those are not
multi-purpose languages.
 
S

Steve Holden

walterbyrd said:
But that is my point. With Python, the language itself takes care of
the platform differences, so the same Python code will run on
different platforms. I realize that, at a lower level, everything is
done is C. But, from the developers point of view: developing code in
C requires more attention to platform specifics, than does developing
code in Python.
That I can agree with, but it isn't the same as "not portable". It
would have been better to say "more difficult to port".

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------
 
M

Michael Torrie

Surely the fact that Python is available on so many platforms implies
that C is a fairly portable language. I realise that you have to take
platform specifics into account much more than you do in Python, but I
do feel you are being somewhat unfair to C.

This is now going off-topic. Cross-platform code is a matter of mindset
and toolset. It's very possible to write python code that is *not*
cross-platform compatible. Perhaps it relies a specific behavioral
quirk of the platform. Or maybe it uses modules that only exist on a
platform. For example, you can do very low-level COM or even Active X
programming using python. That certainly wouldn't run on Linux. The
same can be true of some python code that's only intended to run on
Posix systems. You may have assumed a certain directory character
separator, for example (of course the os module can give you a portable
way of not making this assumption).

I write cross-platform C code all the time. I do it by carefully
choosing my libraries (toolset) and then try to code making as few
assumptions as possible. Platform-specific code is generally less than
6% of the total code. I even wrote a cross-platform python module in C.
It's no big deal. Recently I wrote a medium-sized C++ application using
Qt. The platform-specific code (basically a few minor things Qt doesn't
do for me) is 10 lines total, out of many thousands of lines of code.
The apps compiles and runs on Linux, OS X, and Windows. I plan to write
the next version in Python, but I'm still not sure what GUI toolkit to
use. wxWidgets just doesn't sit well with me, Qt's licensing doesn't
fit my client (I can't afford the non-GPL version), and GTK isn't there
on OS X.

Python, like C, can be used easily to make cross-platform programs.
Python makes it even easier than C because the entire standard python
library of modules is available on every platform, so you don't have to
rely on as many third-party abstraction libraries for threads, sockets,
etc. I think the original poster will find Python, and may wxPython,
satisfies the bulk of his development needs.
I'm just learning Python. FWIW: my opinions about Python:
[ ... ]

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com squidoo.com/pythonology
tagged items: del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------
 
S

scott

Michael said:
I think the original poster will find Python, and may wxPython,
satisfies the bulk of his development needs.
True, I like how Python is a general language that can be used for many
different purposes and hope to learn wxPython as well. I have read
through the archives and found some good suggestions for books/tutorials.

--
Your friend,
Scott

Sent to you from a 100% Linux computer using Kubuntu Version 7.04
(Feisty Fawn)
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

But that is my point. With Python, the language itself takes care of
That I can agree with, but it isn't the same as "not portable". It
would have been better to say "more difficult to port".

Indeed, there are significant chunks (several hundred lines of code)
that are specific to Microsoft Windows; also, there are some modules
(e.g. nis, passwd) which solely run on Unix systems. This code is
inherently unportable. In some cases, there is alternative code for
other platforms, in some cases, there isn't.

In Python itself, the fraction of platform-specific code is still
small (I think - one would have to count to be sure). This is partly
due to Python only using file and network IO from the system, and
these two system-dependent aspects have fairly standard APIs
even on the C level (POSIX in particular).

GUI is much harder - in Tk, the amount of system-specific code is
significant (ca. 80 kLOC specific to either Unix, Windows, or Mac,
compared to 240 kLOC total, for Tk 8.4.7). Fortunately, Python
abstains from implementing its own cross-platform GUI library,
and offloads that burden to third-party libraries.

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top