[H-GEN] Programing

Andrae Muys a.muys at mailbox.uq.edu.au
Sun Jul 30 22:11:02 EDT 2000

[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics.  Please observe the list's charter.          ]

On Mon, 31 Jul 2000, Martin Pool wrote:

> On Mon, Jul 31, 2000 at 11:16:36AM +1000, Andrae Muys wrote:
> >   (If your language has a sort function, don't use it for this one :)
> > Read all the numbers from a file (unlimited but assume will fit in
> > memory) sort them and write to another file.
> OK, this last one is a good example of the different things that C and
> Python will teach you.
Heh, actually I had intended that comment to apply to the previous problem
(Sort 500).  Sorting and searching are two fundamental tasks that any
programmer must be familiar with solutions to.  (As an aside, is anyone
familiar with the merge sort algorthm?  K&P refer to it, but provide no
details, I remember one reference in CS202, but I didn't understand the
importance of searching algorthms then, and I can't remember what was said

> In Python, it's very nearly a one-liner and if the sort() list method
> was allowed then it would be.  Nevertheless it's still a useful
> exercise in thinking about algorithms systematically, and so on.
> In C it's way more complicated: having an unlimited number of entries
> probably implies dynamic allocation, which is a very large kettle of
> fish for the beginner, but a powerful idea.

Hence the reason I included it.  Regardless of language, resource
allocation/deallocation is a very important issue.  Just using python or
java does not eliminate the need to remain aware of it.  Still as you say,
C forces the programmer to spend alot more time dealing with it, and this
is a weakness.  OTOH you will learn more about the lower level issues
facing programmers when learning C, and if you are going to learn C having
written 6-7 small programs it would be about time to learn about the
joys/horrors of malloc/free :).
<SNIP discussion of requirements analysis>

> `The Practice of Programming' is a simply superb book for working
> through this kind of topic.  For about $50 it will teach you more than
> some six month courses.
Truely an excelent book, but unfortunately not one that is all that useful
until you know a language.  TPOP uses C, C++, and Java for all its
examples, so you really do need to know one of them.  And the issues it
discusses are likely to be hard to grasp unless you haev already faced at
least some of them previously.


Andrae Muys <andrae at humbug.org.au> "Never ascribe to malice that which is
Shortech International Ltd          adequately explained by incompetence."
                                                     -Napoleon Bonaparte

* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.

More information about the General mailing list