[TriLUG] Do a lot of you program in Python?

Steve Litt slitt at troubleshooters.com
Tue Jan 7 15:26:32 EST 2014


On Tue, 7 Jan 2014 14:10:26 -0500
Tim Jowers <timjowers at gmail.com> wrote:

> May I ask why Python? My impression is it provides a good scrpting
> soln for Linux. Is that mainly it?

Everyone has their own reasons: I'll give mine.

For stuff that C does, I love C. When I need to get something done
faster, I'll use an interpreter every time. I'm not too good at list
processing, so no Scheme for me. As a matter of fact, I used C for 10
years, so I like languages that at least to a degree have similar
constructs to C. The reason I never use Java is I have the kind of mind
able to go deep, but not broad. I can't keep in mind all the Java
addons necessary to make a modern program.

So, with all that said, here are my choices:

* Perl
* Python
* Ruby
* Lua

Perl's "many ways to do it" philosophy isn't conducive to a person like
me, who is fairly careless. When I make a minor mistake, I like my
language to say "oh no you don't", rather than trying to guess what I
really meant and do that. By the way, I happily programmed Perl for
many years, but the other three weren't as available back then. Perl's
good, the rest are better.

Ruby? It looks so good the first few weeks, and then you get tired of
it. All that syntactic sugar that seemed so convenient starts getting a
little too sweet.

Lua is, in my opinion, the best language on earth. With the only data
structure being the table (pretty much like an array, but an array
whose index entries you can name like a bunch of key/value pairs, and
fast enough to use either way. Functions are just another piece of data
you can store in a table. All those computer science constructs you
learned about but never did because they were such a PITA in your
language of choice, are easy and crystal clear in Lua. If I were giving
a data structures and algorithms class, I'd for sure teach it in Lua.
Lua's also blindingly fast, and if it's not fast enough for you, you
can use their Just In Time LuaJit and attain speeds closer to C than
to an interpreter. Oh, and yeah, Lua is by far the best at interfacing
with C, in either direction, or round trip. See
http://www.troubleshooters.com/codecorn/lua/index.htm . But Lua has a
problem: too few libraries for general application development, and
those libraries have not been adequately documented or quality
controlled. So you can get painted into a corner.

That leaves Python. Like Perl (via CPAN), it has most of the libraries
you could ever want. When you start a project in Python, you're
overwhelmingly likely to finish it in Python, usually with addons
furnished by Python. Also, everyone else is coding in Python, so it's
more accepted in free software projects, and if you're looking for
work, Python's more likely to bring you work than most other languages.
One more thing: Personally, I love Python's indent sensitive syntax. It
moots all those brace placement feuds that drove maintenance and
original programmers batty. And it serves as self-documentation. But
even if I didn't like indent sensitive code, I'd still like Python for
the other reasons I mentioned.

HTH,

Thanks,

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance


More information about the TriLUG mailing list