PDA

View Full Version : What is the weakness of C ?



zahid
12-31-2002, 11:42 PM
If any one ask you about the weakness of C, what is your opinion.

Is it the code management ? or what?

MethodMan
01-01-2003, 12:23 AM
I am not 100% sure, others may know for sure, but I always thought it was speed.

face_master
01-01-2003, 12:28 AM
No its not speed, its its non-ease of use (for some, anyway)

Imperito
01-01-2003, 01:41 AM
Well plain C doesnt give you the advantage of object oriented programming, which hurts both project scalability and code reusability, so I'd say the main deficiency is the efficiency with which it can be programmed in.

face_master
01-01-2003, 01:46 AM
efficiency != defficiency

Imperito
01-01-2003, 03:47 AM
lol, pendantic aren't we? Any nothing about my ending a sentence with a preposition?

Fine.

I'd say the greatest deficiency of C lies in the more limited capacity for scalable efficiency when programming in it.

joshdick
01-01-2003, 04:08 AM
I think C code is much more difficult to decipher than C++ code. What the heck is malloc and dealloc, etc? C++ is much simpler about that—New and delete.

My biggest gripe with C code is input and output. I keep seeing all of that printf, fprintf, scanf stuff along with the % operator which means you have to specify which type all of your variables are in order to output them. That's soooooo overly complicated. Cout and cin make much more sense. There's console output and console input. Their operators help to make the code even easier to read.

I really don't see why anyone would want to learn C when they could learn C++ just as well.

Shiro
01-01-2003, 04:36 AM
C++ is a more complex language than C, it has the elements of C and a lot more. Also the object oriented paradigm is harder to understand for beginners than the procedural paradigm. C is a small language and quite easy to understand.

But the main disadvantage are the already mentioned elements code management, scalability and reusability. The advantages of object orientation are most visible in large scale software development. So the main weakness of C is that it doesn't support object orientation very well.

JoeSixpack
01-01-2003, 07:17 AM
A weakness of C (and of C++ to a large extent) is that it forces you to think in terms of the machine too much. This is not always the most efficient (in terms of productivity) or elegant way to solve every problem. Or so they say.

ammar
01-01-2003, 07:35 AM
Originally posted by joshdick
I think C code is much more difficult to decipher than C++ code. What the heck is malloc and dealloc, etc? C++ is much simpler about that—New and delete.

My biggest gripe with C code is input and output. I keep seeing all of that printf, fprintf, scanf stuff along with the % operator which means you have to specify which type all of your variables are in order to output them. That's soooooo overly complicated. Cout and cin make much more sense. There's console output and console input. Their operators help to make the code even easier to read.

I really don't see why anyone would want to learn C when they could learn C++ just as well.

I agree, I hate the syntax in C, it's easier in C++, although C++ is more complex...

Shiro
01-01-2003, 08:40 AM
>I hate the syntax in C, it's easier in C++, although C++ is more
>complex...

??

C++ has C's syntax and quite a lot more more language elements and constructions, like new operators, pointers to member functions, templates, ways of inheritance, abstract classes etc. A little demonstration of some new operator and constructions in C++:



void (Class:: *fp)() = &Class::print;
((new Class)->*fp)();


To me, C++ has a more complex syntaxis than C.

What, in your opinion, makes C++ easier than C? (I think you've used the wrong words in your post, I think you meant something different than syntaxis)

Sang-drax
01-01-2003, 09:31 AM
Originally posted by Shiro

A little demonstration of some new operator and constructions in C++:

So, by showing an example of complex syntax in C++ you conclude that the C++ syntax is more complex than the C syntax?

Let me show some advanced C syntax:
http://www.es.ioccc.org/2000/anderson.c

I admit that the syntax of C++ can get a bit esoteric sometimes though, especially when dealing with templates.

Shiro
01-01-2003, 10:00 AM
So, by showing an example of complex syntax in C++ you conclude that the C++ syntax is more complex than the C syntax?


No, you probably forgot to read the first lines of my post: "C++ has C's syntax quite a lot more more language elements and constructions,.. ". So C syntax is C++ syntax and I gave an example to show that with C++ the syntax hasn't become easier.

Mister C
01-01-2003, 10:20 AM
It is not the best teaching language to beginning programming students.

Polymorphic OOP
01-01-2003, 10:34 AM
Its "incomplete type-safety" and the fact that it doesn't have templating or direct support of OOP.

So pretty much the weakness of C is that it's not C++ :D

Prelude
01-01-2003, 10:37 AM
>So pretty much the weakness of C is that it's not C++
Except to people who feel that the C/C++ relationship is similar to Algol-60/Algol-68, which was quite the fiasco. ;)

-Prelude

frenchfry164
01-01-2003, 11:21 AM
most people that use C are people who used it b4 C++ was big and are just to stubborn to learn C++.

Sang-drax: that wasn't complicated syntax, that was just an idiot programmer trying to be funny.

Shiro: I hope that code you gave wasn't the complicated syntax you were referring too. It's just a function pointer, and you are dynamically allocating...wait. You didn't provide a variable for the new class you made. Loser:p

