Are there reasons for beginner programmers to learn C ?
-
I somewhat agree, but I would chose those languages only for lower level of education.If it's for college than I am for C all the way. What the heck, C should be in secondary schools as well.
C should not be inflicted upon anyone. It is clumsy, slow to code and inelegant, and is a source of the World's most inefficient and buggy programs. It is only due to inertia and legacy that it still survives, mostly within failing companies.
-
Yes - C is simpler and a much smaller language than C++. C is great for learning about functions, pointers, memory management and calling operating system libraries. C is a beautiful language that allows you to program efficient algorithms. You can learn about how different data types are stored and represented in memory. C will give you the power to implement classic computer science structures and algorithms: arrays, trees, sorting and linked lists. If you 'get' C, you will know that you have what it takes to be a real programmer. C will give you small, lightweight and fast executables. With C, you will have a very good foundation that will complement what you learn with other higher level languages; and the lower level assembly language. Once you know C, it will stand apart from all other languages that you learn.
bigbadben wrote:
Yes - C is simpler and a much smaller language than C++
Exactly. This way students are focused on the important stuff when they are learning programming instead of being distracted from the hugeness of C++. I believe the most important thing to learn is about pointers. Pointers knowledge will be useful even when the student is learning languages that does not require pointer manipulation. They will anticipate many of the managed programming pitfalls if they are familiar of how pointers work and how it differs from stack allocated types.
"To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson
-
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: 1. C forms the basis for many other languages: e.g. C++, C#, and Java. 2. C is good for learning core, low-level programming skills. After these are learned, you can approach object-oriented programming without being distracted by low-level programming issues. 3. C is good for learning function-oriented programming, which complements object-oriented programming. (People who only know object-oriented programming create classes with unmaintainable 300-line methods.) 4. C can be used as a kind of "assembly language", i.e. for low-level modules that have to be the most efficient, without the overhead of C++. 5. C is a small simple language that won't overwhelm a beginner with the complexity of C++. 6. The time spent studying C isn't wasted, since C++ is a superset of C.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
-
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.
Depends on what you want to teach: Do you want them to understand computers, or do you want them to understand programming? For the former, start at boolean logic, continue with gates, assembler, and work your way up through C and C++. For the latter start at UML business diagrams, continue with requirements diagrams, component diagrams, class diagrams, maybe state or sequential diagrams. Then use an actual language like C++. Alternately use something else instead of UML, there are plenty of other diagram types, I know when I learned I was using Flowcharts and Gant diagrams mostly, there was no UML at that time. Most likely you'll want a bit of both worlds though: a bit about program flow and a bit about computer logic. Personally I think neither C nor C++ is useful for that purpose: both suffer from the pitfalls of various C programming language elements. My first language was Pascal, and I still think that was quite reasonable. It is much less prone to problems, is close enough to the computer to stay in touch with how it works, but still got a decent selection of commands to control the program flow. I suppose the same can be said about a number of other languages too. But my personal experience was with Pascal, and I'm convinced that was a very good choice.
-
PIEBALDconsult wrote:
Not as a first language
How about assembly?
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS My LinkedIn Profile
It's interesting that you mention "assembly". The very history of C as a programming language speaks loudly. Long ago and long ago (as the Native Americans would say), Bell Laboratories purchased a DEC PDP-7 computer. That machine was quite primitive, more or less a "minimal" computer. It had either 4k or 8k memory of 18 bit words, 16 op-codes, no multiply or divide instructions, no index registers, and primitive indirect addressing. It did have a set of memory locations that were "auto-increment" that simulated very primitive index registers, but were not terribly useful over all. The principle I/O were paper tape and a model 33 teletype. In fact, a bare-bones PDP-7 only had a teletype, in which case it would have been a model 35 ASR, which had paper tape read and write included. VERY slow! Bell Labs wrote a language called BPL (for Bell Programming Language, I think) which they used as an alternative to the assembly language supplied by DEC. I've never seen any details on BPL. However, Bell Labs used BPL to write a FORTRAN compiler for the PDP-7, as odd at that might sound. When DEC came out with the PDP-11, Bell Labs bought one and jumped on it like a duck on a June bug! They wrote a translator that converted the BPL translator (probably other programs as well) to run on the PDP-11. Using the translated BPL, they developed a new language, C. From rags to riches in terms of machine language capability, the C designers included features in the language to utilize many of the newly available features of the PDP-11. In particular, the auto-increment/decrement and to-memory instruction modifiers were incorporated in the ++/--/+=/-= operators. The indirection modifiers gave rise to the pointer operators. The above information I learned from a Bell Labs programmer/developer at at DECUS (Digital Equipment Computer User's Society) meeting. He was one of the original creators of C, but unfortunately I forget his name. He told me that when they developed C, they had in mind a "portable assembler" that would allow them to port code to any architecture by merely writing a translator for C for that new machine. Good C programmers, he said, visualized assembly code as they wrote in C. For anyone interested, here is a link to the PDP-11 "card": [^] Given the .NET availability these days, it ma
-
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.
Actually I agree with this. Normally I build control systems when VB.net (yes the whole control, serial comms.... all in VB). But I've found knowing C really makes you think about how you code and how it will impact the final product. I only find C fun when working on small embedded boards (Tern, Arduino), it's great to flex your skills in figuring out how to do something with almost no resources. I used to be down on C thinking of it as an outdated language, but I've since come around to realize that every language has its niche. C is for low level - embedded & kernel level, where higher languages work well for leveraging the power of the lower stack. But knowing how the lower stack basically works will help your decisions when coding in high level. One side note; I like C & VB.net, but I still can't stand C# for some reason.
-
Yes: 1. C forms the basis for many other languages: e.g. C++, C#, and Java. 2. C is good for learning core, low-level programming skills. After these are learned, you can approach object-oriented programming without being distracted by low-level programming issues. 3. C is good for learning function-oriented programming, which complements object-oriented programming. (People who only know object-oriented programming create classes with unmaintainable 300-line methods.) 4. C can be used as a kind of "assembly language", i.e. for low-level modules that have to be the most efficient, without the overhead of C++. 5. C is a small simple language that won't overwhelm a beginner with the complexity of C++. 6. The time spent studying C isn't wasted, since C++ is a superset of C.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
I agree with all but item 3 in your list: my experience is quite the contrary of what you claim: it used to be the old C-style programmers wgo produced the unmaintainable 300 lines of code functions, not the OO programmers who normally recognized repetitive parts and refactored them into seperate functions. And it's the same C-programmers that used copy/paste programming to implement an alternate branch in a function, needlessly bloating them to several 1000 lines during the lifetime of an application. However, in truth this may be less connected to being C or C++ programmers, but rather to being good programmers! ;)
-
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.
For a beginner, if the choice was between C and C++, I'd definitely start with C. Why? because C++ has too many voodoo automatic behaviors that bite even experienced C++ developers in the ass. C, by comparison is relatively straightforward to understand the complete behavior of the language. But I wouldn't pick either one as a first language. My first language was APL, but I wouldn't recommend that either. I'd probably start with one of the current crop of dynamic languages. -Shon
-
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:
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.
Emphasis? Certainly not. However, all of software is made up of layers upon layers of leaky abstractions. Sooner or later, quirks from the lower levels leak through to the upper levels. If you already have a working understanding of the lower level, then what's happening makes sense and you already have an idea of what to do about it. If not, you sit there dumbfounded, without a clue where to start debugging the problem. You will absolutely need to know how the next layer down works to deal with bugs that appear in the layer you're working at.
Maximilien wrote:
Are there reasons for beginner programmers to be taught C instead of C++?
I can't think of any. In fact, I wouldn't recommend either language for beginner programmers. Beginner programmers are learning basic concepts, like if statements, boolean logic, loops, variables, functions, etc. Any language that allows them to learn those concepts without having to worry about other details is the best one to start with. In fact, it shouldn't be a language they might use for real work, because they'll also be learning lots of bad habits that the rest of us don't want them to be bringing into our production code. Sometimes a student has to start learning with the language they'll be using for production code, but that just makes it harder for them because they'll have to unlearn a lot of bad habits without really understanding what's going on, why those habits are bad, and what to replace them with. Its actually easier to take concepts forward into another language, learning good habits as you learn the language, than unlearn bad habits.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
-
Not as a first language. Nor should an OOP-only language (VB, C#, etc.) be the first language. In my opinion BASIC and Pascal (and maybe Perl?) are still good first languages even though they won't apply very well to modern business. Professional developers still to be smacked with C.
I had some initial introduction to Basic in high school - way back in trash-80 (TRS-80) days. But my first and I feel MOST beneficial college class I EVER took was programming logic with pseudo-code and flow charting. After that my first language was C then later C++. If I had tried to learn C++ first I'm not sure I would have understood what was actually happening. When I'm writing code I want to make sure I understand what exact is happening. There is a lot in C++ that was much easier to learn knowing the basic C language.
-
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.
Depends on the type of programmer ... I would say that letting a Java-programmer lose with C++ are a receipt for disasters to come ... If you're a hardware/os-agnostic, you might get away with not learning but I wouldn't bet on it.
-
C should not be inflicted upon anyone. It is clumsy, slow to code and inelegant, and is a source of the World's most inefficient and buggy programs. It is only due to inertia and legacy that it still survives, mostly within failing companies.
Rob Ford 2 wrote:
It is clumsy, slow to code and inelegant, and is a source of the World's most inefficient and buggy programs. It is only due to inertia and legacy that it still survives, mostly within failing companies.
Bold statement, but what arguments do you have to support it?
-
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, absolutely and unequivocally yes (except for the "instead of C++" part). The point is not to emphasize old ways. The reason there are so many cringe-worthy issues with C-programming is that so many people never properly learned how to do it. C is practically the ideal first real language for an introductory programming course. Why? Because everything that you learn to do on your own in C is still being done in newer languages, just behind the scenes. (Are there pointers in C# and Java? Absolutely, you just don't handle them as straightforwardly, and the difference between object types and primitive types will just be pure mystery to a beginner...unless that beginner has first understood pointers.) You don't learn mathematics by starting with higher order abstractions and using calculators to do the mere arithmetic, then only later going and learning to add and subtract if you ever get a job that requires it. You learn what numbers mean, how they move and relate to one another on a lower level, and how little things build into bigger ones. You count, then you add and subtract, then you multiply and divide, and so on. C, unlike assembly, is about the right distance from the machine that you don't have to directly think about hardware in most cases, but you do need to think about the basic issues involved in understanding programming concepts. What does a computer do? How does it do it? How are data remembered and acted upon? Why does it make a difference which way you do something? How does a programmer look out for edge cases, efficiency issues, and all the pitfalls that arise from a computer doing exactly what you tell it? C teaches precision, algorithm design and choice, memory efficiency, and other basic things a beginner won't know (like how to translate a notion of what you want to do into a precisely specified set of instructions), all in a pretty simple package with straightforward syntax, and the ability to split pieces of your program out into separate routines for organizational and abstraction purposes. Object-orientation is a mode of programming that builds upon everything learned in C, and it not only becomes a lot to swallow at once, it also bears so much less of a straightforward relationship to what the computer is doing that it should be learned afterward. Garbage-collected languages, or those with massive built-in libraries, are the same way: "Look, now that you understand what is going on in managing memory, here is a tool that, when appropriate, can do it for you." Basically it b
-
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.
Well,
Maximilien wrote:
std::string s("hello world");
.I'm using VC5. Never missed that Construct, and I don't see the efficiency improvement against what I would write:
'CString s("Hello World");
Bram van Kampen
-
C should not be inflicted upon anyone. It is clumsy, slow to code and inelegant, and is a source of the World's most inefficient and buggy programs. It is only due to inertia and legacy that it still survives, mostly within failing companies.
Rob Ford 2 wrote:
C should not be inflicted upon anyone.
It is clumsy, slow to code and inelegant, and is a source of the World's most inefficient and buggy programs. It is only due to inertia and legacy that it still survives, mostly within failing companies.Well, This is an increadibly shortsighted view of things. The New NET type interface is probably very efficient for writing Web Pages. Some of us write Device Drivers. This is a job to be done, every time a new device is being put on the market. Challenge: Try to write a basic Device Driver in Managed Code! Come to it,99% of the OS (e.g Windows 7 or 8) is written in C or CPP. The remainder is written in assembler. What makes your Managed Code run, is ultimately the effort of C and C++ programmers. They have been extremely successful. So Successful in fact, that people like yourself who use those advanced interfaces end up thinking that CPP is Obsolete. To put facts straight:- When you write a piece of NET Code, your result is syntax checked, and, if it passes, compiled into 'Intermediate Code' The compiler that performs this feat, was written in C and CPP.( It would be Impossible to write this sort of compiler in a NET Language) Never mind NET Languges, the compilers for this are still written in C and C++. The RunTime, (that's when you see your code on a screen somewhere) equally attractsOS System based code, originaly written in CPP. In Short: The Crap you write in Managed Code, could never be displayed, if others had not written code in C or CPP, to actually display it!
Bram van Kampen
-
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.
Hi, Those things sometimes happen! C and CPP are Closest to the Hardware, Managed Code is closest to the Overal Concept. At the same time, Managed code requires Hard Wired Code to Run.
Bram van Kampen
-
I had some initial introduction to Basic in high school - way back in trash-80 (TRS-80) days. But my first and I feel MOST beneficial college class I EVER took was programming logic with pseudo-code and flow charting. After that my first language was C then later C++. If I had tried to learn C++ first I'm not sure I would have understood what was actually happening. When I'm writing code I want to make sure I understand what exact is happening. There is a lot in C++ that was much easier to learn knowing the basic C language.
spotsknight wrote:
If I had tried to learn C++ first I'm not sure I would have understood what was actually happening.
Exactly, it needs to be learned in layers. Students should have a firm grasp of the fundementals before advancing to OOP and such.
-
It's interesting that you mention "assembly". The very history of C as a programming language speaks loudly. Long ago and long ago (as the Native Americans would say), Bell Laboratories purchased a DEC PDP-7 computer. That machine was quite primitive, more or less a "minimal" computer. It had either 4k or 8k memory of 18 bit words, 16 op-codes, no multiply or divide instructions, no index registers, and primitive indirect addressing. It did have a set of memory locations that were "auto-increment" that simulated very primitive index registers, but were not terribly useful over all. The principle I/O were paper tape and a model 33 teletype. In fact, a bare-bones PDP-7 only had a teletype, in which case it would have been a model 35 ASR, which had paper tape read and write included. VERY slow! Bell Labs wrote a language called BPL (for Bell Programming Language, I think) which they used as an alternative to the assembly language supplied by DEC. I've never seen any details on BPL. However, Bell Labs used BPL to write a FORTRAN compiler for the PDP-7, as odd at that might sound. When DEC came out with the PDP-11, Bell Labs bought one and jumped on it like a duck on a June bug! They wrote a translator that converted the BPL translator (probably other programs as well) to run on the PDP-11. Using the translated BPL, they developed a new language, C. From rags to riches in terms of machine language capability, the C designers included features in the language to utilize many of the newly available features of the PDP-11. In particular, the auto-increment/decrement and to-memory instruction modifiers were incorporated in the ++/--/+=/-= operators. The indirection modifiers gave rise to the pointer operators. The above information I learned from a Bell Labs programmer/developer at at DECUS (Digital Equipment Computer User's Society) meeting. He was one of the original creators of C, but unfortunately I forget his name. He told me that when they developed C, they had in mind a "portable assembler" that would allow them to port code to any architecture by merely writing a translator for C for that new machine. Good C programmers, he said, visualized assembly code as they wrote in C. For anyone interested, here is a link to the PDP-11 "card": [^] Given the .NET availability these days, it ma
Hi Mr. Ranshaw, very informative thanks. "He told me that when they developed C, they had in mind a "portable assembler" that would allow them to port code to any architecture by merely writing a translator for C for that new machine. Good C programmers, he said, visualized assembly code as they wrote in C." Yes, yes but they failed [well partially they succeeded] to achieve this nifty goal.
Get down get down get down get it on show love and give it up What are you waiting on?
-
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.
Hi Maximilien, >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. Yes this is the bad side of going down to hell, in order to forge a high quality blade you need hellish heath, you know. >Are there reasons for beginner programmers to be taught C instead of C++? Pretty simple: when you treat a child as such you underestimate his/her potential by imposing your limits. If the beginner is afraid to enter deep waters (that is to evolve) it is better not to deal with C at all. >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. What about the old mantra 'data plus algorithms equals programs'? In my view it is absolutely mandatory to know the basics of algorithms, as for the programming languages they come as a natural 'NEXT-STEP'.
Get down get down get down get it on show love and give it up What are you waiting on?
-
Hi Mr. Ranshaw, very informative thanks. "He told me that when they developed C, they had in mind a "portable assembler" that would allow them to port code to any architecture by merely writing a translator for C for that new machine. Good C programmers, he said, visualized assembly code as they wrote in C." Yes, yes but they failed [well partially they succeeded] to achieve this nifty goal.
Get down get down get down get it on show love and give it up What are you waiting on?
"... but they failed [well partially they succeeded] to achieve this nifty goal." In what way did they fail to achieve that goal? More of the history is that Bell Labs developed an operating system for the PDP-7 (for what there was none previously). After they got C running on the PDP-11, they used C to write a translator from BPL (ie, their compiler for the PDP-7). Using that BPL -> C translator, they ported their operating system onto the PDP-11. Of course they had to write assembly code to handle the various low-level drivers. It was that port of their PDP-7 operating system that grew into UNIX(TM). By the way, "UNIX" means "UNIversal eXecutive" according to the Bell Labs guy I talked to. Also witness the various ports of UNIX to a plethora of platforms, all using (as far as I know) some manifestation of C. For example, LINUX and BSD.