"Fredrik Lundh" <[EMAIL PROTECTED]> writes: > use assert as the soonest possible point. implementing "type gates" is > trivial, if you think you need them.
What this is about (to me at least) is the edit-debug cycle. Let's say I write some Python code, using assert to validate datatypes. Maybe I've made 4 errors. I then write a test function and run it. Boom, the first assert fails. I fix the first error, run again. Boom, the next assert fails. Fix the next error, run again, boom, fix, etc. Four edit-debug cycles. With static typing, I run the compiler, get 4 error messages, fix all 4, and can get on with the next phase of testing with three fewer edit cycles. That's a definite benefit of languages like Java. It's not imaginary. Unit tests on Python code don't make it go away. I have less Java experience than Python experience by now, but I still find that Java programs take me fewer iterations to get working than Python programs. The trouble is that Java has a thousand deficiencies that outweigh that particular benefit, so overall I like Python a lot better anyway. Now some of the Python-is-perfect crowd seems to suffer from a "Blub paradox" (http://c2.com/cgi/wiki?BlubParadox). They see annoying, static typed languages like C and Java, and they see pleasant, dynamically typed languages like Python, and conclude that static types = annoying, when in fact they can be orthogonal. So, can there be a language that's both statically typed, and pleasant? I haven't used one yet, but lately I've been reading about Haskell and want to give it a try. I keep finding statements like: To me, Haskell is what Python should have evolved to. As a long-time Python programmer, I have been very, very pleased with Haskell and am currently working on porting my code to it (and write new code in Haskell at every opportunity). (http://supybot.com/Members/jemfinch/haskell-sucks/document_view) or: Using Haskell to develop OpenAFP.hs led to programs that eat constant 2MB memory, scale linearly, and are generally 2OOM faster than my Perl library. Oh, and the code size is 1/10. (http://www.perl.com/pub/a/2005/03/03/pugs_interview.html - Autrijus also raves about how great the book "Types and Programming Languages" supposedly is--I'm trying to borrow a copy. Yeah, this is a Perl comparison, but I think of Perl as being roughly equivalent to Python except a lot uglier). or: Haskell is the least-broken programming language available today. C, C++, Perl, Python, Java, and all the other languages you've heard of are all much more broken, so debating their merits is pointless. :-) Unfortunately Real Life involves dealing with brokenness. (http://www106.pair.com/rhp/books.html) or: In conducting the independent design review at Intermetrics, there was a significant sense of disbelief. We quote from [CHJ93]: "It is significant that Mr. Domanski, Mr. Banowetz and Dr. Brosgol were all surprised and suspicious when we told them that Haskell prototype P1 (see appendix B) is a complete tested executable program. We provided them with a copy of P1 without explaining that it was a program, and based on preconceptions from their past experience, they had studied P1 under the assumption that it was a mixture of requirements specification and top level design. They were convinced it was incomplete because it did not address issues such as data structure design and execution order." (http://haskell.org/papers/NSWC/jfp.ps - this was from a bake-off for a military application where the Haskell solution had 85 lines of code to Ada's 767, C++'s 1105, and Relational Lisp's 274). Obviously I'm in the usual rose-colored-glasses phase of finding out about something new and interesting, but I can't help thinking these guys are onto something. Quite a few of the Haskell Cafe mailing list members seem to have come to Haskell from Python. (Haskell tutorial: http://www.isi.edu/~hdaume/htut/ - I've read most of this and it looks pretty cool--definitely a steeper learning curve than Python but the result looks a lot more powerful). -- http://mail.python.org/mailman/listinfo/python-list