Terrance11
01-01-2003, 03:49 PM
c is tedious to code, prone to programmer errors, and more difficult to debug than just about any other language.

The rule set compared to c++ is much smaller making it a lot less versatile, and since c is completely low level, it requires more code than c++.

Link lists in c++ are created using the stl, and oop allows for reusable code.

c++ is a much more complex language, and I agree that a lot of old time c-er's aren't willing to learn object oriented programming for many different reasons, but it doesn't stop them from using c++ syntaxes, and making c++ code that's 90% c code.

C is only low level, and that's the main weakness in my opinion.

Crimpy
01-01-2003, 04:20 PM
c is tedious to code, prone to programmer errors, and more difficult to debug

C++ really isn't any better, but you can be reasonably sure that you'll use most of C for any given program where with C++ you won't even use 15% of the language even for huge programs. You can know and use all of C regularly but probably only a handful of people in the world know all of C++.


The rule set compared to c++ is much smaller making it a lot less versatile

You can do anything with C, how is that not versatile?

Link lists in c++ are created using the stl, and oop allows for reusable code.

The only advantage for the stl is that it's standard, any moron can write a reusable linked list library in C. Most C++ people don't even know how to make a linked list, that's why they rave about the stl.

Don't get me wrong, I love C++ and use it whenever I can, but I don't run around with a closed mind making idiotic statements. At least come up with a verifiable argument instead of spouting stupid opinions.

JoeSixpack
01-01-2003, 04:50 PM
You can do anything with C, how is that not versatile?

I don't think this is what he meant. The built in language features of C++ allows you more versitility in the way you wish to construct your program. However this may not always be an advantage; which I believe you touched on in your 25.123% of people prefer pepsi statement.



The only advantage for the stl is that it's standard, any moron can write a reusable linked list library in C. Most C++ people don't even know how to make a linked list, that's why they rave about the stl.

I'd agree that the main benefit of the stl is that it offers a standard interface; however I gather it's a little more than a naive linked list that any moron could produce.


At least come up with a verifiable argument instead of spouting stupid opinions.

Indeed.

Nick
01-01-2003, 05:02 PM
Just the syntax of templates should convince anyone
that c++ ranks among the most complicated languages
syntactaly. This is a syntax error
vector<vector<int>> v; But this is not
vector<vector<int> > v;

Terrance11
01-01-2003, 07:26 PM
Originally posted by Crimpy
C++ really isn't any better, but you can be reasonably sure that you'll use most of C for any given program where with C++ you won't even use 15% of the language even for huge programs. You can know and use all of C regularly but probably only a handful of people in the world know all of C++.

You can do anything with C, how is that not versatile?
The only advantage for the stl is that it's standard, any moron can write a reusable linked list library in C. Most C++ people don't even know how to make a linked list, that's why they rave about the stl.

Don't get me wrong, I love C++ and use it whenever I can, but I don't run around with a closed mind making idiotic statements. At least come up with a verifiable argument instead of spouting stupid opinions.

Terrance11
01-01-2003, 07:38 PM
Originally posted by Crimpy
C++ really isn't any better, but you can be reasonably sure that you'll use most of C for any given program where with C++ you won't even use 15% of the language even for huge programs. You can know and use all of C regularly but probably only a handful of people in the world know all of C++.

damn, my last post got messed up cause I hit the wrong button anyways:

that's one of the things that's so great about c++. C++ consists of about 7000 rules sets. You can be a functional programmer in c++ knowing a few thousand.

C is a relatively small language, which is powerful, but a lot less flexible.

And I would say that debugging a well written object oriented c++ program using stl takes 1/4-1/2 the time the same program would take to debug in c. Assuming the programmer knew both languages extremely well. C++'s flexibilty allows you to save a lot of lines of code, and stl saves you a heck of lot of time not having to write out tedious algorithms.

And my guess is that no one knows all of c++, at least not off the top of their head. Stroustrup himself said that he doesn't have a complete understanding of all of the standardized c++ language.


Originally posted by Crimpy
You can do anything with C, how is that not versatile?
The only advantage for the stl is that it's standard, any moron can write a reusable linked list library in C. Most C++ people don't even know how to make a linked list, that's why they rave about the stl.


You can't create classes in c ;) Anyways, I was talking about coding programs, not the language itself.

You can code anything in assembler, why even use c???

And you're right, one advantage of stl is that it's standardized, but it's certainly not the only advantage.

STL has the algorithms to help a programmer code virtually any type of program you can think of, and probably saves the coder 10's to 100's of hours on a large project. If that's not an advantage, then I say there's no advantage of using c over assembly as well.

frenchfry164
01-01-2003, 07:44 PM
I don't use STL much. Most of the time I'll make my own linked list with classes. I just don't like vectors. Now I bet 10 people are going to start yelling and throwing their opinions at me, but I just like linked lists better.

Terrance11
01-01-2003, 07:45 PM
Originally posted by Terrance11
And I would say that debugging a well written object oriented c++ program using stl takes 1/4-1/2 the time the same program would take to debug in c.

excuse me, depending on the program ( it could save that much if not more).

