User: Password:
|
|
Subscribe / Log in / New account

GNOME Platform Stormclouds

GNOME Platform Stormclouds

Posted Mar 25, 2004 17:21 UTC (Thu) by tjc (guest, #137)
In reply to: GNOME Platform Stormclouds by mly
Parent article: GNOME Platform Stormclouds

I'm really surprised to find the lack of static typing to be an argument against Python. Sure, I misspell things in Python and get name errors, but they typically surface quicker than they would in C [snip]

They show up at compile time in C, which is as fast as it gets!

Dave Camp's one-liner in this blog post probably explains the thoughs of most developers on this issue: I have a soft spot in my heart for Python (although I have a softer spot for static type checking).

I think this is mainly a matter of getting used to another way of programming.

I never have gotten used to it. I've written a fair amount of code in both PHP and Tcl, and the lack of static type checking is a language "feature" that keeps on taking. Since my spelling is unlikely to improve significantly, I appreciate a language that points out my mistakes immediately rather than producing unexpected results at runtime.


(Log in to post comments)

GNOME Platform Stormclouds

Posted Mar 25, 2004 18:44 UTC (Thu) by mly (guest, #2171) [Link]

tjc wrote:
> They show up at compile time in C, which is as fast as it gets!

No it's not! Honestly! For my normal programming, I run my python programs more often than I compile my C or C++ programs during development. I typically write very modular code and change it in small steps, testing it often so that I notice whatever bugs I introduce as soon as I can. Of course, only a fraction of these bugs would have been caught by the compiler anyway.

I haven't programmed so much C or C++ lately, but even if I try to use short cycles there as well, they will still be longer, since I need to type so much more in these languages to produce the same amount of functionality.

But if you like the support of the compiler in C, just use PyChecker as your Python "compiler". I would still suggest proper unit tests though. Python has good unit test support in the standard library, and no compiler or code checker can replace real tests.

> I've written a fair amount of code in both PHP and Tcl

I don't think you can draw too many conclusions about Python from Tcl or PHP. That's a bit like deciding what to think about C based on experience from COBOL.

Strange as it may sound, I mistype much more in C or C++ than in Python. There are several reasons for that. One is naturally that there will be fewer mistypings if there is less typing. Another aspect is that Python's syntax is very simple and consistent. I don't have to remember so much, and
since the code typically looks clean and regular, I'm more likely to directly spot mistakes. Python fits my brain. My little experience of Tcl and PHP suggests that they don't offer the same benefits. I'll quote what Eric Raymond said about his first experiments with Python in Linux Journal:

I noticed (allowing for pauses needed to look up new features in Programming Python) I was generating working code nearly as fast as I could type. When I realized this, I was quite startled. ... it generally means you've achieved mastery of the language. But that didn't make sense, because it was still day one ...

This was my first clue that, in Python, I was actually dealing with an exceptionally good design. Most languages have so much friction and awkwardness built into their design that you learn most of their feature set long before your misstep rate drops anywhere near zero. Python was the first general-purpose language I'd ever used that reversed this process.

Pinched from http://www.linuxjournal.com/article.php?sid=3882

GNOME Platform Stormclouds

Posted Mar 25, 2004 20:25 UTC (Thu) by tjc (guest, #137) [Link]

I don't think you can draw too many conclusions about Python from Tcl or PHP.

All three lack static type checking, which is the *only* thing I was comparing with C. I'd probably have more to say about Python, but I've never had a contract that required it, and C is the only thing I use on my own time.

GNOME Platform Stormclouds

Posted Mar 26, 2004 18:08 UTC (Fri) by maney (subscriber, #12630) [Link]

All three lack static type checking, which is the *only* thing I was comparing with C.

Right, and that's why it's a useless comparison. There's a great deal more that differs among the four languages, and assuming that your experience with PHP and TCL are reliable guides to what Python is like is a bad assumption. I haven't used TCL, but I have worked with PHP at some length - indeed, I worked with it until it seemed to be unable to support the application, which was why I switched to Python. Nor was that the biased reaction of a fan of X who proves that Y isn't much good and finds reverting to X clearly better, as I had had nothing but superficial exposure to either language before beginning. And so I made the mistake of taking at face value all the hype that was going around then (still is, I guess) about how PHP is such a wonderful language for web apps with database backends. Maybe for Joe Hacker's Own CD Catalog it actually is; for the middling complex scheduling app I was working on it made some early, stripped down versions easy, but the cost rose quickly as I tried to add meat to those bones.

Rather more that 20 years after my first chance to use C (anyone else remember BDS C for CP/M?), I find that there are languages that work differently than C (or C++, which in some important ways is just a false front hung in front of C to disguise it), and for these languages the static type checking that is so essential in C - because the static checking, limited as it is, is the only sanity check you get - is simply irrelevant. I know I won't convince you: this is something that everyone has to learn for themselves. At least that has been my experience.

GNOME Platform Stormclouds

Posted Mar 26, 2004 22:57 UTC (Fri) by tjc (guest, #137) [Link]

All three lack static type checking, which is the *only* thing I was comparing with C.

Right, and that's why it's a useless comparison.

It was a useful comparison for my purposes, since I was able to determine from an early stage that quite of few languages would not be very useful to me. This is a lot better than spending a great deal of time learning a new language and then finding out further down the road that it's not going to work very well for a particular purpose or project.

GNOME Platform Stormclouds

Posted Mar 25, 2004 18:52 UTC (Thu) by angdraug (subscriber, #7487) [Link]

Unlike Ruby and Python, PHP and Tcl are not mentioned in the context of "making it easy to do things right", and there is a reason to that: they don't.

GNOME Platform Stormclouds

Posted Mar 25, 2004 20:34 UTC (Thu) by tjc (guest, #137) [Link]

My experience with Tcl is restricted to Vignette V/5, one of the most unproductive development environments that I've had the displeasure of using, so in this case I agree with you. Tcl on its own may be a much better experience.

I have little bad to say about PHP -- I like it better than Perl for server-side scripting. I've never used Python, other than working through the O'Reilly book a couple years ago to see what it was about. It seemed ok.

GNOME Platform Stormclouds

Posted Mar 27, 2004 7:42 UTC (Sat) by Cato (subscriber, #7643) [Link]

For (some) static checking in a dynamic language, try Perl - most code is written with 'use strict', which catches variable name typos although the type checking is still done at run time.

Or you can just use OCaml (Objective Caml), which is garbage collected and dynamic like Perl/PHP/Tcl/Ruby/Python, but also has strong inference-based type checking (somewhat like C/C++/Pascal, except that you never have to declare types - it just infers all types, working up from the constants and operators). OCaml is almost unique in having the ease of programming of a dynamic byte-code interpreted language (a la Perl) and the option to compile to truly efficient machine code (which is sometimes faster than C, due to more optimisation enabled by stronger type checking, see link above for details). Well worth a look.

GNOME Platform Stormclouds

Posted Mar 27, 2004 10:30 UTC (Sat) by mly (guest, #2171) [Link]

Or you can just use OCaml (Objective Caml), which is garbage collected and dynamic like Perl/PHP/Tcl/Ruby/Python, but also has strong inference-based type checking...

I realize that this helps improve performance, but does it prevent spelling errors?

GNOME Platform Stormclouds

Posted Mar 28, 2004 6:40 UTC (Sun) by Cato (subscriber, #7643) [Link]

Yes, OCaml prevents spelling mistakes in variable names and any type mis-matches, just like C/C++ type checking. In addition, it can also catch more subtle errors - my OCaml page (see original post) has a link to an example where a similar language's compiler detected an infinite loop at compile time


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds