Are there reasons for beginner programmers to learn C ?
-
Are there reasons for beginner programmers to be taught C instead of C++? I'm not even thinking about Object Oriented programming, but simple declarative programming. I'm reading a lot of questions on CodeProject and on StackOverflow where people ask about issues with C language features that are so prone to errors and defect that it makes me cringe. A lot of those issues could be handled by simple C++ features (memory management (new/delete, smart pointers), strings, collections, references, ... ) I know there are lot of legacy code out there and it should still be maintained, but old code "ways" should not be the emphasis of the education. :confused:
Watched code never compiles.
Maximilien wrote:
Are there reasons for beginner programmers to be taught C instead of C++?
I would say not really however...
Maximilien wrote:
I know there are lot of legacy code out there and it should still be maintained, but old code "ways" should not be the emphasis of the education.
Huh? I suspect there is quite a bit of new development in C. In the following it is the second highest language. http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html[^] In terms of "education" it might be relevant to at least introduce students to a variety of languages like assembly, lisp and C.
-
C is very important and a great way to learn exactly how a computer works, which is a double edged sword but if you push on through and gain a good understanding of C all other languages are a piece of cake.
Shouldn't code be as machine/hardware independent as possible ? If you really want to go down on your knees and look under the hood, it is still possible with C++ and C, but that is not a beginner topic.
Watched code never compiles.
-
Imagine a c++ programmer armed with a few smart pointer classes from boost and the stl and no understanding of the underlying issues each is designed to address.
Well, I don't care (one example of many) how std::string internally manages the string, I just want to do
std::string s("hello world");
. it is safe, it is efficient.Watched code never compiles.
-
Are there reasons for beginner programmers to be taught C instead of C++? I'm not even thinking about Object Oriented programming, but simple declarative programming. I'm reading a lot of questions on CodeProject and on StackOverflow where people ask about issues with C language features that are so prone to errors and defect that it makes me cringe. A lot of those issues could be handled by simple C++ features (memory management (new/delete, smart pointers), strings, collections, references, ... ) I know there are lot of legacy code out there and it should still be maintained, but old code "ways" should not be the emphasis of the education. :confused:
Watched code never compiles.
Yes, C is very good at teaching you HOW computers work. Think of C as super-assembly. (And if you learn assembly language first, C is a walk in the park.) I run across too much C++ code that would be much more stable if more C-type constructs were used. On the other hand, I've also dealt with too much C++ code that is nothing but C with classes and misses out on some truly great features of C++. I've also observed that C programmers who start thinking about encapsulation end up with many of the basics of C++. I remember when I very first learned C++ and realized that the this pointer is what I'd already been doing in a lot of my code, though having it built in was quite nice. Final point and a narrow observation; I've worked with several people whose first language was C#. Not one of them understood memory management. I've also found that they had a hard time moving "down" toward C or even C# code that had to be very hardware aware.
-
Well, I don't care (one example of many) how std::string internally manages the string, I just want to do
std::string s("hello world");
. it is safe, it is efficient.Watched code never compiles.
-
Are there reasons for beginner programmers to be taught C instead of C++? I'm not even thinking about Object Oriented programming, but simple declarative programming. I'm reading a lot of questions on CodeProject and on StackOverflow where people ask about issues with C language features that are so prone to errors and defect that it makes me cringe. A lot of those issues could be handled by simple C++ features (memory management (new/delete, smart pointers), strings, collections, references, ... ) I know there are lot of legacy code out there and it should still be maintained, but old code "ways" should not be the emphasis of the education. :confused:
Watched code never compiles.
-
Are there reasons for beginner programmers to be taught C instead of C++? I'm not even thinking about Object Oriented programming, but simple declarative programming. I'm reading a lot of questions on CodeProject and on StackOverflow where people ask about issues with C language features that are so prone to errors and defect that it makes me cringe. A lot of those issues could be handled by simple C++ features (memory management (new/delete, smart pointers), strings, collections, references, ... ) I know there are lot of legacy code out there and it should still be maintained, but old code "ways" should not be the emphasis of the education. :confused:
Watched code never compiles.
Maximilien wrote:
Are there reasons for beginner programmers to be taught C instead of C++?
No.
Maximilien wrote:
I'm not even thinking about Object Oriented programming, but simple declarative programming.
It would be better to learn procedural C++ followed by C if the end is eventually to learn C. If the end is just to learn to program then there are easier choices.
Kevin
-
Imagine a c++ programmer armed with a few smart pointer classes from boost and the stl and no understanding of the underlying issues each is designed to address.
_Josh_ wrote:
Imagine a c++ programmer armed with a few smart pointer classes from boost and the stl and no understanding of the underlying issues each is designed to address.
Nevertheless, Stroustrup recommends learning high-level procedural C++ and then learning the low-level stuff, i.e., the exact opposite of what you say.
Kevin
-
Shouldn't code be as machine/hardware independent as possible ? If you really want to go down on your knees and look under the hood, it is still possible with C++ and C, but that is not a beginner topic.
Watched code never compiles.
Absolutely not! Code should do the best it can to solve the problem (for your customer.) I'm having this very argument now over writing generic code that can be ported to Linux vs. sharing that code which you can, but tailoring the core to each platform. (The current version is more generic and simply doesn't scale well.) I'm also tired of using programs that suck on every platform, all in the name of being cross-platform.
-
Yes, C is very good at teaching you HOW computers work. Think of C as super-assembly. (And if you learn assembly language first, C is a walk in the park.) I run across too much C++ code that would be much more stable if more C-type constructs were used. On the other hand, I've also dealt with too much C++ code that is nothing but C with classes and misses out on some truly great features of C++. I've also observed that C programmers who start thinking about encapsulation end up with many of the basics of C++. I remember when I very first learned C++ and realized that the this pointer is what I'd already been doing in a lot of my code, though having it built in was quite nice. Final point and a narrow observation; I've worked with several people whose first language was C#. Not one of them understood memory management. I've also found that they had a hard time moving "down" toward C or even C# code that had to be very hardware aware.
I agree with most in your post, except this:
Joe Woodbury wrote:
Yes, C is very good at teaching you HOW computers work.
It reflects what's happening "underneath" only very slightly. It doesn't make it immediately clear that the computer just blindly does whatever you throw at it. It's "too typed" to make it obvious that types do not really exist.
-
I agree with most in your post, except this:
Joe Woodbury wrote:
Yes, C is very good at teaching you HOW computers work.
It reflects what's happening "underneath" only very slightly. It doesn't make it immediately clear that the computer just blindly does whatever you throw at it. It's "too typed" to make it obvious that types do not really exist.
Perhaps I should have written that C is better than most languages at teaching you how computers work, but agree that's true only if the person teaching stresses that point. I still like assembly as a must-language to learn.
-
Are there reasons for beginner programmers to be taught C instead of C++? I'm not even thinking about Object Oriented programming, but simple declarative programming. I'm reading a lot of questions on CodeProject and on StackOverflow where people ask about issues with C language features that are so prone to errors and defect that it makes me cringe. A lot of those issues could be handled by simple C++ features (memory management (new/delete, smart pointers), strings, collections, references, ... ) I know there are lot of legacy code out there and it should still be maintained, but old code "ways" should not be the emphasis of the education. :confused:
Watched code never compiles.
I think that learning on C is not a good idea. They need to be able to deal with implementation of the application, not the details of memory management. Also the sooner they start working with objects the better. In fact I think that a beginning programmer should be programming in an environment with events so that they learn as soon as possible about dealing with events. It is non-linear thinking, and this starts to be important when doing threading also.
-
Are there reasons for beginner programmers to be taught C instead of C++? I'm not even thinking about Object Oriented programming, but simple declarative programming. I'm reading a lot of questions on CodeProject and on StackOverflow where people ask about issues with C language features that are so prone to errors and defect that it makes me cringe. A lot of those issues could be handled by simple C++ features (memory management (new/delete, smart pointers), strings, collections, references, ... ) I know there are lot of legacy code out there and it should still be maintained, but old code "ways" should not be the emphasis of the education. :confused:
Watched code never compiles.
The smaller the program memory you have to deal with the lower the level language you need to know. If you're working with a microprocessor with 8K memory you better be tight and right so you would need C unless speed is also a restriction then assembly. But if you're working with say 128K memory then the added flexibility of C++ might be an option. Right tool for the right job!
-
Shouldn't code be as machine/hardware independent as possible ? If you really want to go down on your knees and look under the hood, it is still possible with C++ and C, but that is not a beginner topic.
Watched code never compiles.
Maximilien wrote:
Shouldn't code be as machine/hardware independent as possible ?
Not if your writting a device driver.... I think if you build your knowledge up from HW level your are a much better software engineer (bias cos i started out as an embedded C guy)
-
Absolutely not! Code should do the best it can to solve the problem (for your customer.) I'm having this very argument now over writing generic code that can be ported to Linux vs. sharing that code which you can, but tailoring the core to each platform. (The current version is more generic and simply doesn't scale well.) I'm also tired of using programs that suck on every platform, all in the name of being cross-platform.
Language feature should make our lives easier to make portability as transparent as possible. Using standard C++ libraries (streams, collections, algorithms, memory management, ...) ), I can write portable code that runs on major OS without the need to think about it.
Watched code never compiles.
-
Maximilien wrote:
Shouldn't code be as machine/hardware independent as possible ?
Not if your writting a device driver.... I think if you build your knowledge up from HW level your are a much better software engineer (bias cos i started out as an embedded C guy)
Well, device driver is not a beginner topic; and is one exceptions, but I would be surprised if proper C++ features were used it could make better and safer code.
Watched code never compiles.
-
Python's a good starting language, the syntax is simple and it's easy to read, plus it enforces code indentation practices.
I've seen a little bit of Python (in MIT's video series), but not used it so I didn't feel I could recommend it.
-
_Josh_ wrote:
Imagine a c++ programmer armed with a few smart pointer classes from boost and the stl and no understanding of the underlying issues each is designed to address.
Nevertheless, Stroustrup recommends learning high-level procedural C++ and then learning the low-level stuff, i.e., the exact opposite of what you say.
Kevin
-
Yes, C is very good at teaching you HOW computers work. Think of C as super-assembly. (And if you learn assembly language first, C is a walk in the park.) I run across too much C++ code that would be much more stable if more C-type constructs were used. On the other hand, I've also dealt with too much C++ code that is nothing but C with classes and misses out on some truly great features of C++. I've also observed that C programmers who start thinking about encapsulation end up with many of the basics of C++. I remember when I very first learned C++ and realized that the this pointer is what I'd already been doing in a lot of my code, though having it built in was quite nice. Final point and a narrow observation; I've worked with several people whose first language was C#. Not one of them understood memory management. I've also found that they had a hard time moving "down" toward C or even C# code that had to be very hardware aware.
Joe Woodbury wrote:
I've worked with several people whose first language was C#. Not one of them understood memory management.
I am one of those people, and actually my first language is VB.NET. IDisposable[^] seems quite hard to implement correctly and even if you implement it there seem to be times when you simply cannot call it. Sometimes even Microsoft recommends not calling it if it gets to difficult[^]. There's also a great article on it right here on CP on the difficulties with IDisposable: IDisposable: What Your Mother Never Told You About Resource Deallocation[^]. In our company not calling IDisposable on a Crystal Reports Object caused quite some frustration... It led to customers not being able to print any more reports after 50 or something. Anyway, today a coworker had a problem. He had a BindingSource in WinForms and bound it to a list variable. After that he created a new list and assigned it to the variable. In his mind the variable and the BindingSource still pointed to the same memory. Unfortunately things don't quite work like that... Of course I wouldn't know how you guys fix that sort of stuff in C or C++. Anyway, having some clue as to what you're doing considering memory management is pretty handy at times, even in a high level language like C# or VB. But I think that's the problem, as a .NET programmer you're led to believe you don't need to know this stuff.
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
Are there reasons for beginner programmers to be taught C instead of C++? I'm not even thinking about Object Oriented programming, but simple declarative programming. I'm reading a lot of questions on CodeProject and on StackOverflow where people ask about issues with C language features that are so prone to errors and defect that it makes me cringe. A lot of those issues could be handled by simple C++ features (memory management (new/delete, smart pointers), strings, collections, references, ... ) I know there are lot of legacy code out there and it should still be maintained, but old code "ways" should not be the emphasis of the education. :confused:
Watched code never compiles.
It may produce a spiritual awaking. C was deliberately written to be unrestricted (to port the Unix O/S). It does what it's told to do, no questions asked. That means you have to pay attention to what you're doing. That is a good habit to learn. I'd even go so far as to suggest you dabble with the in-line assembler.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"As far as we know, our computer has never had an undetected error." - Weisert
"If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010