Don't know where you got this, but he didn't start with Pascal. Pascal is *very* type-strict, but Python doesn't even require you to explicitly declare variables! He started off with ABC, a small language he had designed earlier for the purpose of teaching beginners how to program (similar to BASIC in that sense). That is essentially why Python uses indentation to denote block rather than begin's, end's or braces, and why statements end with a newline rather than a semicolon: Sensible and intuitive to a beginner, especially since it promotes good coding style (or enforces it, depending on your point of view), but a little odd for a programmer already fluent in languages such as C, Awk, Perl, etc.
>Ok, that's great. Now what if the file has 1 million or so lines?
Well then, you do this:
fp = open("afile.txt", "r") line = fp.readline() while line: print line line = fp.readline()
Note that this is "readline" (single) as opposed to "readlines" (plural). One gives you a line at a time, the other gulps them all in a single shot. This will work fine, no matter *how* many lines you have. In fact, this is pretty common usage - if you say you don't like Python and you haven't gotten *this* far, it doesn't sound like you've given Python enough of a chance yet.
Guess what: *Any* language will have proponents that say it's suitable for every single task, from low-level tasks to high-level scripting. I've seen Schemers, Perl Mongers, Pythonistas, Diehard C coders, C++ wizards, etc, all be guilty of this. It goes with the territory.
I don't know where you get the one part -- I've never seen *any* Python user propose it for "bare-metal machine language", as you state. Python is not fast due to its dynamic nature, which is a deliberate design choice as a high level language. Any sane Python user will tell you to code the low level parts in C, anyway.:-)
If you're going to decide what language to try out based on the zealotry of its users, then you should probably design your own from scratch and use it all by yourself. Once you have two or three users, you'll end up with language junkies extolling your creation to the ends of the Earth, even if their arguments aren't always rational.
I'm a Python fan (as if you haven't guessed already), and I love the language because it is so clean, simple and expressive. I try to advocate it where I can, especially in the areas where Python shines: scripting, rapid prototyping, and creating software that should be easily modifiable and extensible. I also keep my mouth shut when Python isn't appropriate (i.e. where speed matters above all else). Does this mean I'm smug when I do it? Maybe not during, but after, when someone comes back and thanks me for introducing them to the language, which is a nice ego boost. But I'm also happy that I've helped someone find a better tool.
Python users are some of the most polite programmers I know. Check the comp.lang.python group some time and you'll be suprised how little flaming goes on there. Pretty rare for a language discussion group.
P.S. I got over the whitespace detail in about 20 minutes. So would you, probably.
That's because in Python, that "i" isn't an integer, its a *reference* to an integer. Every variable in Python is a reference, so naturally, incrementing it doesn't make sense.:=) When you call "i = i + 1", the reference in i now refers to a new integer value. Try "id(1)" sometimes in Python to see what I mean: Even literals have object IDs. References within namespaces is Python's view of the world, similar to how Perl tries to see everything as a flat memory structure whenever possible.
While I do appreciate that having "i++" as syntactic sugar would be nice, or possibly having maybe where an integer reference could have, say, a "i.inc()" method or something along those lines, (primitives currently don't have methods, but that may change in the future) nothing like that has been added to the language. As I understand it, allowing "i++" would be stating that a reference to an integer could be changed "in place", meaning that it's possible to change a reference out from under yourself without assigning it. Oh well. I don't see it as a big deal, but that's me.
I missed the mark on this one. I was upgrading my sister's computer from an old Pentium 133 to a (somewhat) more modern K6-200, and while I was at it, I decided to give her my SoundBlaster AWE 64 since I never had to been able to get it to run under Linux anyway. Even after paying for OSS drivers.:=)
So, I went out and bought an Ensoniq for 30 bucks. Upside: I now have sound under Linux. Downside: Sound under Half-Life and Unreal under Windows is now tinny, where before the sound was rich and full with the AWE 64 card.
And, naturally, I ship the better sound card away in my sister's machine TWO FREAKIN DAYS before the announcement of open source drivers! Ah, Life never gets bored of her dirty tricks, does she?
Where I work, we really *do* have a server named Titanic. It has that heavy grey-and-black industrial look that reminds you of the actual sailing vessel. Its a Data General machine, as big as a refridgerator, with an suprisingly puny laptop screen that folds out of the middle of it. Oh, and it runs NT, adding to the "flop" metaphorical value.
The head of the department who bought it essentially had no choice: He could only get clearance for the purchase of the one Data General machine, and not on getting several reasonably priced servers. I fugure that the naming of the machine to "Titanic" was his way of getting a little justice.:=)
>Python only has one maintainer, last time I looked, which would give most industrial developers the jitters.
Possibly, but since Python is fully Open Source, maintainance of the language shouldn't be a problem. When push comes to shove, you can always find a way to fix the problem -- people can and do post public patches to the Python source to fix things they see as problems, such as better garbage collection, consistent return types from functions, etc. If anything, I'd be more worried about being tied to a proprietary language with a single company behind it. This applies for both good languages (Delphi), and not-so-good ones (VB). If the company goes out of business (Delphi again, sorry Borland), or arbitrarily breaks backwards compatibility (VB), you're screwed.
Also, Python the Language has been pretty stable for a few years now -- my copy of "Programming Python" is dated in 1996 and applies for Python 1.4. The current version is 1.52 and is mostly minor changes in the standard libraries. The major events for Python right now is how it is used, such as in Zope or JPython.
Not to start a language war, but in a case like that, if the person isn't comfortable with Perl, point them towards Python. The two languages are more or less equivalent in what they can do, and it really is just a matter of preference: Perl goes for symbolic representation and flexibility of expression, and Python goes more for object orientedness and readability. For what its worh, I use Perl for quick text- or file-handling tasks, and Python for more elaborate stuff.
Don't know where you got this, but he didn't start with Pascal. Pascal is *very* type-strict, but Python doesn't even require you to explicitly declare variables! He started off with ABC, a small language he had designed earlier for the purpose of teaching beginners how to program (similar to BASIC in that sense). That is essentially why Python uses indentation to denote block rather than begin's, end's or braces, and why statements end with a newline rather than a semicolon: Sensible and intuitive to a beginner, especially since it promotes good coding style (or enforces it, depending on your point of view), but a little odd for a programmer already fluent in languages such as C, Awk, Perl, etc.
Python is my favorite language, btw.
Yeah, baby!
>Ok, that's great. Now what if the file has 1 million or so lines?
Well then, you do this:
fp = open("afile.txt", "r")
line = fp.readline()
while line:
print line
line = fp.readline()
Note that this is "readline" (single) as opposed to "readlines" (plural). One gives you a line at a time, the other gulps them all in a single shot. This will work fine, no matter *how* many lines you have. In fact, this is pretty common usage - if you say you don't like Python and you haven't gotten *this* far, it doesn't sound like you've given Python enough of a chance yet.
> Oh please. Arnold being a robot in T2 was more of a mystery than Deckard being a Replicant in Blade Runner.
No NO *NO*. Arnold was a *Cyborg*. Specifically, a T-800 series, Cyberdyne Systems Model 101. Living tissue over metal endoskeleton.
(Kids these days. Can't tell the freaking difference between a robot and a cyborg. Sheesh.)
Guess what: *Any* language will have proponents that say it's suitable for every single task, from low-level tasks to high-level scripting. I've seen Schemers, Perl Mongers, Pythonistas, Diehard C coders, C++ wizards, etc, all be guilty of this. It goes with the territory.
:-)
I don't know where you get the one part -- I've never seen *any* Python user propose it for "bare-metal machine language", as you state. Python is not fast due to its dynamic nature, which is a deliberate design choice as a high level language. Any sane Python user will tell you to code the low level parts in C, anyway.
If you're going to decide what language to try out based on the zealotry of its users, then you should probably design your own from scratch and use it all by yourself. Once you have two or three users, you'll end up with language junkies extolling your creation to the ends of the Earth, even if their arguments aren't always rational.
I'm a Python fan (as if you haven't guessed already), and I love the language because it is so clean, simple and expressive. I try to advocate it where I can, especially in the areas where Python shines: scripting, rapid prototyping, and creating software that should be easily modifiable and extensible. I also keep my mouth shut when Python isn't appropriate (i.e. where speed matters above all else). Does this mean I'm smug when I do it? Maybe not during, but after, when someone comes back and thanks me for introducing them to the language, which is a nice ego boost. But I'm also happy that I've helped someone find a better tool.
Python users are some of the most polite programmers I know. Check the comp.lang.python group some time and you'll be suprised how little flaming goes on there. Pretty rare for a language discussion group.
P.S. I got over the whitespace detail in about 20 minutes. So would you, probably.
And also TCL, just to be fair (even though I like Python better). :-)
> Bottom line - languages that make you think like a computer don't stand the test of time.
:-)
You mean languages like C?
> but... no 'i++'???? I'm stunned.
:=) When you call "i = i + 1", the reference in i now refers to a new integer value. Try "id(1)" sometimes in Python to see what I mean: Even literals have object IDs. References within namespaces is Python's view of the world, similar to how Perl tries to see everything as a flat memory structure whenever possible.
That's because in Python, that "i" isn't an integer, its a *reference* to an integer. Every variable in Python is a reference, so naturally, incrementing it doesn't make sense.
While I do appreciate that having "i++" as syntactic sugar would be nice, or possibly having maybe where an integer reference could have, say, a "i.inc()" method or something along those lines, (primitives currently don't have methods, but that may change in the future) nothing like that has been added to the language. As I understand it, allowing "i++" would be stating that a reference to an integer could be changed "in place", meaning that it's possible to change a reference out from under yourself without assigning it. Oh well. I don't see it as a big deal, but that's me.
I missed the mark on this one. I was upgrading my sister's computer from an old Pentium 133 to a (somewhat) more modern K6-200, and while I was at it, I decided to give her my SoundBlaster AWE 64 since I never had to been able to get it to run under Linux anyway. Even after paying for OSS drivers. :=)
So, I went out and bought an Ensoniq for 30 bucks. Upside: I now have sound under Linux. Downside: Sound under Half-Life and Unreal under Windows is now tinny, where before the sound was rich and full with the AWE 64 card.
And, naturally, I ship the better sound card away in my sister's machine TWO FREAKIN DAYS before the announcement of open source drivers! Ah, Life never gets bored of her dirty tricks, does she?
Where I work, we really *do* have a server named Titanic. It has that heavy grey-and-black industrial look that reminds you of the actual sailing vessel. Its a Data General machine, as big as a refridgerator, with an suprisingly puny laptop screen that folds out of the middle of it. Oh, and it runs NT, adding to the "flop" metaphorical value.
:=)
The head of the department who bought it essentially had no choice: He could only get clearance for the purchase of the one Data General machine, and not on getting several reasonably priced servers. I fugure that the naming of the machine to "Titanic" was his way of getting a little justice.
>Python only has one maintainer, last time I looked, which would give most industrial developers the jitters.
Possibly, but since Python is fully Open Source, maintainance of the language shouldn't be a problem. When push comes to shove, you can always find a way to fix the problem -- people can and do post public patches to the Python source to fix things they see as problems, such as better garbage collection, consistent return types from functions, etc. If anything, I'd be more worried about being tied to a proprietary language with a single company behind it. This applies for both good languages (Delphi), and not-so-good ones (VB). If the company goes out of business (Delphi again, sorry Borland), or arbitrarily breaks backwards compatibility (VB), you're screwed.
Also, Python the Language has been pretty stable for a few years now -- my copy of "Programming Python" is dated in 1996 and applies for Python 1.4. The current version is 1.52 and is mostly minor changes in the standard libraries. The major events for Python right now is how it is used, such as in Zope or JPython.
Not to start a language war, but in a case like that, if the person isn't comfortable with Perl, point them towards Python. The two languages are more or less equivalent in what they can do, and it really is just a matter of preference: Perl goes for symbolic representation and flexibility of expression, and Python goes more for object orientedness and readability. For what its worh, I use Perl for quick text- or file-handling tasks, and Python for more elaborate stuff.