If any one ask you about the weakness of C, what is your opinion.
Is it the code management ? or what?
Printable View
If any one ask you about the weakness of C, what is your opinion.
Is it the code management ? or what?
I am not 100% sure, others may know for sure, but I always thought it was speed.
No its not speed, its its non-ease of use (for some, anyway)
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.
efficiency != defficiency
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.
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.
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.
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.
I agree, I hate the syntax in C, it's easier in C++, although C++ is more complex...Quote:
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 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++:
To me, C++ has a more complex syntaxis than C.Code:void (Class:: *fp)() = &Class::print;
((new Class)->*fp)();
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)
So, by showing an example of complex syntax in C++ you conclude that the C++ syntax is more complex than the C syntax?Quote:
Originally posted by Shiro
A little demonstration of some new operator and constructions in C++:
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.
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.Quote:
So, by showing an example of complex syntax in C++ you conclude that the C++ syntax is more complex than the C syntax?
It is not the best teaching language to beginning programming students.
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
>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
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
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.
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++.Quote:
c is tedious to code, prone to programmer errors, and more difficult to debug
You can do anything with C, how is that not versatile?Quote:
The rule set compared to c++ is much smaller making it a lot less 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.Quote:
Link lists in c++ are created using the stl, and oop allows for reusable code.
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.
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.Quote:
You can do anything with C, how is that not versatile?
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.Quote:
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.
Indeed.Quote:
At least come up with a verifiable argument instead of spouting stupid opinions.
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;
Quote:
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.
damn, my last post got messed up cause I hit the wrong button anyways:Quote:
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++.
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.
You can't create classes in c ;) Anyways, I was talking about coding programs, not the language itself.Quote:
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 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.
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.
excuse me, depending on the program ( it could save that much if not more).Quote:
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.
sorry again, I can't edit.Quote:
Originally posted by Terrance11
Anyways, I was talking about coding programs, not the language itself.
I meant: Anyways, I was talking about the language, not actually coding programs.
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).Quote:
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.
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.Quote:
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
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.Quote:
and since c is completely low level, it requires more code than c++.
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.Quote:
The only advantage for the stl is that it's standard
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.Quote:
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,
I agree completely.Quote:
Originally posted by face_master
No its not speed, its its non-ease of use (for some, anyway)
And no, im not that some.
templates, inheritance, other built in features of oop, and stl helps c++ save coding time over c, sorry, didn't explain that well.Quote:
Originally posted by Shiro
Therefore libraries are used. Why write code that has already been written?
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.Quote:
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.
I guess speed is the strength of C.
Am I right?
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...
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.Quote:
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.
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.Quote:
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...
That's a weakness of people using C, not of the language itself.Quote:
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.
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.Quote:
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.
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
Also C++ doesn't, unless you add functionality to your classes which takes care of it.Quote:
Another weakness of C (or is it a weakness of the programmer?) is that C doesn't perform bound checking.
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.Quote:
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.
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.
Or just lazy programmers... (but than again that's also a weakness)Quote:
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
I'm not only talking about using wrong functions but also using functions the wrong way like strcpy, memcpy, etc.
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.
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.Quote:
I'm not only talking about using wrong functions but also using functions the wrong way like strcpy, memcpy, etc.
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.Quote:
C and C++ give you more control, which is not a weakness
It's a weakness of c and a strength of c.Quote:
That's a weakness of people using C, not of the language itself.
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.
> 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.
> 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
Hahaha. I was itching to make a post like that.Quote:
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.
*shakes Prelude's hand*
>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...
>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
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.Quote:
That sounds more like a poor choice of language for the task.
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?Quote:
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