• Question: How does coding work?

    Asked by 982smgd43 to Pete on 8 Nov 2015.
    • Photo: Peter Burgess

      Peter Burgess answered on 8 Nov 2015:


      Coding is just ‘giving a computer a list of instructions’.
      If you hit CTRL + U, you will get a window called the page source. That’s the code that you need to make this website.
      It will look like a right mess but basically you have a bunch of information at the top about the kind of web page you want (all the UTF-8 and so on). There’s a bunch of stuff that is fixed (like the ‘I’m a scientist’ logo in the top left) and a bunch of stuff where you can edit and add data (like the box where I’m typing this answer).
      The fixed stuff is written in http which is a special way of presenting information to a computer about what you want on your web page. THe editable stuff looks like it’s written in javascript (I can tell because it says javascript and jquery in a bunch of places.

      There are quite a few different codes which you can use to give computers instructions. I mostly use one called ‘R’. I’ve also used Python, and another called C++. A lot of things on your phone will be done using Java which is related to C(++).

      The reason you use code is because computers are really good at two things: doing sums really quickly, and doing them exactly the same way every time you want them done. I have to do lots of sums, a lot of times and it’s easier for me to tell a computer all the sums I want to do and ask it to do them for every solar power system I want them to run on every day/week/month.

      If you learned to code you could probably do your maths homework really fast. If you have the same kind of problem to do thirty times, you could write a little piece of code that says ‘take these numbers and do …’ and the computer would do a list of 30, or a list of 30,000 faster than you could ever do it.

      It doesn’t always make sense to write a piece of code to do your sums if you’re only going to need to do it say ten times, but if you are going to need to do the same thing hundreds, thousands or millions of times then getting a computer to do it is absolutely necessary. Computers don’t get bored, and their hand doesn’t start to hurt after a few pages of sums.

Comments