Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68126
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'example:': 0.03; 'programmer': 0.03; 'essentially': 0.04; 'interfaces': 0.04; 'static': 0.04; 'classes,': 0.05; 'desired.': 0.07; 'method.': 0.07; 'nested': 0.07; 'result,': 0.07; 'inherited': 0.09; 'oop': 0.09; 'python': 0.11; 'itself.': 0.14; '10:49': 0.16; 'does,': 0.16; 'inheritance': 0.16; 'java.': 0.16; 'optional': 0.16; 'specifying': 0.16; 'structs': 0.16; 'sugar': 0.16; 'syntactic': 0.16; 'written.': 0.16; 'subject:python': 0.16; 'language': 0.16; 'wrote:': 0.18; 'basically': 0.19; "python's": 0.19; 'typing': 0.19; 'not,': 0.20; 'portion': 0.22; 'pointer': 0.24; 'java': 0.24; 'regardless': 0.24; 'compiled': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'wondering': 0.29; 'points': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'usually': 0.31; 'claiming': 0.31; 'struct': 0.31; 'class': 0.32; 'languages': 0.32; 'interface': 0.32; '(i.e.': 0.33; 'actual': 0.34; 'could': 0.34; 'knowledge': 0.35; 'operate': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'really': 0.36; 'c++': 0.36; 'described': 0.36; 'object,': 0.36; 'method': 0.36; 'subject:?': 0.36; 'virtual': 0.37; 'too': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'explain': 0.39; 'does': 0.39; 'structure': 0.39; 'url:2012': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'called': 0.40; 'how': 0.40; 'is.': 0.60; 'most': 0.60; 'entire': 0.61; 'first': 0.61; 'offer': 0.62; 'more': 0.64; 'different': 0.65; 'great': 0.65; 'within': 0.65; 'subject:. ': 0.67; 'between': 0.67; 'biggest': 0.67; 'benefit': 0.68; 'mar': 0.68; 'url:me': 0.69; 'respect': 0.70; 'removal': 0.74; 'article': 0.77; 'satisfied': 0.81; 'compiles': 0.84; 'dispatched': 0.84; 'fields,': 0.84; 'laid': 0.84; 'mature': 0.84; 'subject:over': 0.84; 'subject:removal': 0.84; 'whereas': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=02Vx4UA/xol0NZrwgC5OH3OzhHAG6yEIqHjm2jnv+GI=; b=g16ibSoRzQZy6mas/qgIc4J+vk2ElqQUhd1fl0dAsWUJBZ8KUWkPsybls0SSWrT6l6 28+bmBxsw3Rl+t3IlSchO0oc9IJmST+x24JavEp0/kKvztuPx4eS4QKCKCXiTnmA2sMO 7whlFvHNt0rcfBNprA4/O52vWHcEAZ3QQw4OgZHi+DVEjaEdBqBElPW+Saxasaz9PdFQ F6MRRm+Zl5CZv6/Kjd710irzncwiKVogg+obocUqFH2qHBmj6OPcX6UqH3u9XVUtyEqC 83nyfdjQ06cKG1h+kzEWtCi3U2UYHxjDUPzJSioCJlhlBWijGB/R/oPa0qKyNtwWo+mM mWpA== |
| X-Received | by 10.68.129.201 with SMTP id ny9mr38812266pbb.70.1394437862269; Mon, 10 Mar 2014 00:51:02 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <95cb6bd9-5030-4389-9891-578bb87af219@googlegroups.com> |
| References | <95cb6bd9-5030-4389-9891-578bb87af219@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 10 Mar 2014 01:50:22 -0600 |
| Subject | Re: golang OO removal, benefits. over python? |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7983.1394437871.18130.python-list@python.org> (permalink) |
| Lines | 48 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1394437871 news.xs4all.nl 2922 [2001:888:2000:d::a6]:48126 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:68126 |
Show key headers only | View raw
On Sun, Mar 9, 2014 at 10:49 PM, flebber <flebber.crue@gmail.com> wrote: > I was wondering if a better programmer than I could explain if the removal of OO features in golang really does offer an great benefit over python. > > An article I was reading ran through a brief overview of golang in respect of OO features http://areyoufuckingcoding.me/2012/07/25/object-desoriented-language/ The description of how Go structs work is accurate from what I know of it, but I think the author goes astray in claiming that this is not OOP. If you look at how C++ compiles inherited classes, it works in basically the same way. The SmallBox class in C++ is essentially a struct with its fields laid out in a specific order and some methods that operate on it. A BigBox class that inherits from SmallBox will first lay out the SmallBox fields in the same way that SmallBox does, and then add the fields specific to BigBox after. Draw an imaginary line around the SmallBox fields, and you have the same setup as the Go example: a SmallBox nested within a BigBox. SmallBox methods will only operate on the portion of BigBox that is within the imaginary line (i.e. the SmallBox) and don't need to have any knowledge that the SmallBox is part of a larger data structure. BigBox methods can operate on the entire BigBox and can call SmallBox methods when desired. The author points out that nested structures can be made optional by including a pointer to the structure instead of the structure itself. Again you can do the exact same thing in C++; in OOP this is usually described as a "has-a" relationship. Most languages don't support the syntactic sugar that makes this look almost identical to inheritance in Go, but that's all it is. The biggest difference between the two is that Go doesn't have any concept of virtual methods. A call of a SmallBox method on a SmallBox object, whether part of a larger object or not, will always call that SmallBox method. Whereas a call to a C++ method that is compiled as a virtual method will actually call the method associated with the superstructure, regardless of the static type the method was called on. Go gets around this by using interfaces. An interface that is satisfied by SmallBox will usually automatically be satisfied by BigBox also, and calls to interface methods are dispatched dynamically. As a result, object-oriented Go code will typically work with interfaces rather than specifying actual classes, which is not too different from how Java code is typically written. Incidentally, I rather like the design of Go interfaces. They are essentially Python's duck typing made explicit, divorcing interface implementation from formal inheritance. On the whole though I think that the language is not yet mature enough to be able to seriously compete with more established languages like Python or Java.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
golang OO removal, benefits. over python? flebber <flebber.crue@gmail.com> - 2014-03-09 21:49 -0700
Re: golang OO removal, benefits. over python? Rustom Mody <rustompmody@gmail.com> - 2014-03-09 22:05 -0700
Re: golang OO removal, benefits. over python? Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-10 01:50 -0600
Re: golang OO removal, benefits. over python? Marko Rauhamaa <marko@pacujo.net> - 2014-03-10 10:38 +0200
Re: golang OO removal, benefits. over python? flebber <flebber.crue@gmail.com> - 2014-03-10 04:45 -0700
Re: golang OO removal, benefits. over python? Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-11 14:21 -0600
Re: golang OO removal, benefits. over python? Chris Angelico <rosuav@gmail.com> - 2014-03-11 03:01 +1100
Re: golang OO removal, benefits. over python? Marko Rauhamaa <marko@pacujo.net> - 2014-03-10 18:16 +0200
Re: golang OO removal, benefits. over python? Chris Angelico <rosuav@gmail.com> - 2014-03-11 03:32 +1100
Re: golang OO removal, benefits. over python? wxjmfauth@gmail.com - 2014-03-10 09:10 -0700
Re: golang OO removal, benefits. over python? Neil Cerutti <neilc@norwich.edu> - 2014-03-11 14:37 +0000
csiph-web