Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96050
| Subject | Re: Program in or into (was Python handles globals badly) |
|---|---|
| References | (2 earlier) <CAPTjJmpkry3qBL9ntf4gUsE-aDGLooHqViMBW=ZNcK2Lb9e9nA@mail.gmail.com> <55EA487D.2010807@gmail.com> <mailman.155.1441418073.8327.python-list@python.org> <03c53b53-4103-4fd8-8851-caeccda8e016@googlegroups.com> <55eba65d$0$1665$c3e8da3$5496439d@news.astraweb.com> |
| From | MRAB <python@mrabarnett.plus.com> |
| Date | 2015-09-06 03:54 +0100 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.164.1441508106.8327.python-list@python.org> (permalink) |
On 2015-09-06 03:35, Steven D'Aprano wrote: > On Sat, 5 Sep 2015 01:18 pm, Rustom Mody wrote: > >> Here's mergesort written in various languages >> http://rosettacode.org/wiki/Sorting_algorithms/Merge_sort >> >> You could look at the java if you like but I think C# takes the cake. >> And of course also there's the python >> >> Now the thought experiment: >> >> For some reason you need to code in C# >> [You need to do this part of the experiment honestly!!] >> >> Would you write the C# code? >> Or would you write the python-ish code in C# ? > > > That depends. Is the example C# code idiomatic for the language? Or was it > written by somebody ignorant of C#, and consequently is a poor example of > badly-written and unidiomatic "Java in C#"? > > If the first, then I expect I would write the C# code, because it is > idiomatic and works. What would you do? > > It is certainly true that C# appears to be a more verbose language than > Python. Based on this example, it prefers to use classes with methods > rather than stand-alone functions, it requires static declarations, there's > a lot of boilerplate needed to get things to work. It seems to lack some > nice semantic features of Python, such as list slices and the ability to > treat lists/arrays as first class values, that make Python so easy to work > with. If C# lacks those features, how do you expect to use them? > > Lacking some of those features (or at least having significant downsides to > the use of them) is why idiomatic C# or Java code looks the way it does. > C# and Java don't have functions. The closest you can get is static (class) methods. Note: C programs start with the "main" function. Java tries to follow that pattern, except that it doesn't have functions, so a static method "main" is used instead, which means that it also requires a class to hold it. Similarly, C has "sin" and "cos" functions. Java tries to follow that pattern, except that it doesn't have functions, so a static methods are used instead, which means that it also requires a class to hold them. And C# follows what Java does.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Python handles globals badly. tdev@freenet.de - 2015-09-04 12:11 -0700
Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-04 13:48 -0600
Re: Python handles globals badly. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-04 13:52 -0600
Re: Python handles globals badly. Chris Angelico <rosuav@gmail.com> - 2015-09-05 10:27 +1000
Re: Python handles globals badly. Michael Torrie <torriem@gmail.com> - 2015-09-04 19:42 -0600
Re: Python handles globals badly. Chris Angelico <rosuav@gmail.com> - 2015-09-05 11:54 +1000
Program in or into (was Python handles globals badly) Rustom Mody <rustompmody@gmail.com> - 2015-09-04 20:18 -0700
Re: Program in or into (was Python handles globals badly) Chris Angelico <rosuav@gmail.com> - 2015-09-05 13:31 +1000
Re: Program in or into (was Python handles globals badly) Steven D'Aprano <steve@pearwood.info> - 2015-09-06 12:35 +1000
Re: Program in or into (was Python handles globals badly) MRAB <python@mrabarnett.plus.com> - 2015-09-06 03:54 +0100
Re: Program in or into (was Python handles globals badly) Rustom Mody <rustompmody@gmail.com> - 2015-09-05 21:35 -0700
Re: Program in or into (was Python handles globals badly) random832@fastmail.us - 2015-09-06 01:26 -0400
Re: Program in or into (was Python handles globals badly) wxjmfauth@gmail.com - 2015-09-06 00:42 -0700
Re: Program in or into (was Python handles globals badly) Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-06 18:19 -0600
csiph-web