From the course: Introduction to Career Skills in Software Development

Basic components of a programming language - Python Tutorial

From the course: Introduction to Career Skills in Software Development

Basic components of a programming language

- [Instructor] A programming language can be broken down into two components, its syntax or rules and its semantics or meaning. For instance, we would write Welcome in English and use one exclamation mark. But in Spanish we would write Bienvenido. They mean the same thing, but Spanish requires an exclamation mark at the beginning and end, unlike English. This is one rule or syntax of the Spanish language. Likewise, programming languages also have unique syntax rules. Let's look at an example. First we'll look at a language called JavaScript. This is how we would get the program to print out "Hello!" when run. This may look strange to you right now, but that's okay. I want you just to notice the syntax used in the language. It starts with something called document.write, and then a set of parentheses. Next you'll see single quotes around the word Hello. And then the use of a semicolon at the end of the line. These things are part of the syntax or rules of the JavaScript programming language. Now let's look at some code in the Python programming language. This does the same thing. The syntax is similar to JavaScript, but now we don't see any parentheses. But there's a print. And instead of single quotes, we have double quotes for the word Hello. This adheres to the Python language syntax. Besides syntax, programming languages are also defined by their semantics or meaning. An example will help to illustrate this aspect. This is some code in the Kotlin programming language. Let's discuss its semantics. It means to assign space and memory and store the word Hi in it. Then label that space greeting. And later, if someone tries to clear out the memory for the space labeled greeting, don't let them do it. And yes, we get (laughs) all of that with just a tiny amount of code. Now you've learned about the two basic components of a programming language, syntax and semantics. You've also seen a few examples of how they vary among the languages.

Contents