Get into coding in 8 steps
Daniel - Nov 06, 2007 - Tech CodeIf you've ever wanted to learn to write code, with no prior experience, now is the best time to do it. There are so many simple languages that are possible to learn from the ground up, picking up the basics of programming languages along the way, and improving your code as you learn new techniques. If you've ever wanted to write code to achieve something simple without downloading a program to do it, now's your chance.
In order to give the best examples I can, I'll be referencing Python and PHP - they're both simple and powerful, and they're how I initially started coding.
-
Choose something which interests you, or is useful to you
This is the best advice I can offer. Learning to do anything new is never the easiest of tasks, so having a theme which will keep you interested - and most importantly motivated - is crucial.
-
If you're interested in building websites and want to add more functionality and interactivity to your sites, try PHP.
-
If you've always wanted to write snippets of code to achieve various things more quickly in Windows or Linux - try Python.
-
If you're a fan of Valve's Source Games, Python was recently added to the Eventscripts mod - and it's incredibly simple to start writing addons for them. Want to turn Counterstrike Source into an Unreal Tournament style deathmatch? Now you can.
The great thing about programming languages is that you can apply them to almost anything - which means finding something you're willing to devote hours to completing is a lot simpler.
-
-
Learn the basics
Once you can grasp a few simple concepts, learning about languages becomes incredibly simple.
-
input/output - understand that the majority of programs will take the input from a user or another system, process it in some way, and display or manifest an output.
-
data types - in most languages data is sorted into types; these could be strings ("hello world", "this is a string") integers (1, 2, 3, etc) floats (3.145, 0.33) boolean values (True, False) - to name a few of the most common.
-
variables - names used to store data, in any of the types mentioned above. These are incredibly useful for juggling inputs, and storing anything you process before you output it.
-
functions - take inputs, give you outputs. You might have a function to turn a string from lowercase to UPPERCASE.
-
conditions - only running certain sections of code when certain conditions are met.
-
loops - running sections of code multiple times until the desired output can be obtained. It would be impossible - or impractical - to delve into the specifics of each of these concepts here - but if you can understand how each of the above might work, you're well on the way to understanding how to begin coding.
-
-
Read examples
Most of the time, what you are trying to do will have been done before. This makes life a lot easier, when you need an example of how something is done - a quick search in google will provide a wealth of code, which you can read over, hopefully understand, and base your own code on. Importantly, try out the examples you find. Even if you've only the loosest understanding of how it works, run it, change how it works, make it useful for what you want it to do.
-
Join a community
The best example I can come up with for this is, again, the Eventscripts community for Python mods on Source games - though with a bit of googling you're sure to find one which suits your individual needs. There's little better to help you along than a constant source of advice, a large group of peers who are either learning the same concepts you are, or are willing to read over your code and help you with it. Find a group you can release interesting and useful code to, and - contrary to the lone-coder stereotype - you'll have friends for life.
-
Find somewhere to release or post your work - show off
This ties in very closely with the last point. If you're ever in need of a morale boost, write some functioning code, post it up where people can see it and use it, and wait for the influx of requests, suggestions, bug reports, hate mail... you name it. One day, you'll come up with a really intuitive and useful program or piece of code, and people will love you for it. In an ideal world, this is what every good coder should strive for.
Accept criticism; what you're doing has been done over and over, and someone will always have a better way to do it than you.
-
Code, cod·ed, cod·ing
Fairly simple advice - but if there's something you've set out to do, do it. If you find you enjoy it, you'll have sleepless nights over logical problems, you'll worry about consistency, you'll curse syntax errors you can't find - and you'll be happy for it when it's all done. Writing code is more satisfying than writing literature, doing maths or watching television, because at the end of the day, when you finish up, you can actually see it work. Find an editor you like, preferably with a syntax highlighter for your chosen language, and make sure you can run or compile your code early and regularly. If you find something is impossible, better finding it before the rest of your code depends upon it working.
-
Where to start?
Finding the right place to start can be a nightmare. In my experience, if you want a fair and complete introduction to a language, the official documentation is a good place to start: read it, read it again, and if you don't understand all of it don't worry. While you're reading it, try all of the examples you can, and after that try something new. The more adventurous you are, the more you will pick up. Quite literally.
A few simple rules when writing in any language:
-
Make your code readable. If you can't understand what's going on in your own program a week or a day after you wrote it, even if it works, it's likely not written as cleanly as it should be. If those with more experience can't read it - even less so.
-
Comment your code. Label what sections do, what you might need to change - if you get into this habit early, you'll not regret it later, when you're reading through hundreds of lines of code rather than tens.
-
Write your code to be maintainable. When you can avoid repeating yourself, do so - try as little as possible to copy and paste sections of code you need twice.
-
-
Don't give up!
It's a cliché, sure, but learning to code - like anything - is fairly exponential. Once you're over the initial boundaries, things will click, you'll realise how much you're capable of, and you'll be able to learn ten times as much with the same amount of effort. Keep at it - and if you have any questions - within reason - post them here, and I'll do my best to respond. Apart from that - good luck! And if you're a more experienced coder than I am - which is completely likely - please correct any mistakes I've made above!

jordan widel
This is a great tutorial as i am trying to learn C++. You can read about it at my site http://www.questofacodingpawn.blogspot.com/
BlahBlah
If you're more of an MS guy then I can highly recommend the Visual C# Express program. Very good, free IDE for my favourite language.
jordan widel
hey i built my very own program you should try it out Oh i also brought the new domain name www.codersquest.com
Jason
Excellent post... very informative for those newbies.
Name