# SPO - Lecture 1
## 1 - Review your individual list of programming languages and make a new list of all the computer languages that group members know.
* C
* C#
* C++
* Java
* JS
* Typescript
* VBA
* Processing 3
* Python
* Markdown
* LaTeX
* HTML
* CSS
* Node.js
* p5.js
* R
* MatLab
* SQL
## 2 - Categorize the above languages according to generations (1st to 5th (or 6th))
### 1st - None of the above
### 2nd - None of the above
### 3rd - C, C++, C#, Java, JS, Python, Processing 3, VBA, Typescript, Node.js, LaTeX, P5.js
### 4th - SQL
### 5th - MatLab, R,
## 3 - Categorize the above languages according to paradigm (imperative, object oriented, declarative, special)
### Imperative: C
### Object oriented: C#, Java, C++, Typescript, Processing 3, Python, p5.js, Node.js, JS, VBA
### Declarative: SQL, MatLab, R
### Special: None of our languages are special
## 4 - Create a new list of language features group members would like in a new language. Are any of these features in conflict with each other? How would you prioritize the features?
* if-else
* for
* while
* for each
* functions/methods
* classes/objects
* not typed
* startup + main loop
## 5 - Do Sebesta exercise 1, 2 and 3 page 55.
**1. Do you believe our capacity for abstract thought is influenced by our language skills? Support your opinion.**
- Yes, features of a programming language can be limiting.
- There is a difference between thinking in abstraction in imperative languages and object oriented languages. E.g. in C there are not classes or generics, but in C# there are classes.
**2. What are some features of specific programming languages you know whose rationales are a mystery to you?**
- brainfuck, nobody can read it, it makes no sense what...so..ever.
**3. What arguments can you make for the idea of a single language for all programming domains?**
- That switching project type would not have the learning curve of understanding a new languages syntax. It would be able to run on all architectures.
- Languages would not have to be compatible (e.g. backwards compatible), since there is only one (to rule them all)
- One IDE could be used for everything (a bit like VS Code is trying to be)
## 6 - Do Sebesta exercise 4, 7, 10 and 17 page 56.
**4. What arguments can you make against the idea of a single language for all programming domains?**
- A language that can do everything is rarely very efficient at any of them.
- It would most likely not be simple, and have way too much orthogonality. This causes readability and writability to decrease
**7. Java uses a right brace to mark the end of all compound statements. What are the arguments for and against this design?**
- It is easy to see when a body ends but takes a long time to write and it can be hard to find where an end bracket is missing if there is a lot of nesting.
**10. What are the arguments for writing efficient programs even though hardware is relatively inexpensive?**
- Energy consumption and computation is still not free, and it also makes it possible to run on a larger range of hardware.
**17. Some programming languages — for example, Pascal - have used the semicolon to separate statements, while Java uses it to terminate statements. Which of these, in your opinion, is most natural and least likely to result in syntax errors? Support your answer.**
- I like when it is used for terminating statements, because it defines when I am done with this statement, and now I can start on another. It is more likely to have syntax errors if you forget the semicolons when terminating statements, but on the other hand for some people it makes sense to have the semicolons at the end, as if it was a punctuation mark.
- Pascal is worse since it seems more inconsistent.
## 7 - Do Sebesta exercise 18 page 56.
**18. Many contemporary languages allow two kinds of comments: one in which delimiters are used on both ends (multiple-line comments), and one in which a delimiter marks only the beginning of the comment (one-line comments). Discuss the advantages and disadvantages of each of these with respect to our criteria.**
- One line: quick for one line of code, but a lot of work for multiple lines.
- Multiple-line: Increases writability - it allows to comment out sections of code fast. If you only want to comment out one line of code, it is slower since you have to write in front of and behind the code.
## 8 - Do Fisher et al. Exercise 5 and 6 on page 27-28 (exercise 7 and 14 on page 56 resp. 58 in GE)
**5. To allow the creation of camera-ready documents, languages like TeX and LaTeX have been created. These languages can be thought of as varieties of programming languages whose output controls a printer or display. Source language commands control details like spacing, font choice, point size, and special symbols. Using the syntax-directed compiler structure of Figure 1.4, suggest the kind of processing that might occur in each compiler phase if TeX or LaTeX input was being translated. An alternative to “programming” documents is to use a sophisticated editor such as that provided in Microsoft Word or Adobe FrameMaker to interactively enter and edit the document. (Editing operations allow the choice of fonts, selection of point size, inclusion of special symbols, and so on.) This approach to document preparation is called WYSIWYG — what you see is what you get — because the exact form of the document is always visible. What are the relative advantages and disadvantages of the two approaches? Do analogues exist for ordinary programming languages?**
- TeX and LaTeX: Templates - easier to automate creation of documents, and easier to make several uniform looking documents.
- WYSIWYG: Easy to use for beginners, because WYSIWYG editors provide easy interfaces to use.
**6. Although compilers are designed to translate a particular language, they often allow calls to subprograms that are coded in some other language (typically, Fortran, C, or assembler). Why are such “foreign calls” allowed? In what ways do they complicate compilation?**
- compilation is more complicated due to more languages being involved, and sub-program calls are potentially very bad for excecution costs and hard to optimize.
- Compilation is complicated, because in order to create the result the compiler has to interleave the output of two languages.
## 9 - Do Fisher et al. Exercise 8 on page 28 (exercise 11 on page 57 in GE)
**8. C is sometimes called the universal assembly language in light of its ability to be very efficiently implemented on a wide variety of computer architectures. In light of this characterization, some compiler writers have chosen to generate C code as their output instead of a particular machine language. What are the advantages to this approach to compilation? Are there any disadvantages?**
- Disadvantages: Difficult to translate some high-level languages to C. Loss of low level control. The performance of the new features might not be able to be fully optimized.
- Advantages: Easy portability. C can be compiled to fast assembly code with existing C compilers. Now the compiler writes do not have to replicate all of the optimizations already built into the C compiler.