OT: Python (was Re: vi in /bin)

Previous thread: Making You Richer, Instantly Commissions by Janet Wiseman on Saturday, December 19, 2009 - 3:20 am. (1 message)

Next thread: Re: Handling HTTP virtual hosts with relayd by Stuart Henderson on Saturday, December 19, 2009 - 5:50 am. (1 message)
From: ropers
Date: Saturday, December 19, 2009 - 5:54 am

If you have the time, I'd love to hear you elaborate. So far most
people whose opinion I value have only said good things about Python.
You're the first person whose opinion I respect to go against that.

regards,
--ropers

From: Darrin Chandler
Date: Saturday, December 19, 2009 - 6:17 am

You just need to talk to more people, then. Lots of people don't like
Python. Same for Perl, Ruby, or anything else. I've heard several devs
say they don't like Python but I have yet to hear any of them actually
give a reason. Ask them why they don't like C++ and you get a big list
of everything that's wrong with it. Ask about Python and you get "it
sucks" or "it's awful" or something. So I think it's just a matter of
taste.

Or maybe Henning has actual reasons. I haven't heard him talk about
Python before so I don't know. Henning?

-- 
Darrin Chandler            |  Phoenix BSD User Group  |  MetaBUG
dwchandler@stilyagin.com   |  http://phxbug.org/      |  http://metabug.org/
http://www.stilyagin.com/  |  Daemons in the Desert   |  Global BUG Federation

From: Claudio Jeker
Date: Saturday, December 19, 2009 - 6:38 am

Ugh, a programming language where you can't copy paste from xterm to xterm
without fucking up the program is just way to much pain to work on.
The indenting of code is an optical help but should not change the
behaviour of the program. For me it is important to be able to write code
with style(9) in mind (and I think most other BSD developpers think
similar because our code all looks similar).


From: Darrin Chandler
Date: Saturday, December 19, 2009 - 7:21 am

I have often done copy/paste with Python code between xterms. Of course
you must fix indenting. If you naively copy/paste C you will also have
issues of syntax and meaning, but if you are so used to looking at C
code that the meaning in the new context is immediately obvious without
thinking then you will not notice. Instead you just fix/adjust it in
place and move on.

Some people will never like indent having meaning. But there is value in
having an 'else' that *looks* like it belongs with an 'if' actually
belong to that 'if', *because* it looks like it does. You don't ever
have to like Python, but indenting to make blocks is perfectly
cromulent. It's not a deficiency, it's just different.

-- 
Darrin Chandler            |  Phoenix BSD User Group  |  MetaBUG
dwchandler@stilyagin.com   |  http://phxbug.org/      |  http://metabug.org/
http://www.stilyagin.com/  |  Daemons in the Desert   |  Global BUG Federation

From: Ted Unangst
Date: Saturday, December 19, 2009 - 8:03 am

It's very hard to fix the indenting when you're copying code from a  
web forum/email archive/whatnot that mangled it. Been there done that.  
Pythons behavior in this regard makes it very aggravating to work with  
as a newcomer, and for many people who are a little suspicious of the  
whole whitespace thing, when your first taste of the language is hours  
spent fixing the whitespace, you aren't inclined to use it any more  
than necessary.

On Dec 19, 2009, at 9:21 AM, Darrin Chandler  

From: Darrin Chandler
Date: Saturday, December 19, 2009 - 8:21 am

I agree that copy/paste from the web would be challenging for newcomers.
Pastes from the web do horrible things to indenting. If you aren't
comfortable with Python it'd be a huge pain.

-- 
Darrin Chandler            |  Phoenix BSD User Group  |  MetaBUG
dwchandler@stilyagin.com   |  http://phxbug.org/      |  http://metabug.org/
http://www.stilyagin.com/  |  Daemons in the Desert   |  Global BUG Federation

From: Jonathan Schleifer
Date: Saturday, December 19, 2009 - 11:29 am

