Introduction to Programming
With the AP CSP Pseudocode Interpreter
What is Programming?
If you have found yourself in AP Computer Science Principles (the course this course was made for) or have found yourself looking at this lesson in general, you probably already have a good idea of what programming is. In short it is the creation of algorithms. In other words, it is the process of creating step by step instructions that solve a given problem without volatility. It may surprise you to know, though, that not all programming involves writing code, and not all code results in a program. Often times we write code that does not solve any problem—it is simply there as information storage. Web pages are formatted in what is called HTML (Hyper Text Markup Language). It has code but no special list of instructions that solve a problem. Code is simply a set of symbols that represent information. The English language is, by this definition, code, but it is not a program. On the flip side, you can program without code. You can program using what are called visual programming languages. These come in various forms; some you create graphs which represent the flow of data and others you drag blocks. One famous visual programming language—called Scratch—allows you to create games without ever writing a line of code. In fact, programming can be purely biological. It is likely you put your clothes on in a specific order every day; this is an example of one way you have been “programmed.” Your (DNA) is an example of biological code.
- Volatility (adj)
- the state of being volatile.
- a tendency to change.
What is a Programming Language?
While biological programming is fascinating, that is unfortunately well beyond the scope of what we are going to learn here. We are only concerned here with computer programming. In order to program a computer, we use a specific kind of code called a programming language. Just as languages in real life, programming languages are numerous and have lots of variety. The reason for this is simple: different contexts and cultures result in different languages. For example Hawaiian has specific words for toward the mountains (inland) and toward the ocean (seaward). This makes sense for the context Hawaiian was formed in but would not for someone who lives in Kansas. In the same way, programming languages reflect context and culture.
SQL (Structured Query Language) is a language meant to interact with databases; as such, it has certain operations that are only useful when working with databases and lacks other useful operations other languages have. Instead of being structured around a list of instructions like most languages, it is structured around data queries. It is almost like every command in SQL is asking the database a question. Below is an example of SQL code.
AP CSP covers many topics and different “contexts” in programming. Therefore, AP CSP uses its own special programming language meant to be more abstract than your typical language: AP CSP Pseudocode (CSP). Instead of spending time learning syntax and highly specific language features, AP CSP will teach you how to think like a programmer and common patterns across many languages.
Anytime you see a “csp” block you are able to run and edit the code within. A “*csp” block also shows CSP code, but you can not run it.
By the end of this course you should not only be able to write CSP, but you should be able to understand code written in languages you do not know. For instance, below is the same program that is above just written in the Rust programming language. You may not be able to write code in this language, but you will understand the basic constructs that are used after completing the course.
Conclusion
Programming, at its core, is the creation of algorithms: step-by-step instructions that reliably solve a problem. As you have seen, programming does not require writing code, and code does not always make a program. What matters is the thinking behind the instructions.
Programming languages are the tools we use to express that thinking to a computer. Like human languages, they are shaped by the contexts they were built for, which is why SQL looks nothing like the pseudocode you will use in this course. AP CSP Pseudocode strips away the quirks of any single language so you can focus on what transfers everywhere: breaking problems into steps, working with data, and recognizing common patterns.
In the lessons ahead, you will put these ideas to work by writing and running your own programs. Do not worry about memorizing syntax. Learn to think like a programmer, and every language you meet afterward will be easier to pick up.
Next: Display