Computer programming languages allow us to give instructions to a computer in a language the computer understands. Just as many human-based languages exist, there are an array of computer programming languages that programmers can use to communicate with a computer. The portion of the language that a computer can understand is called a “binary.” Translating programming language into binary is known as “compiling.” Each language, from C Language to Python, has its own distinct features, though many times there are commonalities between programming languages.
These languages allow computers to quickly and efficiently process large and complex swaths of information. For example, if a person is given a list of randomized numbers ranging from one to ten thousand and is asked to place them in ascending order, chances are that it will take a sizable amount of time and include some errors.1
What's the relationship between syntax, static semantics and semantics?
I think of them as 3 levels of success:2
- The most basic level is syntax, which means you've put together something that could potentially make sense simply because it's in the right format. The English analogue to syntax is: noun-verb for a sentence. "I cat." is not a syntactically correct sentence, but "I am." is.
- The second level is static semantics, which represents "meaning". Just because you have the right syntax it doesn't necessarily result in meaning. The example in the 6.00.1x lectures was, 3 + 'hi', which follows the right syntax, but has no meaning. In English, this is like saying "I are cool." It has the right syntax (noun-verb-modifier), but it has no meaning because you can't combine "I" with "are" (kind of like how a string can't be added to an integer).
- The highest level of success is semantics. Finally, you have the syntax correct and the static semantics correct... the Python code will run! But even then, is it doing what you intended? Imagine a bad English speaker putting together a sentence that had the right syntax and static semantics... "Horse ate me" — it makes sense as a sentence... but maybe he meant to say "I ate a horse". Likewise, Python may be able to interpret your code (as it can validate syntax and static semantics), but it may not execute it the way you intended it to be.
- Object Oriented
- Algorithms and Data Structures
- Design Patterns