Learn Fast C Programming: Answers to Beginner Questions

  • Thread starter Thread starter waternohitter
  • Start date Start date
  • Tags Tags
    Beginner
AI Thread Summary
Learning C programming can be approached quickly by engaging in hands-on coding rather than solely reading theory. While some believe that mastering C is essential before transitioning to C++, others argue that C++ can be learned independently, as it incorporates features beyond C. The discussion highlights that C and C++ serve different purposes, with C being more aligned with low-level programming and understanding computer operations. Many experienced programmers recommend starting with C to grasp sequential programming concepts, which can aid in debugging and understanding how computers function. However, the necessity of learning C first is debated, as modern C++ resources often do not require prior knowledge of C. The conversation also touches on the efficiency of programming, emphasizing that while C allows for low-level optimization, the efficiency of code should be balanced with programmer productivity, especially in object-oriented programming contexts.
waternohitter
Messages
52
Reaction score
44
How to learn fast C?
-
Is C really needed to be learned before C++ programming?
-
Are there any fast methods in learning C programming?
-Please, answer this! Other sites are confusing and too complicated to understand. If you have any ideas or your own understanding please comment down below!

Thanks for reading! Stay safe!
 
  • Like
Likes jtbell
Technology news on Phys.org
I came out of college with older languages under my belt (PL/C, Watfor Fortran, various assembly), and was Handed a K&R C book in my first professional job and told to learn it by Monday. I did and was productive by Monday.

If you find 'other sites' confusing and complicated, maybe it won't work that fast. What are you expecting here, a tutorial? Fastest method to learn is to write programs and get them running, right from the first minutes. Don't just read about it.

No, you can go straight to C++. Learning C first sometimes forms bad habits, kind of like learning Basic before Pascal.
 
  • Like
Likes Klystron and jedishrfu
Most folks learn C via books written about C.

I used the original Kernighan and Ritchie book.

https://en.wikipedia.org/wiki/The_C_Programming_Language

Its true that while C++ is a superset of C, it would be wrong to use C idiomatic programming in C++ because it will not always coincide with the best practices of C++.

As an aside, the Go programming language from Google is basically C reimagined for the programming paradigms of today.

There is even a Kernighan book on programming Go that is written in a similar style to K and R. Also many of the early proponents of C programming from Bell labs have become founding fathers of Go.

So if you want to skip forward into a brave new world then check out Go by searching for “golang” online.

One such site is:

www.gobyexample.com
 
Last edited:
waternohitter said:
How to learn fast C?
I assume this is a garbled form of "how to learn C quickly", unless "fast C" is a language I've never heard of.

Halc may have "learned it by Monday" but he had a strong base and I seriously doubt he learned all the features fully over one weekend. If you are in a big hurry, you most likely have the wrong motivation. It's not a good idea. Learn it WELL instead.

Like the previous two posters, I too learned it from the White Book and recommend it. I still have 2 copies on my shelf even though I haven't used C in probably 20 years.
 
  • Like
Likes Klystron
waternohitter said:
Is C really needed to be learned before C++ programming?
C and C++ are entirely different beasts. C++ has syntax that is based on C but it's a whole different world. You CAN learn it first but personally I think that's a terrible idea.
 
  • Like
Likes Filip Larsen
waternohitter said:
Is C really needed to be learned before C++ programming?
No. There are a number of books that teach C++ without assuming any previous knowledge of C. I taught an introductory programming course using C++, from about 25 years ago to about 15 years ago. It assumed no previous knowledge of C. It didn't start out with C and then switch to C++. It used stuff from the beginning that existed/exists in C++ but not in C.

I think many older programmers tend to think that you need to learn C before learning C++ because they think of C++ as being basically C with object-oriented stuff tacked onto it. That has not been true at least since the first C++ standard was published in 1998, before most current college/university students were even born. :wideeyed:
 
Last edited:
jtbell said:
I think many older programmers tend to think that you need to learn C before learning C++ because they think of C++ as being basically C with object-oriented stuff tacked onto it.
Personally, I think that point of view is irrelevant. My point is that if you don't learn sequential programming before OOP you'll have no idea how computers actually work and a lot of trouble debugging when things go wrong. OOP doesn't program the computer, it programs this big fat pillow that's between the programmer and the comptuer. C is a great way to both learn sequential programming and to learn a bit about how computers work.
 
  • Like
Likes Halc
phinds said:
C is a great way to both learn sequential programming and to learn a bit about how computers work.
Huh? Assembly language is the only way to learn how they work.
 
anorlunda said:
Huh? Assembly language is the only way to learn how they work.
Yes, assembly is far better than C, but C is better (closer to the machine) than any other high level language and I think assembly is a step too far for today's programmers (although personally, I recommend it). OOP is REALLY far from the machine.
 
  • #10
phinds said:
Halc may have "learned it by Monday" but he had a strong base and I seriously doubt he learned all the features fully over one weekend.
I said productive, not proficient, so yes. There's always more to learn.

