Slashdot Mirror


Best Practices for Programming in C

An anonymous reader writes "Although the C language has been around for close to 30 years, its appeal has not yet worn off. It continues to attract a large number of people who must develop new skills for writing new applications, or for porting or maintaining existing applications. This article provides a set of guidelines that can help you with your coding."

8 of 123 comments (clear)

  1. I wish that the code i'm debugging had... by neosake · · Score: 1, Funny












    Whitespace :)

    --
    "When a ball dreams, it dreams it's a frisbee"
  2. Write in C by pauljlucas · · Score: 4, Funny
    (Sing this as you would "Let it Be.")
    When I find my code in tons of trouble,
    Friends and colleagues come to me,
    Speaking words of wisdom:
    "Write in C."

    As the deadline fast approaches,
    And bugs are all that I can see,
    Somewhere, someone whispers:
    "Write in C."

    Write in C, Write in C,
    Write in C, oh, Write in C.
    LOGO's dead and buried,
    Write in C.

    I used to write a lot of FORTRAN,
    For science it worked flawlessly.
    Try using it for graphics!
    Write in C.

    If you've just spent nearly 30 hours,
    Debugging some assembly,
    Soon you will be glad to
    Write in C.

    Write in C, Write in C,
    Write in C, yeah, Write in C.
    BASIC's not the answer.
    Write in C.

    Write in C, Write in C
    Write in C, oh, Write in C.
    Pascal won't quite cut it.
    Write in C.

    --
    If you reply, do so only to what I explicitly wrote. If I didn't write it, don't assume or infer it.
  3. Better site by fredrikj · · Score: 4, Funny

    Here is a much better article about coding practices. It also covers broad topics, not just C in specific.

  4. More Tips! by mugnyte · · Score: 5, Funny

    Oh what enlightenment!

    - When you've learned all there is to know about C, find out how to simplify it a bit in C++. Notice the job security and look of awe when you master the ++.

    - After mucking around in these low-density languages, step up to Perl and see how a language built by a task-oriented person stomps one built by a system-oriented person. See your project file sizes shrink before your very eyes!

    - Now take your newfound magic ability to learn new languages and apply it to whipping out pages with PHP and MySQL for all your friends quickly! You'll be the talk of the C crawlers crowd! Hey! Gimmie some content! Aw, forget it - let me just play!

    - Now plumb the depths of (supposed) machine-independent laguanges by writing some Java and finding out what "Sun-certified" means! (hint: Sun owns it)

    - Optional: Head back to school to get a PhD in autoprogramming theory and self-construction methods. Sequester yourself away to your dorm room for endless hours of experiments training a neural net to convert tasks to code using the most efficient method possible.

    - Finally, wrap up your technical life by examining all these related language nuances holistically and achieve the zen of programming: "there is no language"

  5. Re:Nothing new by zulux · · Score: 4, Funny


    Ahem...

    1. Indent properly.
    2. Make Your code readable. //this is a great idea
    3. Use_good_variable_names.
    4. Avoid buffer *overflows.
    5. for (;;x = "Avoid using statements like goto.") {;}

    --

    Moneyed corporations, non-working 'poor' and criminal prisoners are turning productive citizens into tax-slaves.

  6. Re:the best practice by Nick+of+NSTime · · Score: 2, Funny

    No, sucky code is always left by bad programmers.

  7. Re:Looks like the author also knows VB by jilles · · Score: 2, Funny

    they probably left out some #define's that make it valid C :-)

    --

    Jilles
  8. Re:Using continue in place of the null statement? by JamesP · · Score: 3, Funny

    I prefer

    while (*dest++ = *src++) malloc(1000);

    --
    how long until /. fixes commenting on Chrome?