Well, enforced whitespaces are a double-edges sword: While enforcing
newcomes to indent their code correctly and thus getting them used to
the right style and avoiding bad behaviour, it is really a pain in the
ass for testing. If you are just going to test something, you often
have to reindent code. Luckily, vim can do that for you, but still,
it's rather annoying that I have to reformat the code then.

--
Jonathan

[demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]

From: Darrin Chandler
Date: Saturday, December 19, 2009 - 12:26 pm

You're doing testing wrong and the wrongness has nothing to do with
python. ;-)

-- 
Darrin Chandler            |  Phoenix BSD User Group  |  MetaBUG
dwchandler@stilyagin.com   |  http://phxbug.org/      |  http://metabug.org/
http://www.stilyagin.com/  |  Daemons in the Desert   |  Global BUG Federation

From: Jonathan Schleifer
Date: Saturday, December 19, 2009 - 12:32 pm

Erm, since when is it wrong to change code for testing, to make sure it
even works under strange circumstances? oO

--
Jonathan

[demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]

From: Darrin Chandler
Date: Saturday, December 19, 2009 - 12:47 pm

When you can write your code to remain testable. If you've changed code,
then you're only testing test code instead of production code. If you
change it back for production, did you change it back correctly? Better
to call the same code from both production and testing.

Yes, I have used your approach. I only use that approach when I must.

-- 
Darrin Chandler            |  Phoenix BSD User Group  |  MetaBUG
dwchandler@stilyagin.com   |  http://phxbug.org/      |  http://metabug.org/
http://www.stilyagin.com/  |  Daemons in the Desert   |  Global BUG Federation

From: Jonathan Schleifer
Date: Monday, December 21, 2009 - 8:17 am

I'm more talking about debugging here. It's awfully annoying to change  
indentation for that. And yes, I don't commit my debug code by  
accident, as I always read the diff first ;).

--
Jonathan

From: Floor Terra
Date: Saturday, December 19, 2009 - 8:37 am

I agree that copy/paste is a big problem in Python.
But in my experience copy/paste of code in any language is dangerous.
If you want to re-use code, write a function.



-- 
Floor Terra <floort@gmail.com>
www: http://brobding.mine.nu/

From: Henning Brauer
Date: Saturday, December 19, 2009 - 10:08 am

[ ] you have ever seriously used C

heck, even perl.

-- 
Henning Brauer, hb@bsws.de, henning@openbsd.org
BS Web Services, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting

From: Floor Terra
Date: Saturday, December 19, 2009 - 11:06 am

In my experience (mostly python and c), code that has been pasted has
a higher bug density.

This is because most of the copy/paste goes like this:
1) Write some loop
2) Need similar loop
3) copy/paste old loop
4) Modify pasted loop (but forget one tiny change)
5) New loop has bug

It's worse with Python because of the indentation (tabs vs. spaces),
but as a general rule I would say never copy/paste code.

-- 
Floor Terra <floort@gmail.com>
www: http://brobding.mine.nu/

From: Jonathan Schleifer
Date: Saturday, December 19, 2009 - 11:26 am

This is why I never just copy code, but type it. While you type, you
also think about whether it makes sense to just copy the code and you
will notice if you have to adjust something. Saved me quite a few times
and doesn't take too long if you copy only short code. And long code
should never be copied anyway.

--
Jonathan

[demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]

From: Henning Brauer
Date: Saturday, December 19, 2009 - 12:06 pm

boo hoo.

there are very valid uses of copied code, or extremely similiar code
(copy & paste and change a few things). we have that many times in the
tree.

the enforced indentation is completely nuts. i purposefully indent
extremely incorrectly when adding debug code that i intend to remove
again, to spot it faster. just one example, there are many more.

python doesn't solve a problem. perl's been there already.

oh, and the 80s sed, i use it a lot. as well as shell scripts.

-- 
Henning Brauer, hb@bsws.de, henning@openbsd.org
BS Web Services, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting

