Invitation to Cybersecurity

2. The Context of Cybersecurity: Cyberspace 23 Computer programs need to be unambiguous, so programming languages have a well-defined syntax. The syntax is the rules for writing a program in a given language. Syntax rules specify how variables and procedures are defined and how statements are constructed and delimited. For example, the C++ programming language dictates that statements are delimited with a semicolon and procedure definitions are enclosed in curly braces. A big part of learning a programming language is learning its keywords and syntax. Once a person learns a couple of different programming languages, additional ones come quickly because the algorithmic thinking process remains the same and learning new programming language syntax becomes intuitive. Computer hardware cannot directly execute a computer program written in a high level programming language. The program has to be transformed into the instructions that a CPU can execute. These simpler instructions are called machine code and are usually rendered in hexadecimal. A more human-readable form of machine code called assembly language uses mnemonic names as substitutes for hexadecimal machine code instructions. A few lines of a high-level program might result in hundreds of machine code instructions. A compiler is a program that takes as input a text document that contains a high-level program, called source code, and produces as output machine code that can be executed by a computer. If the source code does not have proper syntax, the compiler will fail and return a syntax error. A compiled program is called an executable and can be run by the operating system. Some programming languages do not require that source code be compiled before it can be run. These are called interpreted languages. Instead of going through a compiler, these programs are run by an execution engine program called an interpreter that transforms the source code into machine instructions line-by-line at execution time. Python is a well-known interpreted language. Interpreted programs are called scripts to differentiate them from executables. Traditionally the first program someone writes in a new language is called the Hello, World! program. This is a simple program that just prints “Hello, World!” as output. Table 2.5 shows some Hello, World! programs in different languages. The JavaScript and Python code is much shorter because they are interpreted languages.

RkJQdWJsaXNoZXIy MTM4ODY=