Re: Python less error-prone than Java

2006-06-05 Thread Christoph Zwerschke
Ilpo Nyyssönen wrote: > It is not different. Your crash can tell you that it was a null > pointer. Your crash can tell you that you stomped over memory. You > just get the information about the error in different way. Not all stomping over memory must result in a crash. You might just get wrong r

Re: Python less error-prone than Java

2006-06-05 Thread Christoph Zwerschke
Martin v. Löwis wrote: > In Python 2.4 and later, you could write > > def Distance(t1, t0, maxint=(1<<32)-1): > return (t1-t0) & maxint No, this function behaves differently. It never returns a negative value. The only difference in Python 2.4 is that 1<<32 was 0 before. -- Christoph -- http

Re: Python less error-prone than Java

2006-06-05 Thread Martin v. Löwis
Christoph Zwerschke wrote: > Anyway, in Python, you would first define: > > def wrap(x, at=1<<31): > if x < -at: > x += at*2 > elif x >= at: > x -= at*2 > return x > > Then, the Python program would be as simple: > > Distance = lambda t1,t0: wrap(t1-t0) In Python 2.4

Re: Python less error-prone than Java

2006-06-05 Thread Martin v. Löwis
Ilpo Nyyssönen wrote: >> Buggy library code is what prompted that article. > > Yes, but it is an error type that happens very rarely still. And so it > seems that very few programs even notice that bug in that library. That's certainly the case. The bug went unnoticed in the Java library for nea

Re: Python less error-prone than Java

2006-06-04 Thread Ilpo Nyyssönen
"Kaz Kylheku" <[EMAIL PROTECTED]> writes: > Buggy library code is what prompted that article. Yes, but it is an error type that happens very rarely still. And so it seems that very few programs even notice that bug in that library. > Except when you feed those programs inputs which are converte

Re: Python less error-prone than Java

2006-06-04 Thread Christoph Zwerschke
nikie wrote: > Hm, then I probably didn't get your original point: I thought your > argument was that a dynamically typed language was "safer" because it > would choose the "right" type (in your example, an arbitrary-pecision > integer) automatically. No, my point was not to make a general sta

Re: Python less error-prone than Java

2006-06-04 Thread Alan Morgan
In article <[EMAIL PROTECTED]>, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: >>> Simon Percivall wrote: First: It's perfectly simple in Java to create a binary sort that sorts all arrays that contain objects; so wrong there. >>> My point was that the *same* Java source example, directl

Re: Python less error-prone than Java

2006-06-04 Thread nikie
Christoph Zwerschke wrote: > nikie wrote: > > Let's look at two different examples: Consider the following C# code: > > > > static decimal test() { > >decimal x = 10001; > >x /= 100; > >x -= 100; > >return x; > > > > It returns "0.01", as you would expect it. > > Yes, I wo

Re: Python less error-prone than Java

2006-06-04 Thread Christoph Zwerschke
nikie wrote: > Let's look at two different examples: Consider the following C# code: > > static decimal test() { >decimal x = 10001; >x /= 100; >x -= 100; >return x; > > It returns "0.01", as you would expect it. Yes, I would expect that because I have defined x as decimal

Re: Python less error-prone than Java

2006-06-04 Thread D H
Christoph Zwerschke wrote: > > See the following web page if you dont find it ;-) > http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html > The point of that is that it did fail. It threw an ArrayIndexOutOfBoundsException exception. But it was just luck that h

Re: Python less error-prone than Java

2006-06-04 Thread nikie
Let's look at two different examples: Consider the following C# code: static decimal test() { decimal x = 10001; x /= 100; x -= 100; return x; } It returns "0.01", as you would expect it. Now, consider the python equivalent: def test(): x = 10001 x /= 100 x -= 100 ret

Re: Python less error-prone than Java

2006-06-04 Thread Christoph Zwerschke
Kaz Kylheku wrote: > You can have statically typed languages with inadequate type safety, > and you can have dynamically typed languages with inadequate type > safety. But the point in this example was that the Java program ironically had the bug *because* Java handles ints in a type-safe way,

Re: Python less error-prone than Java

2006-06-04 Thread Fredrik Lundh
Kaz Kylheku wrote: > The trouble with your point is that Christoph's original posting refers > to an article, which, in turn, at the bottom, refers to a bug database > which shows that the very same defect had been found in Sun's Java > library! and as he points out at the top, it was the article

Re: Python less error-prone than Java

