Syntax Errors What They Are and Why They re a Problem

Syntax Errors What They Are and Why They re a Problem

Syntax Errors: What They Are and Why They're a Problem GA S REGULAR Menu Lifewire Tech for Humans Newsletter! Search Close GO Software & Apps > Windows

Syntax Errors: What They Are and Why They're a Problem

Even the smallest mistakes can break an app

By Jody Emlyn Muelaner Jody Emlyn Muelaner Writer University of Bath Dr. Jody Muelander is a former freelance contributor to Lifewire who's writing has appeared in peer-reviewed journals and aerospace industry reports. lifewire's editorial guidelines Updated on September 15, 2020 Tweet Share Email Tweet Share Email Windows The Ultimate Laptop Buying Guide Computer languages impose strict rules. A syntax error means one of those rules is broken. Syntax exists in ordinary language. It's the way words are arranged into sentences to make sense. Humans are adaptable. They can structure a sentence in many ways, and it will still make sense. In contrast, computers require precise instructions. If you break the rules a bit, a command may make sense to a human, but a computer won't be able to interpret it. Valentin Wolf / Getty Images

Syntax in Human Language

Imagine someone says to you, "I saw a woman over there with a telescope." There are several ways to interpret this sentence: Using a telescope, I observed a woman who was over there.I observed a woman, who was over there, and she had a telescope.I observed a woman and a telescope, they were both over there.I was over there, and I observed a woman who had a telescope.Sometimes, I go over there and saw a woman using a telescope. Because you're human, you can apply context to this sentence. You wouldn't consider the last interpretation because you know we don't use telescopes for sawing people as if they were slices of bread. Based on where over there is, and possibly any previous discussion about telescopes, you would probably correctly assume the first or second interpretation.

What is a Syntax Error in a Computer Language

How syntax errors are handled in different languages can vary. For example: Excel: If you type a formula with an incorrect syntax into a cell in Excel, #VALUE displays in the cell. It won't be explicitly labeled as a syntax error, but that's what it is. HTML: You can break a lot of rules in HTML, and a web page will display fine in most browsers. The problem with this is the behavior can become unpredictable. A page may look fine on one browser, but not work on another. It's a good idea to check your code with the W3C validation service, which provides detailed information about errors in the HTML code. If there's a syntax error in JavaScript, it prevents the thread with the error from running. However, the rest of the code, contained in other threads, will execute, provided the code isn't dependent on the thread with the error. When running the code in a browser, typically, nothing happens. You won't get an error message, nor will the code run.

What to Do If You Have a Syntax Error

Debug your code if you encounter a syntax error. Identify the location of the error. You'll encounter detailed error messages in many languages, informing you where the error is in the code. If you know which instruction has the error, you can check the documentation for examples of the correct syntax. If you're not sure where the problem is, break the code into smaller sections, seeing if each one works to identify which section contains the error. When you repeat this process, it's possible to determine where the problem is and fix it. If you need to debug a lot of web code, consider using developer tools. Was this page helpful? Thanks for letting us know! Get the Latest Tech News Delivered Every Day Subscribe Tell us why! Other Not enough details Hard to understand Submit More from Lifewire What Is Syntax? (Syntax Definition) 500 Internal Server Error What Is a Web Browser? Script Errors (What They Are and How to Fix Them) How to Fix the 400 Bad Request Error 9 Best Free HTML Editors for Windows for 2022 What Is a POST Code? (Power on Self Test Code) What Is a Command Line Interpreter? What Are HTTP Status Codes? Error 524: A Timeout Occurred (What It Is & How to Fix It) What Is a 401 Unauthorized Error and How Do You Fix It? What to Do When Facebook Isn't Sending Security Codes What Is a Power on Self Test Card? How to Fix Error Code 29 PHP File (What It Is & How to Open One) How to Insert Source Code Into a Word Document Newsletter Sign Up Newsletter Sign Up Newsletter Sign Up Newsletter Sign Up Newsletter Sign Up By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Cookies Settings Accept All Cookies
Share:
0 comments

Comments (0)

Leave a Comment

Minimum 10 characters required

* All fields are required. Comments are moderated before appearing.

No comments yet. Be the first to comment!