Source Code

From Seobility Wiki
Jump to: navigation, search

Definition

source code
Figure: Source Code - Author: Seobility - License: CC BY-SA 4.0

Source code is the underlying set of instructions that makes any website, app, or computer program work. Source code is used in everything from simple websites to spacecraft and it comes in many varieties. There are different programming languages one can use to write source code and different ways source code is used to create working software, such as compiled or interpreted code.

Structure of source code

Source code can vary wildly, depending on the programming language used, but in essence, a file (often many) is used to contain code in a plain text format. While programming languages are not quite like natural languages, they have something in common: the exact rules of grammar and vocabulary will differ by language, but all will have some form of grammar and structure to them. In the same way, most programming languages will support the features below in some way.

Variables

Variables are used to contain information that varies, hence the name. Virtually every programming language supports variables and any software that accepts user input is highly likely to use them. An example of good use of variables is an e-commerce checkout page. The structure and layout of the page will be the same for all users, but variables are used to contain the products in the basket, address information, and order instructions, that may differ from order to order.

Variables can contain different types of information. For example, a whole number such as "5" is called an integer, a word like "dog" is a string, and a simple true/false variable is called a boolean.

Statements

A statement in programming software is an instruction used to run a process or carry out a command. A simple example of a statement is one that assigns a value to a variable. For example, in Javascript, a simple variable assignment statement may look like this:

let apples = 5;

The variable 'apples' now contains the value 5 and may be referred to in code. Other common statements in programming languages include switches, while loops, if/else statements, and more.

Comparisons

Comparison operators are characters used to make comparisons, typically between two different variables. Comparison operators work differently, depending on the programming language and the type of comparison wanted.

For example, in Javascript the comparison operator '==' is used to compare values, such as '5 == 5', which would return true, as both values match. The comparison operator '===' is used to compare variable types, as mentioned above, so '5 === "5"' would return false, as one is an integer and one is a string.

Comments

Comments are not generally executed by a program, but instead, they are useful for the programmers that write the code. The software can easily become very complicated, with a large program being split into many different files, and each file may contain hundreds of lines of code.

It is tough for anyone, even a single developer, to keep track of and understand every file and every line of code. Software, both large and small, might be worked on by multiple developers, either concurrently or over time, as developers come and go. Comments help provide hints to developers as to what different blocks of code do, or how to use them. They are free-form text which is not interpreted as part of the program, so they could contain any information. An example comment in Javascript looks like below:

// A comment is a piece of text that will not be run or interpreted by the program.

Creating source code

Source code can be written in many ways. Many developers choose to use an IDE (Integrated Developer Environment) to help write source code. An IDE will typically include many features that are extremely useful for developers, such as auto-complete, code hints, debugging, code highlighting, and more.

IDEs make code much nicer to read and write, but source code may be written in a program like Notepad++. Almost all source code is plain text, so simply saving a file in Notepad++ with a .js extension will create a Javascript source code file.

Source code of a website

Source code is used to make and power websites. Behind every website, there is source code that controls the flow of information and presents it to users. Websites can be written in virtually any programming language, but popular web languages include Javascript, PHP, Python, Ruby, and Java.

Websites in particular will use a language such as PHP to create the flow and content of a website. For example, a blog article will use something like PHP to extract information like the title, author, date, and blog content from a database to be displayed on a page. HTML is then used to create the layout for a blog to display that information, and CSS is used to add stylistic information, like which fonts to use, the font sizes, colors, and other design elements. All current web browsers offer their users the possibility to view the code of a website. This is usually done by pressing CTRL+U.

Source code

Screenshot with example source code of seobility.net

Importance for SEO

Source code is very important for SEO, as it is the foundation of websites and apps. Everything from the way in which a website works, to how fast pages load, is determined at least partially by the source code. Poorly-written or poorly optimized code may load slower, which will affect page speed and, in turn, site ranking on search engines.

Source code also dictates which features a website may support, which can in turn affect SEO. Fundamentals like including meta tags, properly labeling website sections, adding alternative text to images, optimizing layouts for different screen sizes, and more contribute towards SEO and are all controlled by the underlying programming.

Related links

Similar articles

About the author
Seobility S
The Seobility Wiki team consists of seasoned SEOs, digital marketing professionals, and business experts with combined hands-on experience in SEO, online marketing and web development. All our articles went through a multi-level editorial process to provide you with the best possible quality and truly helpful information. Learn more about the people behind the Seobility Wiki.