473,785 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Article of interest: Python pros/cons for the enterprise

This is part of a series examining the strengths and weaknesses of
various scripting languages, with particular attention to enterprise
(read: big company) use.

You Used Python to Write WHAT?
Python is a powerful, easy-to-use scripting language suitable for use
in the enterprise, although it is not right for absolutely every use.
Python expert Martin Aspeli identifies when Python is the right
choice, and when another language might be a better option.
http://www.cio.com/article/185350
Feb 20 '08
62 2918
On Feb 22, 1:17 am, Jeff Schwab <j...@schwabcen ter.comwrote:
[...]
If you've already got a generic, language-supported way to manage
resources (like RAII with deterministic destruction), then why bother
with garbage collection? I'm not trying to knock it; it was a big step
up from C-style "who forgot to delete a pointer" games. It just seems
to me like a solution to something that's no longer a problem, at least
in well-written C++ code. I'll take destructors over GC any day.
The real point about garbage collection is that it's about the only
way to ensure that an object of one type is never taken to be of
another type, e.g. by keeping around pointers to the object that
occupied its memory before it was reallocated. I believe that this
degree of type safety is worth having, which is why I favour the
addition of optional GC to C++.

Cheers,
Nicola Musatti
Feb 22 '08 #21
Nicola Musatti <ni************ @gmail.comwrite s:
In C++ memory is just another resource which you can handle just like
any other one, possibly using RAII.
Ok, I'll bite. Here's a straightforward Python expression:

a = [f(x) + g(y) for x,y in izip(m1, m2) if h(x,y).frob() == 7]

Consider how many intermediate objects are being allocated in figuring
out that listcomp. Do you REALLY want to manage all the deallocation
with something like RAII?
Feb 22 '08 #22
Nicola Musatti <ni************ @gmail.comwrite s:
The real point about garbage collection is that it's about the only
way to ensure that an object of one type is never taken to be of
another type, e.g. by keeping around pointers to the object that
occupied its memory before it was reallocated. I believe that this
degree of type safety is worth having, which is why I favour the
addition of optional GC to C++.
But in C++, garbage collection makes no such guarantee. Think of
out-of-range subscripts.
Feb 22 '08 #23
On Feb 22, 9:03 am, Bruno Desthuilliers <bruno.
42.desthuilli.. .@wtf.websitebu ro.oops.comwrot e:
Nicola Musatti a écrit :
[...]
So, yes, your big company is
likely to be safer with newbie C++ programmers than with Python newbie
programmers.

Sorry but I don't buy your arguments.
I suspect nobody seriously does, not even in C++ newsgroups ;-)
Had we been speaking of productivity... but we weren't, were we?

Should we ?-)
Oh, I'm convinced that Python wins in many contexts, but I believe
that it has more to do with the number of batteries that come with the
package rather than to its being a dynamically typed language. Is this
controversial enough? ;-)

Cheers,
Nicola Musatti

Feb 22 '08 #24
On Feb 22, 12:09 pm, Paul Rubin <http://phr...@NOSPAM.i nvalidwrote:
Nicola Musatti <nicola.musa... @gmail.comwrite s:
The real point about garbage collection is that it's about the only
way to ensure that an object of one type is never taken to be of
another type, e.g. by keeping around pointers to the object that
occupied its memory before it was reallocated. I believe that this
degree of type safety is worth having, which is why I favour the
addition of optional GC to C++.

But in C++, garbage collection makes no such guarantee. Think of
out-of-range subscripts.
I'm aware that the guarantee would not be perfect. For instance
another source of problems could be holding pointers to local
variables that went out of scope. Yet I'm convinced that even such
partial guarantee is worth having.

Cheers,
Nicola Musatti
Feb 22 '08 #25
Nicola Musatti a écrit :
On Feb 22, 9:03 am, Bruno Desthuilliers <bruno.
42.desthuilli.. .@wtf.websitebu ro.oops.comwrot e:
>Nicola Musatti a écrit :
[...]
>>So, yes, your big company is
likely to be safer with newbie C++ programmers than with Python newbie
programmers .
Sorry but I don't buy your arguments.

