100 likes | 209 Views
High Level Languages. Why don’t Computers understand English?. Complexity of human language Size of vocabulary Flexibility of grammar E.g. Word order Ambiguity Figures of Speech Metaphors Similes Etc. So what is their language?. Machine Code Binary 0 and 1
E N D
Why don’t Computers understand English? • Complexity of human language • Size of vocabulary • Flexibility of grammar • E.g. Word order • Ambiguity • Figures of Speech • Metaphors • Similes • Etc.
So what is their language? • Machine Code • Binary 0 and 1 • Impossible for humans to understand • Lots of tiny steps to do one task • Controls working of the computer • Low level language 010101111101010101010101010111111
How to control computers? • They can’t understand English • We can’t understand Machine Code • Need an “in-between” language • High Level Languages • Assembly Code
High Level Languages • Similar to English • PRINT, FOR…STEP…NEXT, DO… LOOP etc • Easy to learn / write / edit • Designed to solve problems • Different types • Need translating to Machine Code
HLLs - Examples • BASIC • Beginners’ All-purpose Symbolic Instruction Code • COBOL • Common Business Oriented Language • PROLOG • Programming with Logic
Translation • All HLLs need translated into machine code • Interpreted Languages • Line at a time • Compiled Languages • All done in one go at the start
Compiled Languages • E.g. C++ • Won’t run at all if there’s a syntax (grammar) error anywhere • E.g. missing colon, FOR without NEXT etc. • Guaranteed grammatically correct when it runs • Runs fast once translated
Interpreted Languages • E.g. Visual Basic • Points out errors at implementation stage • Will run until an error is found • May take ages to find an error • Slower to run • Each instruction translated as required • Wasteful of time in loops
Assembly Code • Sometimes HLLs aren’t what’s needed • Low level – nearer Machine Code • Translated to M/Code by Assembler • Control computer SUB ESP, LOCALDATASPACE ; make space for local data FLD [ESP].SMAP.A ; load a FSTP [ESP].SMAP.CALLPARM1 ; store a on top of stack CALL _sin ; _sin reads parameter CALLPARM1 FSTP [ESP].SMAP.X ; store x