Experience by definition means “doing”. This is the difference between book smarts and street smarts.
Gain experience by learning(studying) or by doing?
There are times for each. Generally you want to make well-structured code, but frankly where can I say the balance lies?
Is it better to have well structured code that takes 5 hours in time to make, than have spagetti code that takes 30 mins to pump out?
If you are a very beginner on your own project there is no reason not to pump out quick-but-crap code.
Yet companies prefer structure.
To be quite frank the only way you can truly understand this dynamic balance is by doing both and learning their impacts on your code quality vs. getting results done. In fact you will need to learn the difference between them on your own personal level anyway in order to give accurate estimates to your future employer.
It is a crime to do either one of them in certain situations, so as long as you are a beginner and on your own, why not try them both so that you can get a feel for the dynamics behind them?
This is a false question.
Is it better to become well versed in a particular(or broad) area of study, and then go in and tackle a project, or just learn as you go?
You never dive into the deep-end until you have a little background. In fact you simply can’t.
Firstly, you need to be versed in a subject to some degree before you dive.
The point at which you dive marks the balance, and that is up to your learning ability. Everyone is different.
The way that works best for the person.
I'm wondering, what do YOU guys think are the best ways to learn how to code?
I guess you meant to ask how we each feel is our own best ways of learning.
For me that is a slight bit of reading on the subject followed by tons of hands-on and active doing.