From the course: Programming Foundations: Fundamentals

What is a programming language? - Python Tutorial

From the course: Programming Foundations: Fundamentals

What is a programming language?

- When you want to provide instructions to a computer, you use what's called a programming language. There are hundreds, if not thousands, of programming languages available, each made up of its own syntax, or rules, and semantics, or meaning. Let me give you an analogy. In English, we would write, Welcome, and use on exclamation mark, but in Spanish, we would write, Bienvenido. Semantically, they mean the same thing, but Spanish, unlike English, requires an exclamation mark at the beginning and end. This is one rule, or a syntax, of the Spanish language. Likewise, programming languages also have unique syntax rules. Let's look at a few examples of the Hello, world program. Maybe you've already heard of it before. It's the most basic program used for decades to get started with a new programming language. It helps to highlight the differences in syntax between languages. First we'll look at a language called C++. This is how we would get the program to display Hello, world when run. Now, it may look strange to you, but that's okay. Soon you'll be able to understand exactly what's happening. For now, I want you to just notice the syntax used in the language. This consists of double quotes around the words Hello, world, the use of a semicolon at the end of statements, and there's a return keyword right before a closing curly brace. All of these things are part of the syntax, or rules, of the C++ programming language. Let's look at a few more examples. This language is called JavaScript. It's a very popular language used in virtually every website these days. This is how we would display Hello, world using JavaScript. Notice the use of different syntax. First, the words Hello, world are now inside of single quotes. We don't have any curly braces. Instead, we see something about document.write. And finally, here's Hello, world in Python. Similar syntax to JavaScript, but now we don't see any parentheses, and the use of double quotes has returned, just like we saw with C++. Now you may be wondering, what's the point of having so many different languages, especially if they do the same thing? Why not just have one programming language and we all use it? The main reason why we have so many languages is that each comes with its own set of strengths and weaknesses. Some are ideal for programming small devices with limited memory, whereas other were made to handle complex mathematical computations. Regardless of the language you choose, ultimately, that language has to be broken down into the only one that computers understand, machine language. Machine language is extremely complex for us to write directly because it's mostly just a series of numbers. Professor Mike DeHaan compared machine code to DNA molecules. Can you imagine trying to read a DNA sequence atom by atom? That would take you forever, and this is why we have these other languages that we call high-level languages. They're closer to human languages, comprised of keywords, structure, and syntax that's easier for us to learn and understand.

Contents