How to code - year of code

There’s a strong demand for talented programmers right now and, since it’s the Year of Code, we show you how you can become an expert

Coding – or programming - is everywhere and in everything around us. All computers run code: it’s what makes them burst into life when the power is turned on and what makes things happen when an icon or menu is clicked.

Code isn’t just for PCs: smartphones wouldn’t be nearly as smart without code for the operating system and apps. Tablets require similar code, as do TV boxes from Sky, Virgin media and others. Websites are powered by code (see How to build a website), even cars rely on code these days; enthusiasts use this fact to boost an engine’s power by reprogramming it – there’s no need to even reach for the toolbox.

Learn to code - Tado thermostat

You can even control the heating in your home using a phone app and the phone (see Tado thermostat review), app and heating are all powered by code. Someone has to write it, couldn’t it be you?

With so many smart devices, gadgets and internet services all requiring code in order to function, there’s a demand for people that can code and a shortage of people that are really good at it. This is the reason why the Government announced that this is the Year of Code and it has provided £500,000 to train teachers to show children how to become programmers.

From September 2014 all children from the age of five will be taught to program. Education Secretary Michael Gove said “The new computing curriculum will give our children the skills they need to succeed in the 21st century.”

The scheme was set up with the best of intentions, but it quickly ran into problems and one of the scheme’s advisors, Emma Mulqueeny, quit after just one week. Its launch was a PR disaster and there were many critical stories in the news (BBC and Guardian to mention just two). Jeremy Paxman quizzed Year of Code director Lottie Dexter on Newsnight and she admitted that she and some of the other advisors couldn’t code:

The government has the right idea, though, and everyone should try coding. Not everyone will like it or need it, but a few will take to it like a duck to water and will become the expert coders that are needed. Do you have what it takes to become a coder? Why not try and see.

The Fizz-Buzz test

Coding is skill that takes a lot of hard work to master. If you think you can code already, try the Fizz-Buzz test: Write a program that prints the numbers 1 to 100, except for multiples of three print “Fizz” and for multiples of five print “Buzz”. If you’re good, you’ll have a finished and working program in under five minutes. Start Notepad and create a web page that prints Fizz-Buzz using JavaScript. The answer is at the end of the article on the next page - no cheating!

Introducing programming to children at school is essential if we are to fill the demand for skilled programmers in the future and the earlier you start programming, the better you will be. Five-year-olds won’t be looking for jobs for another 15 years though, so who’s going to do the coding in the meantime? Could it be you?

Learn to code: Which programming language?

There are many computer programming languages and although some are similar, many are quite different. Some languages are only used in certain niches and these are fairly easy to spot and to avoid. You don’t see many programmers using Lisp, Forth, Prolog, Smalltalk or Fortran these days. Learning them is pointless unless you are looking for a job in a niche that still uses them.

Programming languages can become popular for a while and then disappear. Pascal was once popular, but isn’t used much these days. The only people using BBC Basic, Sinclair Basic, Z80 and 6502 machine code are people writing retro games for Sinclair Spectrum and BBC emulators.

You should learn the most popular programming languages, but you must be aware that what is popular this year might not be next year. Programmers frequently have to learn to program all over again when some new language takes off. Earlier this year Facebook announced it had created its own programming language called Hack because other languages could not cope with its billion members. If you want to work as a developer for Facebook you need therefore need to learn Hack.

So which language should you learn? The best way to discover which languages are the most used is to look at job adverts. Job sites have large numbers of listings and the most commonly requested skills are for C++, C#, .Net/VB.Net, Java, PHP, and web technologies like JavaScript, HTML, SQL, Asp.Net and others. Most jobs require knowledge of several programming languages and knowing just one won’t cut it. Many job adverts are aimed at computer science graduates with degrees and this is typical: “Graduate / Junior Software Developer - C# / ASP.Net / MVC / SQL Server / Degree.”

Learn to code: Programming for fun

