in reply to Perl or Python?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl or Python?
by japhy (Canon) on Nov 30, 2005 at 13:25 UTC | |
| [reply] |
by Fletch (Bishop) on Nov 30, 2005 at 14:12 UTC | |
Try and write a useful python -e one-liner which has nested loops or conditionals and I think you'll have your answer. (And as an aside, no the whitespace-as-indentation's not completely without merit but it does straightjacket you in some contexts; besides there's enough other blecherous stuff about Python (admittedly some of which they've actually started to clean up)) | [reply] |
by Perl Mouse (Chaplain) on Nov 30, 2005 at 14:10 UTC | |
I don't mind Pythons whitespace rules at all. It's not that coding in Python requires any change to the whitespace practises I've been coding with for decades. (Well, except for one minor thing. With my editor, it's slightly easier to close a block using Perl (or C) than in Python. When coding Perl, if I start a line with a closing parenthesis, brace or bracket, it will automatically align it with the line that has the corresponding opening brace - when using Python, I have to use ^D. Same amount of keystrokes, but a lesser used combination than }, so slightly (very, very slightly) more difficult in Python than in Perl. Oh, and there's '%' (vi users will know)).
Perl --((8:>*
| [reply] |
by herveus (Prior) on Nov 30, 2005 at 15:10 UTC | |
I don't know... However, the question brings to mind the TUTOR language (used on PLATO many years ago and once again available). The language uses commands with arguments. The commands are flush left, up to seven characters long, then tab to column 8 for the arguments. In the course of its life, structured programming features were added -- if, loop, etc.
You could, of course, nest those structures. That made it ugly if you got deep into indentation...especially given that the screen is 32x64. Yeah, uniform indentation is not necessarily a Bad Thing, especially if the alternative is doing without block-like stuff. PLATO ran on CDC mainframes such as the Cyber. Some folks are running a Cyber emulator on a high-end Pentium box (with a Mac as the backup) on top of which they are running NOS and PLATO. You can read more about it at http://www.cyber1.org.
yours, Michael | [reply] [d/l] |
by Aristotle (Chancellor) on Dec 01, 2005 at 03:38 UTC | |
First off, note that the whitespace silliness isn’t the foremost reason I just can’t like Python, but it sure is a constant irritation. Why? When I am rearranging my code, I generally cut and paste sections together as I see fit. With Perl, I use Vim’s = command on the entire section and the indentation is magically cleaned up in one fell swoop. With Python, I use Vim’s = command on the entire section and have a veritable mess on my hands. No can do. I need to pay close attention and reindent everything immediately upon pasting. Basically, the difference is that you can indicate the nesting structure of a piece of code by asserting it with one visible extra character every dozen lines or so and let the computer work out the formatting from that; or you can specify the nesting structure of a piece of code by re-asserting it on every single line with multiple invisible characters and be unable to request any help with it. I thought computers were supposed to automate dronework. I shuffle code around often enough that it matters to me: I generally postpone structuring code until I’ve written it and can see which parts do what – what lends itself to extraction into subroutines, whether some functions can be inlined, etc. In a way, I let the code suggest its distribution of responsibilities to me. Perl just lets me be as sloppy as I deem fit. Python doesn’t trust that I’ll be disciplined when it counts. That’s a general trend which extends to a lot of other details. In expressive power and conciseness, the languages are neck to neck, but writing Python feels like work. Makeshifts last the longest. | [reply] |
by hardburn (Abbot) on Nov 30, 2005 at 17:37 UTC | |
It causes problems when you use a different variation of whitespace than the next person. Say you write this (psedo-Python):
Say the next programmer has their editor set to show tabs as 4 spaces, and uses 4 literal spaces for each indent. They add:
Oops! Now a new block has started. This will almost certainly cause a problem at some point, and it will be very difficult to see exactly what the problem is (whitespace problems are like that). Good solution: Have coding standards that force all members of your team to have consistent indent settings. Better solution: Don't have your langauge use whitespace for anything more than tokenizing. Preferably not even that, if you can get away with it. In any case, I think this is mostly an annoyance, and it does not stop me from using Python or Ruby. "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni. | [reply] [d/l] [select] |
by skx (Parson) on Nov 30, 2005 at 18:22 UTC | |
It also makes copying and pasting blocks of code from webpages harder. (Although programmers never use copy & pasting, right? ;) | [reply] |
by gregor42 (Parson) on Nov 30, 2005 at 18:12 UTC | |
Go ask a COBOL programmer the same question about Area A & B ... :-PWait! This isn't a Parachute, this is a Backpack! | [reply] [d/l] |