I've programmed in C++ for 17 years and I realize on this forum that I look like a noob still. I have no experience with any standard libraries. I've never used IO streams, since they're not thread-safe. I'd make a terrible tutor for intro C++ work.

phinds said:
My point is that if you don't learn sequential programming before OOP you'll have no idea how computers actually work and a lot of trouble debugging when things go wrong. OOP doesn't program the computer, it programs this big fat pillow that's between the programmer and the comptuer. C is a great way to both learn sequential programming and to learn a bit about how computers work.
Totally agree with this. I pride myself in writing efficient code, and I find that C++ often hampers that. I'm thinking of caution taken when creating a structure that goes onto disk, where it cannot have any pointers, so it cannot have virtual member functions or anything. Constructors and such potentially consume an unintuitive amount of CPU compared to C structures.
 
  • #11
Halc said:
Totally agree with this. I pride myself in writing efficient code, and I find that C++ often hampers that.
Well, the kind of low-level efficiency that C is so great at is mostly beside the point w/ OOP and OOP IS efficient for some types of programming, particularly now that computers are SO fast and programmer time is still expensive. You can do things with OOP that would be awkward at best w/ purely sequential programming, and now that programming is mostly IDE-driven and things that happen are event-driven, OOP can be even more helpful since a lot of the OOP overhead is handled by the IDE.
 
  • #12
Halc said:
I'm thinking of caution taken when creating a structure that goes onto disk

In general, the issue of persistency is non-trivial, and OO makes it worse. Transient/persistent separation is maybe more work, but also a good idea.

The usual "quick and dirty" method of writing out the contents of an object easily runs into trouble. Think about a class called Circle: if you write out "radius" and "diameter" separately, you run the risk of doing that inconsistently.
 
  • #13
phinds said:
My point is that if you don't learn sequential programming before OOP you'll have no idea how computers actually work and a lot of trouble debugging when things go wrong.
When I taught my C++ course, I didn't start on object-oriented programming (designing and implementing one's own new classes i.e. object types) until the second semester of a two-semester sequence.

Up till that point, the major differences between my course and a C course were:
  • Input/output using iostreams (cout, cin, the >> and << operators, file streams) instead of C-style I/O (printf(), scanf(), file pointers, etc.).
  • Text data (character strings) using the standard string data type (class) instead of C-style null-terminated char arrays.
  • Collections of data (of the same type) using the standard vector data type (class) instead of C-style arrays.
For these, students needed to learn how to use previously-defined object types (classes), e.g. for strings, myName.length() instead of strlen (myName); or myArray.size() for vectors instead of ... um, what? :wink: for C-style arrays.

I considered it important to be able to use this stuff before learning how to create it. I applied the same philosophy to plain old functions. I had them use functions from the standard library, and functions that I had alresady written, before having them write their own functions.

I agree that even in these situations, compiler error messages could be rather intimidating. This was not only because of using classes, but also because of using templates, e.g. the vector class. I dealt with this by urging my students to write and compile programs incrementally (a few statements at a time), instead of trying to write the whole thing at once and throw it to the wolves, er, compiler. That would at least localize the mysterious error messages that they got. As they got better, they could of course increase the "number of statements at a time."

And of course, I was available to help them decipher the error messages that they got.
 
Last edited:
  • Like
Likes Mark44
  • #14
phinds said:
Well, the kind of low-level efficiency that C is so great at is mostly beside the point w/ OOP and OOP IS efficient for some types of programming, particularly now that computers are SO fast and programmer time is still expensive.

This is an important point. Programmer time is two or three orders of magnitude more expensive than computer time, yet that's not always how we act.
 
  • #15
anorlunda said:
Huh? Assembly language is the only way to learn how they work.
Well, having written microcode in my misspent youth...
 
  • #16
Nugatory said:
Well, having written microcode in my misspent youth...
Ah so. Microcoders are the true black belt holders. :bow:
 
  • #17
Vanadium 50 said:
This is an important point. Programmer time is two or three orders of magnitude more expensive than computer time, yet that's not always how we act.
Programming time might well be three orders of magnitude more expensive than computer time, but if the code segment runs 7 orders of magnitude more often than it is programmed, it is still pretty dang important that it be efficient, else the customer will buy a different product.

Yes, for run once quick and dirty jobs, ease of OOP programming often will outweigh the extra CPU needed due to lax attention to efficient algorithms and implementations. I'm just saying that it isn't always the case. In what I worked on (network file servers), there are very performance critical parts of the program which get brutally scrutinized for efficiency, and then there are other parts of the same software where getting it working quickly and reliably far outweighs the resources consumed by the task.
 
  • Like
Likes PeterDonis
  • #18
I really appreciated your advice. Let me write it on my guidebook as my reminders! Thank you for spending your time on my post.
 
Back
Top