What is the weakness of C ?

This is a discussion on What is the weakness of C ? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I guess speed is the strength of C. Am I right?...

  1. #31
    Registered User zahid's Avatar
    Join Date
    Aug 2001
    Posts
    532
    I guess speed is the strength of C.
    Am I right?
    [ Never code before desk work ]
    -------------------------------------:-->
    A man who fears Nothing is the man who Loves Nothing
    If you Love Nothing, what joy is there in your life.
    =------------------------------------------------------= - I may be wrong.

  2. #32
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Another weakness of C (or is it a weakness of the programmer?) is that C doesn't perform bound checking. It's easy to overwrite the end of a string and actually overwrite other variables. Hackers can use this weakness...

  3. #33
    Registered User zahid's Avatar
    Join Date
    Aug 2001
    Posts
    532
    Ohh.. I don't think it's a weakness of C. Programmers know this. It's because of so open and so free language.

  4. #34
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Originally posted by zahid
    Ohh.. I don't think it's a weakness of C. Programmers know this. It's because of so open and so free language.
    Programmers know this (weakness of C) but they are also very lazy. If they want to read a persons name they allocate a buffer of 100 bytes long (should be enough) and read the name from input with the gets function. This is just a simple (stupid) example but I have seen it many times. An the most common mistake: people using the strcpy function without checking if the target array is large enough.

  5. #35
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by Monster
    Another weakness of C (or is it a weakness of the programmer?) is that C doesn't perform bound checking. It's easy to overwrite the end of a string and actually overwrite other variables. Hackers can use this weakness...
    I wouldn't call that a weakness, that's just something that comes when people get access to any type of pointer as well. Besides, I'd rather do my own bounds checking than use internal bounds checking. Everytime you access an array you don't have to explicitly or implicitly check to see if it's within bounds -- often times you already know.

  6. #36
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by Monster
    Programmers know this (weakness of C) but they are also very lazy. If they want to read a persons name they allocate a buffer of 100 bytes long (should be enough) and read the name from input with the gets function. This is just a simple (stupid) example but I have seen it many times. An the most common mistake: people using the strcpy function without checking if the target array is large enough.
    That's a weakness of people using C, not of the language itself.

  7. #37
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Originally posted by Polymorphic OOP
    That's a weakness of people using C, not of the language itself.
    If there are so many people (also professional) that make this kind of mistakes, than I don't call it a weakness of the programmer but a weakness of the progrogramming language.

  8. #38
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    > If there are so many people (also professional) that make this kind of mistakes, than I don't call it a weakness
    >of the programmer but a weakness of the progrogramming language.
    Or rather, a weakness of the books and teachers who told them that an old function which is unsafe and should have been removed from the standard libraries long ago is the best solution.

    -Prelude
    My best code is written with the delete key.

  9. #39
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Another weakness of C (or is it a weakness of the programmer?) is that C doesn't perform bound checking.
    Also C++ doesn't, unless you add functionality to your classes which takes care of it.

    If there are so many people (also professional) that make this kind of mistakes, than I don't call it a weakness of the programmer but a weakness of the progrogramming language.
    A nice point of view, which I at first agreed with. If most people using a system and all make the same mistake in using the system, then this can be seen as a defect in the design of the system. If the design was better, people could immediately see that the system can't be used like they did or the system could even prevent people from misusing it.

    But, in C++ classes, bound checking can be built in. In C also such could be built in libraries using datastructures. Note that these kind of checks are all higher level operations, both C and C++ allow such higher level operations, but also low level operations.

    So this aspect of C and C++ is a consequence of the low level character of the languages. Programmers using C or C++ must know this, if they still make the error, it can be seen as a weakness of the programmers.

  10. #40
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Originally posted by Prelude
    > If there are so many people (also professional) that make this kind of mistakes, than I don't call it a weakness
    >of the programmer but a weakness of the progrogramming language.
    Or rather, a weakness of the books and teachers who told them that an old function which is unsafe and should have been removed from the standard libraries long ago is the best solution.

    -Prelude
    Or just lazy programmers... (but than again that's also a weakness)

    I'm not only talking about using wrong functions but also using functions the wrong way like strcpy, memcpy, etc.

  11. #41
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    A logical error on the part of the programmer can not be considered a fault of the language being used. Attempting to access data beyond the bounds of an array can happen in just about any language -- the fact that other languages do internal error checking doesn't change the fact that there would be a problem with the program anyway! Trying to access an index beyond the bounds of an array is a logical error that exists whether or not the language checks for it. If you are really that poor a programmer that you need the computer to check for you, then make a function that checks bounds which takes a parameter for the array index, but that won't fix any problems, it only masks them, just like in other languages. C and C++ give you more control, which is not a weakness. If the programmer using the language can't deal with it, that's their problem, not the language's.

    I'm not only talking about using wrong functions but also using functions the wrong way like strcpy, memcpy, etc.
    How is that a weakness of the language. If a person uses a function that they don't understand how to use, then that's their problem.

  12. #42
    Registered User
    Join Date
    Sep 2002
    Posts
    272
    C and C++ give you more control, which is not a weakness
    If you don't need more control but still have to write (potentially bug ridden) extra code because of the control available, then it's a weakness.
    Joe

  13. #43
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    That's a weakness of people using C, not of the language itself.
    It's a weakness of c and a strength of c.
    An out of range array access can result in code that
    appears to run correctly but at a critical point
    will fail or effect other parts of the program. Some other
    languages will throw an exception.

  14. #44
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    > A logical error on the part of the programmer can not be considered a fault of the language being used.

    I'm not saying it's a fault of the language, just a weakness...

    > Attempting to access data beyond the bounds of an array can happen in just about any language -- the fact that other languages do internal error checking doesn't change the fact that there would be a problem with the program anyway! Trying to access an index beyond the bounds of an array is a logical error that exists whether or not the language checks for it.

    There is a big difference between doing internal checking or not. Like I said in my first post without internal bound checking you can overwrite other variables. It's relatively easy to hack these programs.

    > How is that a weakness of the language. If a person uses a function that they don't understand how to use, then that's their problem.

    Okay, maybe I didn't explain this right. The function is used in a "correct" way but without bound checking of the programmer itself.

  15. #45
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    > If you don't need more control but still have to write (potentially bug ridden) extra code because of the control available, then it's a weakness.
    That sounds more like a poor choice of language for the task.

    >The function is used in a "correct" way but without bound checking of the programmer itself.
    So you're saying that C should baby the programmers like Pascal? One of the reasons you can do so much with C is because the language assumes you're not a moron. If in fact you are a moron, you shouldn't be using C.

    -Prelude
    My best code is written with the delete key.

Page 3 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Microsoft Interview Questions
    By Kohatian 3279 in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 04-29-2006, 04:00 PM
  2. weakness and strenghs of Polymorphism?
    By must in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2002, 10:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21