Languages Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Source Code and Compiler

A
  • “source code” is the high level code authored by the programmer
  • the compiler reads the source code and translates and expands it to a larger sequence of machine code instructions to implement the sequence of actions specified by the code
    • suppose a “high level” construct, an if-statement, can be implemented by a sequence of 5 machine code instructions
  • the output of the compiler is a program file
  • end user does not need source code or compiler
  • does not work backwords well
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Dynamic (Interpreter) Languages

A
  • intrepreter is a program that “runs” other code
    • web browsers include a JS interpreter
    • proceeds through the code given to it, line by line
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Compiler vs. Interpreter Process

A
  • a compiler translates all the source code into equivalent machine code program.exe to be run later – it is a bulk translation.
  • an interpreter looks at each line of code, and translates and runs it in the moment, and then proceeds to the next line of source code
  • the interpreter does not produce a program.exe, instead it performs the actions specified in the source code directly
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Compiler Advantages

A
  • compiled code generally runs faster than interpreted code
  • pre-processing the source code, stripping out many complications, leaving the program as lean and direct as it can be to just run
  • In contrast, the interpreter deals with each line in the moment, so all the deciphering and overhead costs of interpreting each line are paid as it runs
  • these overhead costs in effect make the interpreted program run more slowly than the equivalent compiled program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Dynamic Language Advantages

A
  • tend to have a greater number of programmer-friendly features
  • automatic memory management, no programmer input needed
  • in contrast, in C and C++, the programmer at times must think about memory management at times, and may have to author lines of code to help solve it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Memory Management

A

the isssue in a program of knowing, over time, when bytes of RAM are needed and when they can be reclaimed and used for something else

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

JIT

A
  • “Just In Time” compiler
  • best of both compiler and interpreter worlds
  • the interpreter is used for simple cases, but for important sections of dynamic code (like the inside of a loop), the JIT creates a block of machine code in RAM for that section
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What best describes what a C++ compiler does?

A

translates C++ source code into machine code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The CPU’s machine code has only simple, low-level instructions. A computer language (such as Javascript) adds high-level features, such as the for-loop we have used. What are some high-level instructions?

A
  • loop over all the pixels in an image
  • append two strings together
  • print a string to the screen
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Firefox is an open source program, so anyone can get access to the source code. What is something that is possible because Firefox is open source?

A

anyone is free to run the compiler to produce and distribute their own version of Firefox

How well did you know this?
1
Not at all
2
3
4
5
Perfectly