tags:
- bsu
- school
- cs354
- programming-languages
- notes
- lecture
source: https://boisestatecanvas.instructure.com/courses/37064/files/folder/pub/slides?preview=18225184
created: 2025-01-13
published: 2025-01-13
What is a natural language? (1)
A natural language is any language which occurs naturally in a human community.
What is a formal language? (1)
A formal language is a language consisting of words whose letters are taken from an alphabet and are formed according to a set of rules.
What is the set of rules for a formal language called? (1)
The set of rules for a formal language is called a formal grammar.
Are programming languages natural languages or formal languages?
Programming languages are formal languages.
Is knowing multiple programming languages a good thing?
Yes, knowing multiple programming languages is a good thing.
In what ways are programming languages different from one another?
The ways that programming languages are different from one another include:
- Their features.
- Their paradigms.
- What tasks they're good at.
What should you know about the design of a programming language?
For the design of a programming language, you should know the theory behind it.
It's good to know multiple programming languages because they're different from one another in their features, paradigms, and what tasks they're good at. By knowing a language, you should also understand the theory behind its design.
What are five basic levels of abstraction when it comes to programming languages?
When it comes to programming languages, the five basic levels of abstraction are:
What makes Java an intermediate language?
What makes Java an intermediate language is that it compiles to a bytecode that's lower level than source code but higher level than actual machine code.
What are twelve different reasons why there are many different programming languages?
Twelve different reasons why there are many different programming languages are:
What are six reasons why some programming languages are more successful than others?
Six reasons why some programming languages are more successful than others are:
What three things does a programming language help to determine?
Three things that a programming language helps to determine include:
What two points of view do some programming languages try to match?
The two points of view that some programming languages try to match include:
What two things can a programming language be an abstraction of?
Two things a programming language can be an abstraction of are:
What do programming languages allow you to do?
Programming languages allow you to specify what you want the hardware to do without getting down into the bits.
What are five benefits of knowing multiple programming languages?
Six benefits of knowing multiple programming languages are that:
x << 1
instead of x * 2
.x * x
instead of x ** 2
.with
statement to factor address calculations.What is a programming paradigm? (1)
A programming paradigm is a relatively high-level way to conceptualize and structure the implementation of a computer program.
What can an assignment statement cause in imperative programming languages and what does it influence?
In imperative programming languages, an assignment statement can cause a side-effect which influences future computation.
What does an imperative program tell the computer and how?
An imperative program tells the computer how to solve a problem in a particular way by using statements to describe each step.
Newton's method for finding the square root of a number.
What does a declarative program tell the computer and how?
A declarative program tells the computer what problem to solve by describing all of the acceptable solutions for it.
What is a declarative programming language translator free to choose when processing a program?
When processing a program, a declarative programming language translator is free to choose any way of finding an acceptable solution.
What are functional programming languages based on?
Functional programming languages are based on recursive-function definition and invocation without side-effects.
Are programming language families clear cut?
No, programming language families aren't clear cut.
You can write a C program in a functional style if you constrain yourself.
What is dataflow programming? (1)
Dataflow programming is a programming paradigm that models a program as a directed graph of the data flowing between operations.
What do dataflow programming languages model and with what?
Dataflow programming languages model computation with nodes that transform input data streams into output data streams.
What do the arcs between nodes in dataflow programming model?
In dataflow programming, arcs between nodes model the data streams.
jq
.What were scripting programming languages originally used for?
Scripting programming languages were originally used for gluing together other programs.
What have scripting programming languages morphed into?
Scripting programming languages have morphed into von Neumann and object-oriented programming languages.
How do object-oriented programming languages model computation?
Object-oriented programming languages model computation as the message-passing simulation of real-world entities.
What are other imperative programming languages identified with?
Other imperative programming languages are identified with John von Neumann.
/* gcc -Wall -g -o gcd gcd.c && ./gcd */
int gcd(int a, int b) {
while (a != b) {
if (a > b)
a = a - b;
else
b = b - a;
}
return a;
}
int main() {
printf("gcd(15,25)=%d\n", gcd(15, 25));
return 0;
}
#!/usr/local/bin/guile
!#
(define (gcd a b)
(cond ((= a b) a)
((> a b) (gcd (- a b) b))
(else (gcd (- b a) a))))
(display "(gcd 15 25)=")
(display (gcd 15 25))
(display "\n")
#!/bin/gprolog --consult-file
gcd(A, A, A).
gcd(A, B, G) :- B > A, C is B-A, gcd(C, A, G).
gcd(A, B, G) :- A > B, C is A-B, gcd(C, B, G).
main :- gcd(15, 25, G), write('gcd(15, 25, G)='), write(G), nl, halt.
:- initialization(main).
Are compilation and interpretation opposites?
No, compilation and interpretation aren't opposites.
What is pure compilation?
Pure compilation is when the compiler translates the high-level source program into an equivalent target program and then exits.
What is the benefit of compiled programs?
The benefit of compiled programs is that they're more time and space efficient.
What is pure interpretation?
Pure interpretation is when the interpreter translates each statement or construct and then immediately executes that translation.
What is the benefit of interpreted programs?
The benefit of interpreted programs is that they're more flexible and easier to debug.
What is the flowchart for each step in compilation?
The flowchart for each step in compilation is:
What is the flowchart for each step in interpretation?
The flowchart for each step in interpretation is:
What is the flowchart for each step in hybrid compilation-interpretation?
The flowchart for each step in hybrid compilation-interpretation is:
What is the interpreter for Java byte-code?
The interpreter for Java byte-code is the Java Virtual Machine (JVM).
What is the intermediate program also called?
The intermediate program is also called intermediate code.
Do all compilations of source code need to produce an output that hardware can natively understand?
No, not all compilations of source code need to produce an output that hardware can natively understand.
Compilation entails "... ..." of what is being processed.
Compilation entails "semantic understanding" of what is being processed.Preprocessing is a ..., rather than ..., transformation.
Preprocessing is a textual, rather than grammatical, transformation.
What do many compiled languages have?
Many compiled languages have interpreted pieces.
printf
and scanf
function calls.printf
function call in C which is interpreted/* gcc -Wall -g -o format format.c && ./format */
#include <stdio.h>
int main() {
int i = 123;
double d = 3.14;
printf("%7d FOO %7.4f\n", i, d);
return 0;
}
C gcc -Wall -g -o format format.f -lgfortran && ./format
PROGRAM MAIN
I=123
D=3.14
PRINT 10,I,D
10 FORMAT (I7, ' FOO ', F7.4)
END
What do some compilers only produce?
Some compilers produce only virtual instructions.
What do some translation systems use?
Some translation systems use a preprocessor.
What are some things a preprocessor does?
Some things a preprocessor does include:
- Removing comments and whitespace.
- Grouping characters into tokens, like keywords, identifiers, numbers, and punctuation.
- Expanding abbreviations in the style of a macro assembler.
- Identifying higher-level syntactic structures.
What is the flowchart for compilation with an assembler and linker?
The flowchart for compilation with an assembler and linker is:
What features does the C preprocessor have?
The features which the C preprocessor has include:
#if
and friends.#include
.#define
.#pragma
.What is the flowchart for compilation of a C++ program?
The flowchart for compilation of a C++ program is:
This section shows what implementations you could create if you were porting Pascal to a new computer.
...