Debugging and Compiling Code

An error occurred trying to load this video.

Try refreshing the page, or contact customer support.

Coming up next: Business Application Software Flashcards

You're on a roll. Keep up the good work!

Take Quiz Watch Next Lesson
Your next lesson will play in 10 seconds
  • 0:06 Writing Code
  • 1:15 Testing and Debugging
  • 4:12 Machine Code vs. High-Level
  • 5:51 Compiler & Interpreter
  • 7:24 Compiled vs. Interpreted
  • 8:10 Lesson Summary
Save Save Save

Want to watch this again later?

Log in or sign up to add this lesson to a Custom Course.

Log in or Sign up

Speed Speed

Recommended Lessons and Courses for You

Lesson Transcript
Instructor: Paul Zandbergen

Paul has a PhD from the University of British Columbia and has taught Geographic Information Systems, statistics and computer programming for 15 years.

Programmers use an integrated development environment to assist in writing code in a specific programming language. Learn about some of the specific tasks performed by programmers, such as debugging and compiling code.

Writing Code

Computer code is essentially a list of instructions that can be run by a certain program. You can write code using a basic text editor, but it is much more efficient to use a software application that is specifically designed for this purpose. For example, when you write a document in plain English, you would use word processor software, which can assist you with things like formatting, spelling and grammar. Similarly, a code editor provides tools such as syntax checking. Syntax is to code what spelling and grammar are to written English.

A code editor is also called an integrated development environment, or IDE. An IDE is a software application for formatting your code and checking syntax, as well as running and testing your code. Below is an example of what a typical IDE looks like. This may look a little overwhelming, but you can think of this as a specialized word processor for programmers to write code.

Example of what an IDE looks like
IDE Example

Testing and Debugging

A program that is free of syntax errors will execute. However, this does not mean it actually works. For example, let's say you have a file with payroll information for each employee, with each employee represented by a line. You need a computer program that reads this information line-by-line and performs some type of operation, such as calculating benefits. The results should then be written to a new file.

Once you have written your code and checked for any syntax errors, you are ready to start testing. Testing consists of determining whether the program actually does what it is supposed to do. In order to test your program, you would run the program using a test file as the input. You then examine the output to make sure it is correct.

Did the program create an output file in the desired format? Does the output file contain the correct information? Were the calculations done correctly? Were all the lines in the input file processed?

Now let's say your testing shows that the output is not as expected. Time to start debugging. A bug in a computer program is a defect - something that prevents the program from executing correctly. Debugging is the process of finding and removing bugs from a program.

One approach to debugging is to read through the original code to try to find any bugs. Now imagine that your code contains 1,000 lines, and 999 of those could actually be correct. Finding the bug by manually reading through all the lines of code is possible but cumbersome.

To make debugging more effective and less time-consuming, programmers use a debugger. This is one of the tools in a typical IDE. A debugger helps you walk through your code in a systematic manner to find the bugs.

Consider the example of the payroll data. Let's say the bug is that the output data cannot be written to the output file due to some issue with the file formatting. All the calculations are done correctly, but when the time comes to write the results to an output file, an error occurs. Debugging would allow you to follow the processing of the data and see that everything went fine up until the writing of the output. So now you know which lines of code to fix.

Debugging can tell you where the bug is located in the program but not how to fix your code. You still have to go into the code, understand its logic and then correct it. However, using a debugger can save you a lot of time; instead of having to look at 1,000 lines of code, you may only have to look at 5 lines.

Machine Code vs. High-Level Languages

For now, we have simply referred to 'running' or 'executing' a program. Let's look at what this actually involves. Computers think in terms of 1s and 0s. Machine language, or machine code, is the only language that is directly understood by the computer and does not need to be translated.

Machine code uses binary notation written as a string of 1s and 0s. A program instruction in machine language may look like something like this:


Binary notation is very difficult for humans to understand. This is where high-level languages come in. A high-level language is a programming language that uses English and mathematical symbols in its instructions. When programmers write code, they use a high-level language. Examples of high-level languages are C++, Fortran, Java and Python.

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back
What teachers are saying about
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account