Programming Languages Notes - Youre Welcome Society
Programming Languages Notes - Youre Welcome Society
ble all memory management done during runtime. Slow, compared to the stack stack well organized very systematic operations implicit heap-dynamic variables bound to heap storage when they are assigned values value determines storage size. Names that adapt to whatever purpose is given most flexible highest runtime cost. Less ability to error check Scope Range of statements in which a variable is visible Static Scope compile time C/C++, Java scope is determined by the physical spacial arrangement of code. Global variable scope everywhere no 'protection' in C++ if a scope has multiple variables of the same name, the closest one 'hides' the further ones. ::a = 0; refers to global variable a faster during execution less flexible may encourage overuse of global variables Dynamic Scope APL, SNOBOL4, early Lisp, Perl(optional) scope based on the call order during runtime makes reuse difficult readability is more difficult local variables are visible to other functions reliability suffers. Memory access is slower. Scope determined at runtime. Referencing Environment collection of all variables available at that statement.
Notes Sept 16 2011 Named Constant a variable that is bound to a value only once. Readability: Increased. Writability: Increased. Relaibility: Increased. Data type collection of data values and a set of predefined operations on those values. Primitive Data Type not defined in terms of other data types. 'base types' Numeric Types: Int Sizes : nibble, byte, short, long Two's compliment: easy math with negative numbers Float Precision: # of decimal places Range: range of exponents Storage: 1 8 23 [sign][exponent][ fraction] 1 11 52 [sign][exponent][ fraction] Decimal binary coded decimal stored like a string COBOL & C# restricted range less efficient memory use (1-2 bytes per digit) precisely store decimal values Boolean True / False 1 bit Character ASCII 8 bits Character String string type or character array? String type has no indexing Dynamic or Static length? Who checks for string overflow? C/C++ - programmer Java program checks C/C++ strings end with '\0' C/C++ - character array Size? -compile time Static length set at declaration limited dynamic length given a max length
length can very up to max length dynamic length can change at any time, no max String Class C++ Library dynamic string does not increase compiler complexity