You don’t need to be a computer science graduate to become a programmer and not everyone wants to do it as a full time career. Learning to program can be fun and for some people it can simply be a hobby. It can also be useful too and you might find yourself needing to tweak a web page or add some functionality to a site, such as adding PayPal buttons so people can buy goods. A little knowledge of how to code for the web can make it a lot easier to build a website. You don’t need to know how to build complete Windows applications and simply recognising a few key commands and functions can provide sufficient knowledge to tweak someone else’s code, such as a WordPress template. Although a site can be built by pointing and clicking, knowing how and where to paste in the code for a PayPal button in the HTML or PHP of a web page is really useful.

Occasionally apps for mobile phones are created by a single programmer working on their own on their home computer. Flappy Bird, the most downloaded app for the iPhone in January, was created by Nguyen Ha Dong in just a few days. It was rumoured to be earning $50,000 a day in advertising revenue but even a quarter of this would be very nice.

Learn to code - Flappy Bird

See how easy it is to create a playable Flappy Bird clone at code.org

Learn to code: online tools which teach kids (and you) how to program

Coding with the languages and tools that professionals use is hard because you need to know a lot before you can do anything, even just displaying the classic greeting, ‘Hello world’, on the screen.

Avoid pro tools at first and go to sites like code.org, which teaches coding to US schools. There is a great Hour of Code link on the home page which everyone that wants to be a programmer should try. There are 20 lessons and before each one is an inspirational video by Bill Gates, Mark Zuckerberg and other celebs. Each lesson involves moving a character through a maze to reach a destination. Programming statements are on jigsaw-like puzzle pieces that you drag and drop to snap together. Join the pieces in the right order and it makes a program that you can run and watch.

code.org Learn to code

Try the Hour of Code and become a programmer in 60 minutes!

It is simple, graphical and entertaining for all ages. After your first hour of code, you can try some of the other tutorials, such as An Introduction to JavaScript, My Robotic Friends, A Taste of Python Programming, and Build Your Own iPhone Game. Everything takes place in a web browser window and nothing extra is needed. It’s a great website.

  

There are many similar tutorials using the Hour of Code drag and drop puzzle pieces method and you can create a modern Flappy Bird clone, or go back to gaming roots and recreate Pong.

         

Real programming is a lot harder than dragging and dropping the puzzle pieces and the next step to becoming a programmer is to try some of the Codeacademy tutorials. It is still browser-based, but is more realistic and there is a choice of HTML/CSS, JavaScript, PHP, Python and others. These are all popular web technologies and are useful to learn. Each lesson has many parts and on the left of the screen are instructions and help, in the middle is a text editor for entering code, and on the right is the output area. This is closer to real programming.

         

There are other websites that take a similar approach and learn-c.org, learnpython.org, learnjavaonline.org, learn-php.org, and learncs.org all have useful tutorials. There is explanatory text and at the bottom of each web page is a code window and output window. You can click buttons in the tutorials to view the code, then you can edit it on the page, and finally run it and see the output.

         

Basic was a popular programming language on home computers like the Sinclair Spectrum and BBC Micro in the 1980s and lots of old programmers started on those. Basic isn’t used these days, but the language was invented for teaching programming and so is very simple. Quite Basic lets you write and run Basic programs in a browser window. There are example programs including the Mandelbrot Set, a recursive Towers of Hanoi solution, Bubble Sort and more.

Learn to code - Basic

Basic reads almost like English, making it easy for beginners

Learn to code: Beyond the basics

There is nothing harder than sitting in front of a real programmer’s IDE (integrated development environment) and creating a program from scratch. Interlocking puzzle pieces and guided coding tutorials just aren’t the same.

If you want to really create software, a good place to start is with Microsoft Visual Studio. The Express editions are free and there is one version for creating web applications and services, one for creating Start screen apps for the Windows Store, and one for creating standard Windows desktop software. Many programming jobs require knowledge of the technologies used in Visual Studio.

Learn to code - Visual Studio

Follow the links to the developer’s section at the Java website and you can download a Java development kit that enables you to create Java software. Before tackling the real thing though, you should try Alice, Greenfoot and BlueJ. These are simplified Java development environments that have been designed to teach programming in a fun way to students. Java is designed to run everywhere so Alice, Greenfoot and BlueJ work on Windows, Mac and Linux.

Learn to code: A JavaScript solution to the Fizz-Buzz programming test

Learn to code - Fizz-Buzz solution