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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham 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!news2.google.com!news.maxwell.syr.edu!cyclone.bc.net!newsfeed.telusplanet.net!newsfeed.telus.net!xmission!nnrp.xmission!adam.ruth From: Adam Ruth Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: Mon, 27 Sep 2004 08:21:01 -0600 Organization: InterCation, inc. Message-ID: References: <11b4d.3849$d5.30042@newsb.telia.net> NNTP-Posting-Host: 166.70.154.50 X-Trace: news.xmission.com 1096294861 15921 166.70.154.50 (27 Sep 2004 14:21:01 GMT) X-Complaints-To: abuse@xmission.com NNTP-Posting-Date: Mon, 27 Sep 2004 14:21:01 +0000 (UTC) User-Agent: MT-NewsWatcher/3.2 (PPC Mac OS X) Xref: g2news1.google.com comp.lang.ada:4269 Date: 2004-09-27T08:21:01-06:00 List-Id: 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. Great if you're just a hacker having fun, terrible if you're someone maintaining Perl code. 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. I've seen those same programmers be able to digest 20,000 line Python programs in an afternoon. I've not got nearly as much experience with Ada, but I can't see it being much different in that regard. -- Adam Ruth adamruth at mac dot com