Learn Fast C Programming: Answers to Beginner Questions

  • Thread starter Thread starter waternohitter
  • Start date Start date
  • Tags Tags
    Beginner
Click For Summary

Discussion Overview

The discussion revolves around the best approaches to learning C programming, including whether it is necessary to learn C before transitioning to C++. Participants explore various methods, resources, and philosophies regarding programming education, particularly in the context of C and C++.

Discussion Character

  • Exploratory
  • Debate/contested
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Some participants suggest that writing programs immediately is the fastest way to learn C, rather than just reading about it.
  • Others argue that learning C is not a prerequisite for learning C++, citing books that teach C++ without prior knowledge of C.
  • There is a viewpoint that learning C first can lead to bad habits when transitioning to C++, as C and C++ have different programming paradigms.
  • Some participants emphasize the importance of understanding sequential programming before object-oriented programming (OOP) to grasp how computers work and to aid in debugging.
  • There are conflicting opinions on whether assembly language is necessary to understand how computers work, with some asserting that C is closer to the machine than other high-level languages.
  • Concerns are raised about the efficiency of C++ compared to C, particularly in low-level programming and resource management.
  • Participants discuss the complexities of object persistence in OOP and the potential pitfalls of writing object data to disk.

Areas of Agreement / Disagreement

Participants express a mix of opinions regarding the necessity of learning C before C++. While some believe it is essential for foundational understanding, others argue it is not required. The discussion remains unresolved with multiple competing views on the best approach to learning programming.

Contextual Notes

Some participants reference their personal experiences and educational backgrounds, which may influence their perspectives. There is also mention of differing pedagogical approaches in teaching programming languages.

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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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 (count, 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   Reactions: 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   Reactions: 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.
 

Similar threads

  • · Replies 25 ·
Replies
25
Views
1K
Replies
86
Views
3K
Replies
69
Views
11K
  • · Replies 133 ·
5
Replies
133
Views
12K
  • · Replies 43 ·
2
Replies
43
Views
7K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
16
Views
3K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 86 ·
3
Replies
86
Views
13K