From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews1.google.com!not-for-mail From: kevin.cline@gmail.com (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: 27 Sep 2004 13:34:46 -0700 Organization: http://groups.google.com Message-ID: References: <11b4d.3849$d5.30042@newsb.telia.net> NNTP-Posting-Host: 198.23.26.253 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1096317286 29594 127.0.0.1 (27 Sep 2004 20:34:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 27 Sep 2004 20:34:46 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:4285 Date: 2004-09-27T13:34:46-07:00 List-Id: Adam Ruth wrote in message news:... > In article , > duggar@mit.edu (Keith H Duggar) wrote: > > > > I've come to this thread late, so I'm not completely sure about the > > > exact specs of the code, but here's my take on a Python version. It > > > comes in at a svelt 10 lines, and I think it's quite readable. I'm sure > > > I'm missing something though. > > > > > > import sys > > > > > > words = {} > > > for line in sys.stdin.readlines(): > > > for word in line.split(): > > > words[word] = words.get(word, 0) + 1 > > > > > > words = [[x[1], x[0]] for x in words.items()] > > > words.sort() > > > words.reverse() > > > > > > for word in words[:10]: > > > print word[0], word[1] > > > > Sweet. Python get's my vote for most readable in this case. > > The "for ... in ..." construct is very nice. It saves a lot > > of time and a lot of error prone indexing code. Thanks for > > posting it. > > > Python and Ada tie for my favorite languages (with Lisp coming in a > close second). Which I use, depends on the task at hand. Ada and > Python seem to have similar philosophies, though on opposite sides of > the spectrum. Python's designer had as an explicit goal: > > "There should only be one obvious way to do anything". > > Some think that that stifles creativity, but I disagree. It frees the > programmer in my mind. While I'm not sure about the Ada designer, it > seems that a similar philosophy was in play. That's a very > "engineering" type of thought, as opposed to a "hacker" type of thought. > > That's actually my biggest problem with Perl. Its designer had as a > goal that there should be as may ways to accomplish things as there are > programmers. That was not so much a goal as property that emerged as the language grew. Features were added to make it convenient to do some things, or to improve code readability, /without worrying about feature overlap. So you can say either if (!condition) { statement; } or unless (condition) { statement; } or statement unless (condition); Or you can say either foreach $element (list) { do something; } or map { something } (list); Having more than one way to do things makes it easier to write readable code. And also easier to write unreadable code. > Great if you're just a hacker having fun, terrible if > you're someone maintaining Perl code. Really not so terrible. > I think that has more to do with Perl's unreadability than the syntax. I've > never met a "great" Perl > programmer (read, Perl hacker), who wasn't completely confused by their > own two month old code. Then you've never met a great Perl programmer. The great programmers I've known can write crystal-clear code in almost any language, with very little need for explanatory comments beyond class and function descriptions. I've read a lot of CPAN modules and found most of them pretty clear. But there are some very high-level PERL modules that allow one to do a lot with a little code, and it takes a little effort to learn what those modules do.