Many people post on Forrst stating that they want to learn a language, and I'm beginning to tire of seeing the repetitiveness of the posts, and the repetition of the answers. So, here is how I have learnt to code.
If you have learnt to code in another way, please post it as a comment. I will then link to it from the main post so that in future cases when people are wondering how to learn to code, this can be used as a reference point that will help anyone and everyone choose the best way that suits them. Also, at the bottom, there will be a list of links that I find are more useful that others, and some that should be taken with a pinch of salt. I am happy to add extras etc...
How did I learn?
The best method of learning is doing, the old saying of practice makes perfect could not be more true. Of course, you have to have a certain mindset to even consider the possibility of learning through practice.
If you're the type of person that will give up when they get an error, or who thinks they are about as thick as the mould on a 25 year old piece of bread, then ignore this method. If you think you're pretty intuitive, and have the perseverance to fight through your problems, and solve them. You will become a good programmer, but not just that, you will become a bloody good debugger. Ultimately trial and error is what this method is, take code, break the code, fix the code, pat self on back!
How do I practice to become perfect when I know nothing?
I understand where you're coming from, you need to start basic, you need to work your way up to the task that you want to finally make. I gave the same advice to a rather reluctant @justinsherrard on Twitter, he has followed me for many months/years and has had an interest in learning PHP, but hadn't got round to it.
He started a while back making a member system - you register, you login, you have a profile (I think!). Simple, nothing complex, or hard to the seasoned programmer. But to a new guy, this opens up a HUGE array of tasks... in brief:
How do I interact with a database?
How do I make a database with PHPMyAdmin?
How do I handle a form posting?
How do I even consider storing a password?
How can I log someone in, and keep them loggedin?
The list goes on - but what you have on that list there is the barebones of what you will use day in & day out with PHP - all wrapped into a nice project. After he had got that running & 'working' to a point he was happy with, he moved on to a very ambitious forum system. Not trying to be the next huge board provider or anything, but to learn!
So how do you start if you actually don't know anything? You use something called time, you use something called, the internet, and you look things up. You type into Google 'handle form post with php' and read the sites that popup - you read what people have put and play with their code.
If you're coming at a language with no prior coding knowledge, it's worth following a brief tutorial on a website such as Tizag. It will guide you through the basic syntax, and usage. I would advise that you read through it with your project in mind.
I have never done a tutorial that a site has offered - ever - I have taken my project, read what code was provided at a tutorial and editted it to match etc.
I have no idea what to do for a small project to learn!
Well if you have no idea, then you need to think of something simple, it could be something like a calculator, or just something in jQuery that will enhance picture display. Or you might want to try some fun with the language, and perhaps solve some of the Euler Project questions that exist, that or try to solve FizzBuzz in a stupidly short number of characters.
Other ideas could be:
Display twitter stream [any language]
Create some crazy Forrst Stats page with the Forrst API.
User management system
Client interaction system
Poll system (allow create/edit polls & people to vote etc)
Image hosting site*
many many more.
I used an image hosting site as my first project, it started off very basic with PHP when I was learning. It soon escalated to a site that was pulling in just over 1TB of traffic a month, and about 13million hits. I incidentally closed it down due to my inability to fund it - it is back in the pipeline for re-release.
So how do you learn? Take something you want to make (not something stupidly complicated, something stupidly basic!), make it. Then build it up. Use some of the sites that are mentioned throughout & at the end of the post for help & guidance. Don't give up either, just because you can't do it, doesn't mean it's impossible.
I'll suggest 3 little things to do throughout your learning experience:
Post your code for review
If you are new to coding & haven't written much in a language before, post on Forrst - state that you haven't done the language before and would like some tips on whether the methods/syntax you are using is best. If it's a language I know, I'll happily jump in & write you a lengthy comment explaining stuff etc.
Read other people's code
If you find a code post here on Forrst in a language you're wanting to learn, go read the code, if you don't understand what stuff does, post saying so. Forrst is here to be used & abused, and to be quite honest, as a beginner you should be hugged, loved, cuddled, stroked and guided through anything that you need help with. If people flame you for asking a stupid question - just flag their comment.
ASK FOR HELP!
I've rambled a bit, and will probably refactor most of this message, but the message is there, determination will get you through. I will leave you with one quote that I love, I can't remember the source but hey ho:
He who asks now is a fool for 5 minutes, he who doesn't ask is a fool forever
PHP.net - official documentation site for the PHP Language
jQuery Docs - jQuery documentation
http://www.w3schools.com/ - Please take this site with a pinch of salt, it is not always accurate, but is helpful for basics.
Google - if in doubt, google your question
My Twitter Account - *I am always happy to answer any coding questions over Twitter - if it's a complex question, I'll normally throw you my Skype or email! *
Feel free to post any questions, corrections or additions. I apologise that it seems as if the post has been tailored more towards PHP, the basics remain for any programming language.
Last Updated: 23rd Aug 2011 @ 00:04