From: Chris Dukes
Date: Saturday, December 19, 2009 - 4:22 pm

If you're copying and pasting, you're probably doing something wrong.

If it's a small example that you're using as a tutorial or as inspiration
to understand how something works, you probably should type it.
By typing it the information makes another pass through your brain
which can improve comprehension.
If it's large and part of something functional, it should have been 
in a tarball or under source control and there shouldn't be any copy/paste.

If your coding style involves a lot of copy and paste, you're repeating
yourself and probably should not do that.

With that said my python grumbles have been.

1) Developers that refuse to understand the packaging utilities available
and how they work with source control systems.

2) Packaging libraries that were written with CVS and subversion in mind that
completely break on current versions of subversion.

3) Inattention to detail in libraries.  IE the python ldap libraries
where results can be retrieved without a message id, but an exception

-- 
Chris Dukes

From: Nick Guenther
Date: Saturday, December 19, 2009 - 12:51 pm

and just to add to the pyre...


Your losses then. Python isn't so much a language of recipes, it's a
language of ideas.


Python is about thinking about what you're doing. It's one of those
languages that forces you to work on a higher level (not that there
aren't lots of places where python is used as a scripting
language--that code tends to come out badly, but that's because it's
written just to get the job done).

Ideal code is abstracted code, what possible use does repeating
yourself in the tree have? I know drivers have to declare a common set
of globals and make some macro calls and various entry-points are
found by sticking to a naming scheme, but that's trivia, hardly enough
to justify "valid uses for copied code". Anytime I find myself wanting
to copy some code it's always meant I've stumbled over an abstraction
I haven't made yet, so what in the world is src/ doing that -requires-
copied code?

-Nick

From: Ryan Flannery
Date: Saturday, December 19, 2009 - 1:18 pm

I must disagree here... there's nothing about *any* programming
language [1] that forces one to work on a higher level.  That's up to
the programmer.  I've seen even the simplest tasks, or ones that
scream for a nice, simple abstraction, done horribly (if at all) in
any language, including python.  My experience grading countless
programs from freshman-senior students, which are increasingly written
in python, show it's not the programming language... it's the
programmer.

Good design + good coding practices + tons-o-work  forces one to think
more and come up with a better design, not the language.

-ryan

[1] except of course for Haskell, the ONE TRUE GOD of proper programming :P

From: Marco Peereboom
Date: Saturday, December 19, 2009 - 5:00 pm

There is no limit to shit code produced by amateurs and "professionals".


Really?  then why do you use scrotwm?

From: William Boshuck
Date: Saturday, December 19, 2009 - 5:15 pm

Because it kicks the balls out of every other wm.

From: Johan Beisser
Date: Saturday, December 19, 2009 - 5:28 pm

Out of this whole thread this is the only statement I agree with completely.

From: Matthias Kilian
Date: Sunday, December 20, 2009 - 4:28 am

Because I'm a slacker.

From: Ryan Flannery
Date: Sunday, December 20, 2009 - 10:58 am

Because 1) that was a joke/jab at the Haskell folks, who often make
similar claims about Haskell, and 2) William Boshuck already put it
best.

From: Claudio Jeker
Date: Saturday, December 19, 2009 - 1:19 pm

Yeah, we C-programmers are just mastrubating monkeys poking the typewrite
till it produces compiling code. If you don't think about what your doing
you get the crap code you see everywhere and it is not depending on the

Code abstraction is nice until you have to update a vendor driver or some
other highly abstracted nightmare. Been there, done that, got the
nightmares. Sometimes it is far better to copy a few lines instead of
abstracting an interface until it is unusable.

No programming language will redeem people from thinking and designing
their projects correctly.


From: Nick Guenther
Date: Saturday, December 19, 2009 - 1:51 pm

I should make it more clear what I was saying: knowing the basics of
python can't force you to write good code (in fact the python stdlib
is full of shitty shitty code--the web stuff is particularly terrible)
but there's something about working in it that lets me approach
problems in a different way then I would have otherwise.

