Introduction Flashcards
Classifying Languages 1
Languages are commonly classified by their core paradigm. But this isn’t an exact science!
- Imperative / Procedural
- Controlled flow of operations that effect a programs state.
- e.g., C, assembler [*]sh, Postscript, OpenGL, Logo, Scratch, Javascript, Python
- Object Oriented
- Imperative with implicit encapsulation of data and functions
- e.g., C++, Java, C#, Javascript, Python
- (Pure) Functional
- Declarative languages with no explicit state
- Haskell, Erlang, (Python?)
- Declarative
- Describes logic of program with minimal explicit control of the flow of execution.
- SQL, HTML, Regex
Classifying Languages 2
▪ Languages are also classified by technical design choices…
▪ Statically typed
▪ The type of a variable is explicitly defined and fixed at the time that variable is created
▪ Return types of functions/methods are also explicitly defined
▪ Dynamically typed
▪ Variables are typically not explicitly defined at all
▪ Type of a variable is inferred from its use, and can change in the lifetime of a program
▪ Compiled
▪ Programs are translated into a low level language (e.g. machine code) before they are run
▪ The high level language is then typically not directly involved at run time
▪ Interpreted
▪ The program is read (by another program) and each ‘token’ (e.g. a line of code) executed one at a time
▪ Based on the result of that execution, program flow may move to a different place in the file
Classifying Languages 3
▪ …as they directly impact the external characteristics
▪ Platform Independence
▪ Allowing a program to run on a range of platforms without adaptation
▪ Safety
▪ Verifying that a program operates as intended
▪ Scoping, type safety and immutability
▪ Expressivity
▪ How closely individual instructions relate to a users intent
▪ Closely related to the notion of code density – how much code is needed to represent a program.
▪ Performance / Efficiency
▪ How much resource is needed to execute a given program (e.g. CPU / RAM)
▪ How efficiently the language translates to hardware and its optimisations (e.g. instruction/data parallelism)
▪ Which brings other considerations to bear…