Best free sites for learning how to write code

These four sites offer step-by-step tutorials that take very different approaches to programming instruction. One of them is perfect for your level of coding experience.

Dennis O'Reilly/CNET

Not so long ago, typing was for secretaries, journalists, and would-be authors. Now we're all tapping away at keyboards and screens from morning until night.

The number of people who spend their workday coding continues to soar. In the not-too-distant future, writing code may be as commonplace as typing and other forms of text-keying are today.

Learning how to code has never been easier. Whether you're a programming newbie or an old hand looking to learn a new skill or two, these four free services have you covered. (Note that all but W3Schools.com requires that you register to use the service by providing an e-mail address and password.)

All four of the coding tutorials I tested have their positive attributes (ahem), but my favorite is LearnStreet's Ruby for Beginners, which was just my speed. The lessons prompt you to write and run the code for each step, and when you make a mistake -- which is key to learning how to program -- the correction hints are clear.

The video lessons in Khan Academy's Programming curriculum keep you engaged in the subject and are perfect for folks starting at square one. However, the complete program could easily take weeks to complete.

I made it through 24 percent of the Codecademy's Ruby tutorial before I hit a lesson that stopped me in my tracks: in the loops section, of course. If you've done a little coding in the past, you'll likely have better luck than I did with Codecademy's write-it-yourself approach.

The simplest of the coding tutorials I tried was W3Schools.com's JavaScript tutorial, which you can complete without having to register (unlike the other three services). Each of its dozens of lessons includes plenty of "Try it yourself" options for practicing the technique the step covers.

LearnStreet puts the focus on the code
The first thing you notice when you start the lessons on LearnStreet is the prominent code-entry screen on the right side of the window. Under the code is the run environment that demonstrates the code you write. The instructions are listed on the left side of the screen.

LearnStreet Ruby tutorial: method definition
LearnStreet's Ruby tutorial prompts you with hints and answers when you make a mistake in its coding exercises. Screenshot by Dennis O'Reilly/CNET

It took me about two hours to work my way through the first five lessons in LearnStreet's 12-lesson Ruby for Beginners. Once you finish the site's programming courses, you can turn your attention to the dozens of coding projects for JavaScript, Python, and Ruby. The projects can be sorted by level (beginner, intermediate, advanced) and by category (tools, games, and algorithms).

LearnStreet also offers free courseware for teachers who want to instruct their students in coding.

Khan Academy lays a solid programming foundation
The Khan Academy is famous for its ground-breaking video tutorials covering nearly every subject a student is likely to encounter. Rather than focus on a particular programming language, the Khan Academy's programming module uses JavaScript to illustrate concepts that apply to coding in general while also teaching some practical JavaScript skills.

The courses are divided into about a dozen categories, each of which has from three to 12 separate lessons. Each video lesson animates the coding technique in a window on the left and shows the result of the code running in a window on the right.

After you watch the coding in action, you're challenged to write code that duplicates the operation. When your code isn't quite right, the tutorial provides hints to help you spot and correct the problem.

Khan Academy programming tutorial
After the coding technique is demonstrated in a video, you're challenged to write code that executes the technique. Screenshot by Dennis O'Reilly/CNET

It's easy to navigate the Khan Academy lessons and jump between them and the site's other features. A space is provided for creating your own programs, which you can save in your profile and share with the world. You can also browse the programs written by other students.

Like LearnStreet, teachers can sign up to be "coaches" for their students and manage their students' progress. You can monitor your own progress and set goals for yourself in your dashboard, which prominently displays the badges you've won and your "energy points."

Expand your programming horizons with Codecademy
As much as I appreciate Codecademy's polished interface and interactive tutorials, more than once I was stymied by the lack of help when the code I wrote failed to execute as expected.

Admittedly, my programming experience is limited to HTML and JavaScript. The lessons in Codecademy's Ruby tutorial had me backing up and restarting several individual steps, even with the hints that the lessons offer to us tyro programmers when something's not running as expected.

Most of the Codecademy lesson screen is taken up by the window in which you enter code. The instructions for the step are in the left pane. After you enter your code and click the Save & Submit Code button, the code runs in a pop-up window on the right side of the screen.

Codecademy Ruby tutorial: loops and iterators
The code window is prominent in the Codecademy's Ruby tutorial. The hints for correcting your coding mistakes aren't always as helpful as they could be. Screenshot by Dennis O'Reilly/CNET

I was making fairly good progress through the Ruby tutorial until I reached the Loops & Iterators module. When I took a class years ago in C++ I recall struggling through the same subject. After about a half-dozen attempts, I threw in the towel. (As with most tutorials, you can't proceed to the next module until you complete the current one successfully.)

Keeping it simple pays off for W3Schools.com
At first glance, the JavaScript tutorial on W3Schools.com looked too basic to be useful. After I had stepped through the first half-dozen lessons, I found the pace of the lessons kept me interested without overwhelming me.

The site offers tutorials in HTML, CSS, XML, SQL, PHP, JQuery, and other Web technologies in addition to JavaScript. There are also demos for building a Web site, server technologies, and Web databases.

The lessons are at a slower pace than those of the other three tutorials I tried, and they entail lots of scrolling down the page. You read the instructions and are then shown the code. Click the Try It Yourself button to open a new browser window that lets you write and run the lesson's code.

W3Schools.com JavaScript tutorial: manipulating HTML elements
W3Schools.com's JavaScript tutorial explains the coding technique, presents the code, and then lets you duplicate the code in a run environment. Screenshot by Dennis O'Reilly/CNET

The Basic section of W3Schools.com's JavaScript tutorial has 19 separate lessons, each of which will take most people 15 minutes to a half hour to complete. There are eight more Advanced lessons, as well as eight to 12 lessons for HTML DOM and Browser BOM. Another dozen or so modules provide libraries, examples, and references.

What a difference an hour makes
This is Computer Science Education Week, and Code.org is honoring the occasion by sponsoring the Hour of Code program that encourages teachers to spend an hour teaching their students how to code. (My certificate of completion is shown at the top of this post.)

The Computer Science Education Week site has tutorials that let students as young as 6 years old write their first program in an Angry Birds-like environment. The site also has the Khan Academy's Introduction to JavaScript intended for students in middle school and up, in addition to other app-development resources for students of all ages, many of which are designed to be used offline.

About the author

    Dennis O'Reilly began writing about workplace technology as an editor for Ziff-Davis' Computer Select, back when CDs were new-fangled, and IBM's PC XT was wowing the crowds at Comdex. He spent more than seven years running PC World's award-winning Here's How section, beginning in 2000. O'Reilly has written about everything from web search to PC security to Microsoft Excel customizations. Along with designing, building, and managing several different web sites, Dennis created the Travel Reference Library, a database of travel guidebook reviews that was converted to the web in 1996 and operated through 2000.

     

    Join the discussion

    Conversation powered by Livefyre

    Don't Miss
    Hot Products
    Trending on CNET

    TechProbe Volunteers Wanted: Huawei Mate 7

    Your chance to test drive and keep the Huawei Mate 7 phone

    Tell us about the technology you're using right now, and how a smartphone could help you in your professional life.