(of course the near-ultimate end of this line of thinking is lisp,
where you can define syntax for any construct you want to abstract,
but lisp personally I find lisp too wordy--that's just me though)

And I didn't mean "abstracting" in the way that C++/Java people mean
it. I've fought tooth and nail against indirection in the name of
"simplification" before. Come on.

On Sat, Dec 19, 2009 at 3:30 PM, Darrin Chandler

I'm sorry, I didn't mean to imply that scripting people wrote bad

Ideas as in the structure of the program, not as in "communication".
Yes you can write any data/dependency/etc structure in any language,
but some languages let you do it easier, and I've found python to be

Yeah yeah, I would trust that there's abstraction in the tree (more in
OpenBSD than most), but I didn't know why you wouldn't always try to
make the smallest code. I hadn't thought about execution time, it's
true, but even then I would think it's better to define a template and
fill in the blanks somehow instead of copy-pasting.

Anyway, enough /noise/, I can see that this is just going to end with
misunderstood words.

-Nick

From: Darrin Chandler
Date: Saturday, December 19, 2009 - 1:30 pm

Oh my.

A language of ideas should mean that ideas are concisely expressible in
code, and that reading the code should convey the meaning. So you see an
idea on the web somewhere and paste the idea into your code and it's
broken? Idea fail!


Python is regularly used by myself and others for scripting and it
comes out just fine. Sometimes I work at a higher level and other times
not, as the situation calls for. Doing things The UNIX Way(tm) means
some programs are simple filters that do not benefit from large numbers
of abstraction layers. Far from forcing me, Python allows me to write in

Oh my.

Python didn't invent abstraction. There's a lot of abstraction in the
tree, you know, in plain old C. Some kinds of abstraction are easier in
some languages, but there are often trade-offs. How many times per
second does an ethernet driver get called when there's a lot of traffic?

Really, Python doesn't paste well from the web and this can be a problem
for newbies. This isn't about Python being a language of ideas, it's
about Python choosing indent as meaningful and how sucky copying from a
web page is in practice. Meaningful indent works really, REALLY well
when writing python or reading python, but it sucks bad in this one
instance. Not because Python sucks, but because embedding code in forum
posts sucks. Tough cookies for python, because that's the shape of the
world right now.

-- 
Darrin Chandler            |  Phoenix BSD User Group  |  MetaBUG
dwchandler@stilyagin.com   |  http://phxbug.org/      |  http://metabug.org/
http://www.stilyagin.com/  |  Daemons in the Desert   |  Global BUG Federation

From: Jacob Meuser
Date: Saturday, December 19, 2009 - 2:15 pm

python sucks because people think it's great.

ever try to port a program written in C that uses Scons as it's build
system?  for me, the C is easy, fixing the damn Scons (python) build
scripts is a *royal PITA*.  autohell sucks but at least it uses old
school UNIX tools as it's backend (shell, awk, sed, perl).

-- 
jakemsr@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org

From: Marco Peereboom
Date: Saturday, December 19, 2009 - 5:03 pm

Bwahahahahaha! ok that is the funniest thing I heard in a couple of

So when I am writing some sort of wire protocol I am not thinking about

Abstracted code is usually gratuitously complex for no other reason than
abstraction.  Abstraction is useful when used in its problem domain.  It

From: Martin Schröder
Date: Saturday, December 19, 2009 - 6:26 am

It's religion. The python followers say the same about perl. :-)

Best
   Martin

From: Ted Unangst
Date: Saturday, December 19, 2009 - 7:58 am

The rules for scoping are utterly fucked.


Previous thread: Making You Richer, Instantly Commissions by Janet Wiseman on Saturday, December 19, 2009 - 3:20 am. (1 message)

Next thread: Re: Handling HTTP virtual hosts with relayd by Stuart Henderson on Saturday, December 19, 2009 - 5:50 am. (1 message)