Terrance11
01-01-2003, 07:49 PM
Originally posted by Terrance11
Anyways, I was talking about coding programs, not the language itself.

sorry again, I can't edit.

I meant: Anyways, I was talking about the language, not actually coding programs.

Polymorphic OOP
01-01-2003, 07:55 PM
Originally posted by frenchfry164
I just don't like vectors. Now I bet 10 people are going to start yelling and throwing their opinions at me, but I just like linked lists better.

If you don't understand situations where it's better to use arrays or vectors instead of linked lists then that's not a question of opinion, it's of stupidity (sorry to be harsh, but each have their place and neither makes sense in all situations).

Shiro
01-02-2003, 04:03 AM
Shiro: I hope that code you gave wasn't the complicated syntax you were referring too. It's just a function pointer, and you are dynamically allocating...wait. You didn't provide a variable for the new class you made. Loser


First it is a member function pointer and not just a function pointer, second I didn't make a new class and third a new variable isn't always necessary. I can imagine you don't find the code complicated, but that's probably because you are a very well C++ programmer.



and since c is completely low level, it requires more code than c++.


Therefore libraries are used. Why write code that has already been written? A lot of the low level things, like implementation of trees, graphs and other datastructures and a lot of algorithms are implemented a lot of times. So when using C in a software project, programmers, coding in whatever language, usually first take a look around what code they can reuse.



The only advantage for the stl is that it's standard


In my opinion it is a great advantage. You are right that every programmer should be able to write a linked list library, but if your goal is to use a linked list and not to write a linked list implementation, an implementation already available in the standard library is preferred. Then you don't need to spend time on designing, writing and probably debugging a linked list library. Also, if you use standard code, others can easily use your code without being required to have your libraries too.



C is a relatively small language, which is powerful, but a lot less flexible. (..) C++'s flexibilty allows you to save a lot of lines of code,


If that is your definition of flexible, then I disagree, because when using a library, a C program also doesn't require a lot of lines of code.

civix
01-02-2003, 05:23 AM
Originally posted by face_master
No its not speed, its its non-ease of use (for some, anyway)

I agree completely.
And no, im not that some.

Terrance11
01-02-2003, 05:55 AM
Originally posted by Shiro
Therefore libraries are used. Why write code that has already been written?

templates, inheritance, other built in features of oop, and stl helps c++ save coding time over c, sorry, didn't explain that well.






Originally posted by Shiro
If that is your definition of flexible, then I disagree, because when using a library, a C program also doesn't require a lot of lines of code.

Not my only definition of flexible. :) C function libraries are great, but templates allow the same general set of operations using various data types, and are sorely missed in C.

zahid
01-02-2003, 06:51 AM
I guess speed is the strength of C.
Am I right?

Monster
01-02-2003, 07:39 AM
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...

zahid
01-02-2003, 07:52 AM
Ohh.. I don't think it's a weakness of C. Programmers know this. It's because of so open and so free language.

Monster
01-02-2003, 08:09 AM
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.

Polymorphic OOP
01-02-2003, 08:10 AM
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.

Polymorphic OOP
01-02-2003, 08:11 AM
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.

Monster
01-02-2003, 08:43 AM
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.

Prelude
01-02-2003, 09:10 AM
> 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

Shiro
01-02-2003, 09:12 AM
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.

Monster
01-02-2003, 09:42 AM
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.

Polymorphic OOP
01-02-2003, 03:21 PM
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.

JoeSixpack
01-02-2003, 04:17 PM
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.

Nick
01-02-2003, 04:37 PM
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.

Monster
01-03-2003, 03:41 AM
> 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.

Prelude
01-03-2003, 09:59 AM
> 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

Polymorphic OOP
01-03-2003, 10:13 AM
Originally posted by Prelude
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.

Hahaha. I was itching to make a post like that.

*shakes Prelude's hand*

Monster
01-03-2003, 11:13 AM
>So you're saying that C should baby the programmers like Pascal?
>If in fact you are a moron, you shouldn't be using C.

No I don't say that, read my posts... I said "it's a weakness". You translate it to: "I wan't internal bound checking in C because morons should also get a change to program in C" ... ;)

> One of the reasons you can do so much with C is because the language assumes you're not a moron.

Every strength has a weakness...

Prelude
01-03-2003, 11:32 AM
>Every strength has a weakness...
Of course, everyone has a different perspective. The perspective of C's designers was to give power and flexibility instead of safety. I don't consider that choice to be a weakness of the language, merely a feature that caters to some and not to others. You obviously consider it to be a weakness. The difference between weakness and strength is a matter of opinion, nothing more.

-Prelude

JoeSixpack
01-03-2003, 12:49 PM
That sounds more like a poor choice of language for the task.

Of course. Due to a weakness of the language. If there was some sort of all encompassing super language with no faults, everbody would be using it for always for everything.


The perspective of C's designers was to give power and flexibility instead of safety. I don't consider that choice to be a weakness of the language

Whether it's a weakness or not depends on your requirements. Would you advocate using C for everything? If not, why? What's wrong with C that make it a poor choice of language for particular tasks?