I suspect nobody seriously does, not even in C++ newsgroups ;-)
Mmm... Feel like I've been trolled !-)
>>Had we been speaking of productivity... but we weren't, were we?
Should we ?-)

Oh, I'm convinced that Python wins in many contexts, but I believe
that it has more to do with the number of batteries that come with the
package rather than to its being a dynamically typed language. Is this
controversial enough? ;-)
Brillant !-)

Feb 22 '08 #26
In article
<a8************ *************** *******@71g2000 hse.googlegroup s.com>,
Nicola Musatti <ni************ @gmail.comwrote :
Yet I'm convinced that even such partial guarantee is worth having.
Partial guarantees are like being a little bit pregnant.
Feb 22 '08 #27
In article <ma************ *************** ***********@pyt hon.org>,
"Reedick, Andrew" <jr****@ATT.COM wrote:
>
-----Original Message-----
From: py************* *************** ****@python.org [mailto:python-
li************* ************@py thon.org] On Behalf Of Carl Banks
Sent: Wednesday, February 20, 2008 8:39 PM
To: py*********@pyt hon.org
Subject: Re: Article of interest: Python pros/cons for the enterprise
C++ is a compile-time, type-checked language, which means it is
totally safer for newbies than Python. Yep, your big company is
totally safe with newbie C++ programmers.

Eh, don't laugh too hard. Since Python code isn't type-checked until
the actual code block is executed, you have to go through the extra step
of testing/running every line of code before you'll find an error.
Then there's the problem of how mutable Python objects are. So even if
you execute every line of code, you might not have executed the code
with every possible type of object combination.

Compared to a statically typed language, it can get very expensive to
write comprehensive test cases for python scripts. So I wouldn't be
quick to dismiss the notion that Java/C#/C++ are more newbie-safe than
Python. =/

An amusing case in point was where I had a type-cast error in an
exception's catch block's print statement. This simple error caused the
program to stop with an unhandled exception. Something that basic would
have been caught in a statically typed language very early in the dev
cycle when it's cheaper to fix the problem. And the idea of
running/testing exceptions or simple print statements isn't always
foremost in people's minds. =P

Well, you're technically right about static typing. That could head off
some bugs... But my experience over several years has been that this has
never happened to me. That is, where I need to test every line of code
or even half of them. What usually happens is that I get an error, I
get the line and module, go there, and realize I tried to use data that
didn't fit the expression (e.g. an object without the required method).
Usually, a one-step fix. What still occasionally gets me is mutable
objects where I just use "=" to set two things (accidentally) equal to a
mutable object instead of copying. Then modify one and get and error
when the other object is used since they were the same object. I know
better, but I have a half life on this of about 4 months which means
that about twice a year this one gets me.

Looking at it the other way having done C++ development, I am w a y
more productive in Python and overall spend far less time debugging.
Just my experience. YMMV.

--
-- Lou Pecora
Feb 22 '08 #28
On Feb 22, 3:25 pm, Roy Smith <r...@panix.com wrote:
In article
<a88eef80-1b0a-4e09-ae46-9fa632bc1...@71 g2000hse.google groups.com>,
Nicola Musatti <nicola.musa... @gmail.comwrote :
Yet I'm convinced that even such partial guarantee is worth having.

Partial guarantees are like being a little bit pregnant.
Yes, and I'm sure your tests cover all possible paths through your
code.

Cheers,
Nicola Musatti
Feb 22 '08 #29
On Feb 22, 5:13 pm, Marc 'BlackJack' Rintsch <bj_...@gmx.net wrote:
On Fri, 22 Feb 2008 04:48:28 -0800, Nicola Musatti wrote:
[...]
As you can see the standard library takes care of all memory
management.

Aaah, that's much nicer and easier to understand than the list
comprehension. After this great example I'll switch to C++. ;-)
You should. As you can see C++ is waaaaay more explicit than
Python ;-)
>
But somehow you still manage memory by writing in a style that favors
value types.
Certainly, but this is a natural C++ programming style, at least for
those that aren't too deeply rooted in their C heritage.

Cheers,
Nicola Musatti
Feb 22 '08 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.