Python is going to be hard

Rustom Mody rustompmody at gmail.com
Thu Sep 4 00:11:27 EDT 2014


On Thursday, September 4, 2014 9:20:02 AM UTC+5:30, Chris Angelico wrote:
> On Thu, Sep 4, 2014 at 1:22 PM, Rustom Mody  wrote:
> > | Effect-free programming
> > | -- Function calls have no side effects, facilitating compositional reasoning
> > | -- Variables are immutable, preventing unexpected changes to program data by other code
> > | -- Data can be freely aliased or copied without introducing unintended effects from mutation
> > So to answer your question: print statements are side-effecting and therefore obstruct
> > compositional reasoning.

> Yeah, fine. One small problem: Computers aren't built to do nothing.
> "Effect-free programming" is utterly valueless and purposeless. To
> make a program actually useful, you need to have some effect
> somewhere. So where do you do that? Where do you permit a function
> with side effects?

> If you force *everything* to be in the return value, you lose any
> possibility of partial results - for instance, if it takes two weeks
> to render a ray-traced animation, you actually spend the entire two
> weeks building up a single, gigantic return value, which some outside
> system (which is presumably allowed to have side effects) then saves
> somewhere. In the meantime, you have absolutely no idea how far it's
> progressed - no information that it's completed frame 6 and is working
> on frame 7, nothing. Because telling the user anything is a side
> effect.

> And if my function f calls show_status_to_user() which has side
> effects, then f has side effects too, and you can no longer reason
> purely about f. The impurity that makes for practicality (hey, isn't
> there something in the Zen of Python about that?) pollutes upwards
> until all you'll have will be pockets of pure functional code that
> execute quickly enough to not need any intermediate output. That
> doesn't equate to "abolish print",

Is there some PEP filed called "Abolish print in python 4" ?
I dont remember filing any such...

Perhaps you should think of the relevance (rather than the
correctness) of your arguments Chris!  Are you arguing

1. With me?
2. With the OP?
3. With ACM/IEEE?

If 1 then yeah I know when to use prints and when not
If 2, are examples like ray-tracing animation remotely relevant (at this stage)?
If 3 Sure! Take it up with ACM&IEEE if you feel something in their
recommended curriculum is "valueless¹ and purposeless"



> that just means that you separate
> the guts from the UI - which is good advice for any system, no matter
> what its structure.

Yes thats the whole point -- computers do computing.
IO should be conceptualized separately.

--------------
¹ Strange choice of word considering that one principal agenda of functional
programming is to replace state-change thinking with value-oriented thinking



More information about the Python-list mailing list