[ale] C programming tips

Fletch fletch at phydeaux.org
Tue Jul 2 22:15:09 EDT 2002


>>>>> "cfowler" == cfowler  <cfowler at outpostsentinel.com> writes:

    cfowler> How many more cycles and memory is wasted on that?  

        Probably not enough to worry about on most modern hardware in
80-90% of the loads that it's likely to encounter.  The a more
relevant question might be `how much more time are you going to spend
debugging memory leaks in your C?', or `how much is it going to cost
because someone found a buffer overflow and r00ted my very important
box?' instead.  Hardware is cheap, programmer time isn't (well, it's
cheaper than it was but that's another thread . . . :).


    cfowler> C is easy.

        Granted C isn't hard to pick up (given the proper background
and access to good references; _A Book on C: Programming in C (4th
Edition)_ by Al Kelley, Ira Pohl, ISBN 0201183994), but for many tasks
something like Perl or Python is just as capable, most of the time
will take much less programmer time to implement, and is easily
replaced with C on the bare metal where necessary.


        Things like P&P have security advantages as well (they're less
susceptible to buffer overflows by virtue of their automatic memory
managment and a lack of pointers, and Perl's taint mode can make it
harder to use suspect input (or at least it'll make *tsk tsk*'s behind
your back at you when you do :)).


        As I said, I was only half serious in my sugguestion.  I know
C, I've used it within the past year (interfacing with libpcap, from
Perl using Inline of course :).  I would sugguest learning C++ (or
even Java) first though, as you'd probably pick up fewer bad habits
you'd have to unlearn if you went C => C++.



        At any rate, I'll stop beating the periodic-thread-dead-horse
and leave with a quote . . .


        If you want to program in C, program in C. It's a nice
        language. I use it occasionally... :-)
                --Larry Wall in <7577 at jpl-devvax.JPL.NASA.GOV>

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
770 933-0600 x211(w)  |  scary questions." -- Jules                =(___)=
770 294-0820 (m)      |                                               U

---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list