Learning to program in C.
I've been telling myself I'm going to start learning C for a while now. I finally got around to reading some e-books I downloaded the other day. (K&R, and some other one called Learning GNU C.)
I have a question for those programmers out there, not just people who program in C, but others as well.
I'm not sure how to explain it, but I'll try my best. When I started reading the books, and doing tutorials in them, I soon realised that these books are going to teach me "how" to program, but not necessarily how to program well, and efficiently, if you know what I mean. Just teaching the bare minimum and the basics.
What have the programmers here done to become as good as you are, after reading these books?
I know that in addition to reading them, looking and playing around with other programmers' codes helps much when you're still learning.
What else have you all done to help yourselves become better programmers?
I hope my question and problem made sense, I wasn't exactly sure how to explain it. :angry:
You won't become a good programmer by just reading and doing tutorials, although it's a good way to start. Later on you will learn by trial and errors.
A tip is that you not just read a specific language but also read code structuring and read others code. I wrote code and then looked up others that gave similar results, that made me think more and widened my perspective.
cpu-junkie wrote: You won't become a good programmer by just reading and doing tutorials, although it's a good way to start. Later on you will learn by trial and errors.
A tip is that you not just read a specific language but also read code structuring and read others code. I wrote code and then looked up others that gave similar results, that made me think more and widened my perspective.
Structuring code, that's when you split up your code into several different files, right? The Learning GNU C books said stuff about that, where they broke up the program and had a few files which called upon functions from another file, and it was compiled into one program.
I've read some other peoples' codes, and found them quite helpful in giving me ideas on how to do things, and how to improve my own code.
A common misconception is that learning a programming language will teach you how to program. A book about programming in C will only teach you how to program in C, not how the logic and functionality behind programming operates itself. It may seem contradictory, but the logic behind data manipulation and structured programming languages is completely up to the intelligence level of the user. A good way to speed up the pace of comprehension until that point of enlightenment is to learn how a computer works in its entirety - not just how it intereprets a language, but how it stores and operates memory, how it interacts with the real world, and how it may be manipulated.
A good way to do this is learning Unix. Another may be to take classes. Alternatively, hack.
Night_Stalker wrote: Structuring code, that's when you split up your code into several different files, right? Encapsulating parts of your program into separate files that can, in turn, be called by other programs won't really make learning to program any easier. It will, however, make your code cleaner and easier to read/use which will, in the long run, make you a thousand times more proficient. Not to mention a godsend when you start working on larger projects with other people.
Comments, too, tend to be extremely useful while often wholly overlooked. When you come back to your program later to try and figure out what the hell you were thinking. (And trust me- if you continue learning your language of choice for a while before returning to your first(ish) programs, you will wonder what the hell you were thinking)
I've read some other peoples' codes, and found them quite helpful in giving me ideas on how to do things, and how to improve my own code. This is always a good idea, however you must do so in moderation and only if you're absolutely sure you want to ruin the fun. When I learned Python, I spent a lot of time reading other code and then easily replicating it- making me feel like a professional. However, when I went to actually do anything on my own, I felt lost and ended up floundering around for hours feeling like an idiot.
But here's the deal- that floundering around taught me way more than reading other people's stuff (at first). You need that initial "what the fuck am I doing?" to push you to start thinking like a programmer would. Once your in that mindset, there's nothing wrong with looking over other stuff to see how to improve what you have. But make sure you have something first. And, if you do look over someone else's work, make sure you understand exactly what they're doing and why they're doing it.
Moral of the story? Reading code is easy. Writing code is easy. Actually figuring out what you want your code to do, though? That shit is rough. And rough is good.
Good luck.
(Note: Neither reading nor writing code is easy. I'm a liar.)
Futility wrote: But here's the deal- that floundering around taught me way more than reading other people's stuff (at first). You need that initial "what the fuck am I doing?" to push you to start thinking like a programmer would. Once your in that mindset, there's nothing wrong with looking over other stuff to see how to improve what you have. But make sure you have something first. And, if you do look over someone else's work, make sure you understand exactly what they're doing and why they're doing it.
Futility has a great point. OP, you are exactly right, the book does seem to just teach you the basics of the language. It gives you enough to get started, and once you have that all you need to do is code what you can and learn from it. You'll have a rough start, but you'll quickly get better as you code more and more. The things the book doesn't teach you can be taught to you by google when you hit a dead end (and you certainly will), and the techniques it doesn't cover you will learn from your own mistakes.
All you have to do is just code. You'll suck at first, but you'll learn from it ;)
Futility wrote: Comments, too, tend to be extremely useful while often wholly overlooked but dont overdo it lol ive seen people who comment evry line in their code and dont just look at others codes after writing your own talk to others and share code ask what people better than you think of what youve written and what they would change and why dont be afraid to learn from those who have the nowledge to give. dont be afraid to ask and disguss hope this helps :3
Thanks for all of the replies and advice, everyone. I think it'll all help me out with learning to program lots. :3
Now I just have to find a solution my biggest problem with learning to program, and with much else I'm interested in learning: staying focused on just one thing at a time, so I can be more productive when it comes to learning it. >_<
this might go down as hijacking this thread …
but, just for arguments sake, suppose that I use a GOTO command to go to a certain line, in the code , is their an method which can help me determine the place from where i jumped… e.g.
#include<iostream.h>
void main()
{
int a=1;
cde: cout<<"meow";
//ohshumaka
abc: cout<<"grrrr";
cout<<"boo..";
if(a==0)
{
goto abc;
}
else
{
goto cde;
}
}
so , here i will land up in the else block , so after i go to cde, i will be at ohshumaka, so is there many method by which at this step i will be able to determine which goto was used….
very similar to functions i would say :)
tuere816 wrote: this might go down as hijacking this thread …
but, just for arguments sake, suppose that I use a GOTO command to go to a certain line, in the code , is their an method which can help me determine the place from where i jumped… e.g.
#include<iostream.h>
void main()
{
int a=1;
cde: cout<<"meow";
//ohshumaka
abc: cout<<"grrrr";
cout<<"boo..";
if(a==0)
{
goto abc;
}
else
{
goto cde;
}
}
so , here i will land up in the else block , so after i go to cde, i will be at ohshumaka, so is there many method by which at this step i will be able to determine which goto was used….
very similar to functions i would say :)
Yeah, it's called a debugger. Learn to use GDB.
OR if you mean IN your code, you could set a new boolean value and update it with each goto.