Final Exam Flashcards
System langages vs scripting languages?
System programming languages has an emphasis on computing a result, high performance compilers. Scripting languages emphasis on automating a process, highly-portable interpreters.
What is a scripting language?
One that coordinates other programs.
Traditional programming vs scripting langues stress different priorities…
traditional programming stress efficiency, maintainability, portability, and the static detection of errors.
Scripting languages stress flexibility, rapid development, local customization, and dynamic runtime checking
General thumb of rule on speed of traditional “system languages” and scripting languages:
Code can be developed 5 to 10 times faster in a scripting language, but will run 10 to 20 times slower.
What are some common characteristics of a scripting language?
- Both batch and interactive use
- Economy of expression.
- Lack of declarations; simple scoping rules
- Flexible dynamic typing.
- Easy access to other programs.
- Sophisticated pattern matching and string manipulation.
- High level data types.
Tend to find their principal use in well-defined problem domains
General purpose languages widely used for scripting?
Scheme, visual basic
Scripting languages intended to be general purpose:
Perl, python, ruby.
Ancestors of modern scripting languages:
- Command interpreters or “shells” of traditional batch and “termina” computing.
Varios tools for text processing and repot generation: Unix sed and awk
Problem domains of scripting languages
Mathematics and Statistics (Matlab), Extension Languages, General-Purpose scripting Languages
Lua is Portuguese for?
Moon
Advantages of Lua?
Extensibility, simplicity, efficiency, and portability. Easy to write modules that add functionality. Easy to embed Lua as a scripting language in other program such a game or use it on hardware device.
What are the basic types in Lua?
nil, number, string, boolean, table, function, thread, userdata
How to define default values in functions?
the or operator:
function Hello(str)
str = str or “World”
end
How to create own blocks in lua?
Use do end
How to do variable number of parameters in lua?
... function printLines(...) for i = 1, select("#", ...) do print((select(i, ...))) end end
What are closures?
Function bound by scope preserving local variables accessed by the function.
What are types good for?
- Implicit context: programmer does not need to know the exact size of a block of memory to set aside for a variable.
- Checking to make sure that certain meaningless operations do not occur. Does not catch all but enough of them to be useful.
What is strong typing and what is static typing?
Strong typing is a buzzword that informally means that the language prevents you from applying an operation to data on which it is not appropriate.
STATIC typing means that the complier can do all the checking at compile time.
What is orthogonality?
No restrictions on the ways in which features can be combined. For example, Pascal is more orthogonal than Fortran because it allows arrays of any type.
Why is orthogonality considered good?
Makes a language easy to understand, easy to use, and easy to reason about.
What are primitive data types?
Those not defined in terms of other data types.
What is the integer type?
Almost always exact reflection of hardware.
Floating-Point Types?
Model real numbers, but only as approximations. Usually exactly like the hardware, but not always.
Decimal Types?
Essential for business applications to represent money. Essential to COBOL, c# offers a decimal data type. AA fixed number of dceimal digits is stored in binary coded decimal (BCD) form. Advantage? accuracy. Disadvantage: limited range, wasteful of memory