Computer Languages Humans Computers How can humans “talk to” 00101010110010 011000101110101 010111001001 10 0011 Humans Computers How can humans “talk to” (instruct) computers? Answer: Computer languages (e.g., Java, C, Python, FORTRAN, Basic, C++, Lisp, Ruby, …)
Computer Languages Natural languages are often ambiguous. Consider: “Alice and Betty had on the same dress.” Alice Betty Alice & Betty YES NO
Computer Languages Consider: “Alice and Betty ran from the same building.” Alice Betty Alice Betty NO YES
Computer Languages Natural languages contain a great deal of redundant information, making them quite “fault tolerant.” It deosn't mttaer in waht oredr the ltteers in a word are, the iprmoatnt tihng is taht the frist and lsat ltteer are in the rghit pcale. Easy for a human to make sense of this despite 13 of the 27 words being misspelled.
Computer Languages Computers typically can’t tolerate ambiguity or mistakes. Statements (instructions) must be unambiguous and without mistakes. Computer languages provide framework for humans to communicate to computers in a way that is almost natural to humans.
Computer Languages Executable Compiler File Source File 1001010001110 1011101001101 0000110010100 Compiler int main() { printf(”Hi\n”); return 0; } Source File Two-step process to execute source code. Executable File 1001010001110 1011101001101 0000110010100 Processor Output/Results
Computer Languages Source File Source code is Interpreter executed directly. Interpreter print(”Hi”) Output/Results Interactive Environment We will use Python interpreter. Compilers better at catching errors and producing faster code. Interpreters better for developing code and learning to use a language.