2006-06-04 Thread Christoph Zwerschke
>> Simon Percivall wrote: >>> First: It's perfectly simple in Java to create a binary sort that >>> sorts all arrays that contain objects; so wrong there. >> My point was that the *same* Java source example, directly converted to >> Python would *automatically* accept all kinds of arrays. > > And

Re: Python less error-prone than Java

2006-06-04 Thread Kaz Kylheku
Ilpo Nyyssönen wrote: > This is one big thing that makes code > less error-prone: using existing well made libraries. > You can find binary search from python standard library too (but actually the > API > in Java is a bit better, see the return values). > Well, you can say that the binary search

Re: Python less error-prone than Java

2006-06-04 Thread Peter Otten
Kaz Kylheku wrote: > Would that be a case-insensitive lexicographic comparison, or > case-insensitive? How do you specify what kind of less-than and equal > you want to do? class Key(object): def __init__(self, value, key): self.keyval = key(value) self.key = key def __lt_

Re: Python less error-prone than Java

2006-06-04 Thread Kaz Kylheku
Christoph Zwerschke wrote: > You will often hear that for reasons of fault minimization, you should > use a programming language with strict typing: > http://turing.une.edu.au/~comp284/Lectures/Lecture_18/lecture/node1.html Quoting from that web page: "A programming language with strict typing an

Re: Python less error-prone than Java

2006-06-03 Thread Ilpo Nyyssönen
Christoph Zwerschke <[EMAIL PROTECTED]> writes: > What's better about the Python version? First, it will operate on > *any* sorted array, no matter which type the values have. > > But second, there is a hidden error in the Java version that the > Python version does not have. While I can see your

Re: Python less error-prone than Java

2006-06-03 Thread Alan Morgan
In article <[EMAIL PROTECTED]>, Neil Hodgson <[EMAIL PROTECTED]> wrote: >Alan Morgan wrote: > >> Since Java doesn't allow function overloading that clearly can't be >> the way. J2SE 5.0 allows generic classes and functions that operate >> on generic containers. There are some gotchas, but it's n

Re: Python less error-prone than Java

2006-06-03 Thread Neil Hodgson
Alan Morgan wrote: > Since Java doesn't allow function overloading that clearly can't be > the way. J2SE 5.0 allows generic classes and functions that operate > on generic containers. There are some gotchas, but it's not drastically > more complex than the original int-only java code. Doesn

Re: Python less error-prone than Java

2006-06-03 Thread Alan Morgan
In article <[EMAIL PROTECTED]>, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: >Simon Percivall wrote: > > First: It's perfectly simple in Java to create a binary sort that > > sorts all arrays that contain objects; so wrong there. > >My point was that the *same* Java source example, directly conv

Re: Python less error-prone than Java

2006-06-03 Thread Christoph Zwerschke
Cameron Laird wrote: > So, here's my summary: Python's a nice language--a very nice one. > It's safer to use than Java in many ways. Python's typing is > STRICTER than Java's, but it's also dynamic, so people get to argue > for decades about which is a better model. Anyone who thinks typing > i

Re: Python less error-prone than Java

2006-06-03 Thread Christoph Zwerschke
Simon Percivall wrote: > First: It's perfectly simple in Java to create a binary sort that > sorts all arrays that contain objects; so wrong there. My point was that the *same* Java source example, directly converted to Python would *automatically* accept all kinds of arrays. No need to make a

Re: Python less error-prone than Java

2006-06-03 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: >You will often hear that for reasons of fault minimization, you should >use a programming language with strict typing: >http://turing.une.edu.au/~comp284/Lectures/Lecture_18/lecture/node1.html > >I just came across a

Re: Python less error-prone than Java

2006-06-03 Thread Alex Martelli
Simon Percivall <[EMAIL PROTECTED]> wrote: ... > with static typing. The equivalent in Python would have been if an > overflow exception was raised when the int got too big. It might have > been that way, typing or no typing. Indeed, it _used_ to be that way --

Re: Python less error-prone than Java

2006-06-03 Thread Simon Percivall
Actually, you're wrong on all levels. First: It's perfectly simple in Java to create a binary sort that sorts all arrays that contain objects; so wrong there. Secondly: The bug has nothing to do with static typing (I'm guessing that's what you meant. Both Python and Java are strongly typed). The

Python less error-prone than Java

2006-06-03 Thread Christoph Zwerschke
You will often hear that for reasons of fault minimization, you should use a programming language with strict typing: http://turing.une.edu.au/~comp284/Lectures/Lecture_18/lecture/node1.html I just came across a funny example in which the opposite is the case. The following is a binary search al