Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12714
| References | <j3tjov$c30$1@dont-email.me> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2011-09-03 12:50 -0600 |
| Subject | Re: Functions vs OOP |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.743.1315075846.27778.python-list@python.org> (permalink) |
On Sat, Sep 3, 2011 at 10:15 AM, William Gill <noreply@domain.invalid> wrote: > During some recent research, and re-familiarization with Python, I came > across documentation that suggests that programming using functions, and > programming using objects were somehow opposing techniques. > > It seems to me that they are complimentary. It makes sense to create > objects and have some functions that take those objects as arguments. Are > they suggesting that any function that takes an object as an argument should > always be a method of that object? Conversely I can see creating functions > that take raw input (e.g. strings) and return it in a format compatible with > an object's constructor, rather than have objects accept any conceivable > format for its constructor. > > Am I missing something, or am I taking things too literally? I think you may be confusing "functional programming" and "programming using functions". These are not the same thing. Functional programming is about using functions in the *mathematical* sense. A mathematical function maps one value (or tuple of values) to another value. The mapped value never varies; if it did, it would be a different function. So functional programming eschews the use of functions where the results depend on any internal or external state beyond the values of the passed-in arguments, such as the variable state of the object the method is being called on. Functional programming and OOP are not entirely opposed -- for example, string methods in Python such as str.upper are perfectly functional, since strings are immutable. Many functional languages such as Common LISP also have powerful OOP facilities. Still, functional programming does not fit well with the traditional OOP model of objects passing messages to other objects, which generally implies statefulness. Cheers, Ian
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 12:15 -0400
Re: Functions vs OOP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-04 02:25 +1000
Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-03 15:15 -0400
Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 17:34 -0400
Re: Functions vs OOP Ben Finney <ben+python@benfinney.id.au> - 2011-09-04 07:39 +1000
Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-03 17:58 -0400
Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-03 21:51 -0400
Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 22:18 -0400
Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-05 14:58 -0400
Re: Functions vs OOP MRAB <python@mrabarnett.plus.com> - 2011-09-03 17:29 +0100
Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 17:09 -0400
Re: Functions vs OOP Ian Kelly <ian.g.kelly@gmail.com> - 2011-09-03 12:50 -0600
Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-03 17:13 -0400
Re: Functions vs OOP tinnews@isbd.co.uk - 2011-09-04 09:13 +0100
Re: Functions vs OOP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-04 21:18 +1000
Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-04 14:32 -0400
Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-04 15:43 -0400
Re: Functions vs OOP Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-05 09:41 +1000
Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-04 20:46 -0400
Re: Functions vs OOP Chris Angelico <rosuav@gmail.com> - 2011-09-05 10:59 +1000
Re: Functions vs OOP rusi <rustompmody@gmail.com> - 2011-09-04 06:13 -0700
Re: Functions vs OOP William Gill <noreply@domain.invalid> - 2011-09-05 13:45 -0400
Re: Functions vs OOP Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-09-05 21:04 +0200
Re: Functions vs OOP William Gill <nospam@domain.invalid> - 2011-09-05 20:30 -0400
Re: Functions vs OOP Terry Reedy <tjreedy@udel.edu> - 2011-09-05 18:55 -0400
csiph-web