CS312: Programming Languages Lecture 21: Javascript 1/25 I Any AJAX Application Heavily Relies on Javascript
Total Page:16
File Type:pdf, Size:1020Kb
CS312: Programming Languages Lecture 21: JavaScript Thomas Dillig Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 1/25 I Any AJAX application heavily relies on JavaScript I JavaScript also has interesting language trade-offs I You can think of JavaScipt as a hybrid language with features from almost everywhere glued together Why Discuss JavaScript? I JavaScript is very widely used and growing Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 2/25 I JavaScript also has interesting language trade-offs I You can think of JavaScipt as a hybrid language with features from almost everywhere glued together Why Discuss JavaScript? I JavaScript is very widely used and growing I Any AJAX application heavily relies on JavaScript Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 2/25 I You can think of JavaScipt as a hybrid language with features from almost everywhere glued together Why Discuss JavaScript? I JavaScript is very widely used and growing I Any AJAX application heavily relies on JavaScript I JavaScript also has interesting language trade-offs Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 2/25 Why Discuss JavaScript? I JavaScript is very widely used and growing I Any AJAX application heavily relies on JavaScript I JavaScript also has interesting language trade-offs I You can think of JavaScipt as a hybrid language with features from almost everywhere glued together Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 2/25 I C: Systems programming I Java: Set-top box I JavaScript: Web scripting I Every language modifies some abstract data structure I In JavaScipt, this is the document object model of an html web page JavaScript Target I Every language has a design target: Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 3/25 I Java: Set-top box I JavaScript: Web scripting I Every language modifies some abstract data structure I In JavaScipt, this is the document object model of an html web page JavaScript Target I Every language has a design target: I C: Systems programming Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 3/25 I JavaScript: Web scripting I Every language modifies some abstract data structure I In JavaScipt, this is the document object model of an html web page JavaScript Target I Every language has a design target: I C: Systems programming I Java: Set-top box Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 3/25 I Every language modifies some abstract data structure I In JavaScipt, this is the document object model of an html web page JavaScript Target I Every language has a design target: I C: Systems programming I Java: Set-top box I JavaScript: Web scripting Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 3/25 I In JavaScipt, this is the document object model of an html web page JavaScript Target I Every language has a design target: I C: Systems programming I Java: Set-top box I JavaScript: Web scripting I Every language modifies some abstract data structure Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 3/25 JavaScript Target I Every language has a design target: I C: Systems programming I Java: Set-top box I JavaScript: Web scripting I Every language modifies some abstract data structure I In JavaScipt, this is the document object model of an html web page Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 3/25 I Embedded JavaScript produces HTML to be displayed by the browser I Shell Scripts compute commands executed by the shell I Lots of string support I Simple structure with little/no declarations I Flexibility preferred over efficiency, safety, common sense I More specifically, a scripting language is used to write programs that produce inputs to another language processor I Examples: I Common characteristics of scripting languages: What's a Scripting Language? I Answer: One language embedded in another Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 4/25 I Embedded JavaScript produces HTML to be displayed by the browser I Shell Scripts compute commands executed by the shell I Lots of string support I Simple structure with little/no declarations I Flexibility preferred over efficiency, safety, common sense I Examples: I Common characteristics of scripting languages: What's a Scripting Language? I Answer: One language embedded in another I More specifically, a scripting language is used to write programs that produce inputs to another language processor Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 4/25 I Lots of string support I Simple structure with little/no declarations I Flexibility preferred over efficiency, safety, common sense I Embedded JavaScript produces HTML to be displayed by the browser I Shell Scripts compute commands executed by the shell I Common characteristics of scripting languages: What's a Scripting Language? I Answer: One language embedded in another I More specifically, a scripting language is used to write programs that produce inputs to another language processor I Examples: Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 4/25 I Lots of string support I Simple structure with little/no declarations I Flexibility preferred over efficiency, safety, common sense I Shell Scripts compute commands executed by the shell I Common characteristics of scripting languages: What's a Scripting Language? I Answer: One language embedded in another I More specifically, a scripting language is used to write programs that produce inputs to another language processor I Examples: I Embedded JavaScript produces HTML to be displayed by the browser Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 4/25 I Lots of string support I Simple structure with little/no declarations I Flexibility preferred over efficiency, safety, common sense I Common characteristics of scripting languages: What's a Scripting Language? I Answer: One language embedded in another I More specifically, a scripting language is used to write programs that produce inputs to another language processor I Examples: I Embedded JavaScript produces HTML to be displayed by the browser I Shell Scripts compute commands executed by the shell Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 4/25 I Lots of string support I Simple structure with little/no declarations I Flexibility preferred over efficiency, safety, common sense What's a Scripting Language? I Answer: One language embedded in another I More specifically, a scripting language is used to write programs that produce inputs to another language processor I Examples: I Embedded JavaScript produces HTML to be displayed by the browser I Shell Scripts compute commands executed by the shell I Common characteristics of scripting languages: Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 4/25 I Simple structure with little/no declarations I Flexibility preferred over efficiency, safety, common sense What's a Scripting Language? I Answer: One language embedded in another I More specifically, a scripting language is used to write programs that produce inputs to another language processor I Examples: I Embedded JavaScript produces HTML to be displayed by the browser I Shell Scripts compute commands executed by the shell I Common characteristics of scripting languages: I Lots of string support Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 4/25 I Flexibility preferred over efficiency, safety, common sense What's a Scripting Language? I Answer: One language embedded in another I More specifically, a scripting language is used to write programs that produce inputs to another language processor I Examples: I Embedded JavaScript produces HTML to be displayed by the browser I Shell Scripts compute commands executed by the shell I Common characteristics of scripting languages: I Lots of string support I Simple structure with little/no declarations Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 4/25 What's a Scripting Language? I Answer: One language embedded in another I More specifically, a scripting language is used to write programs that produce inputs to another language processor I Examples: I Embedded JavaScript produces HTML to be displayed by the browser I Shell Scripts compute commands executed by the shell I Common characteristics of scripting languages: I Lots of string support I Simple structure with little/no declarations I Flexibility preferred over efficiency, safety, common sense Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 4/25 I Later standardized for browser compatibility, called ECMAScript I Renamed to JavaScript in part of marketing deal with Sun - no relation to Java! I Today: Many implementations available JavaScript History I Developed by Brendan Eich at Netscape in 1995 as scripting language for Navigator 2 Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 5/25 I Renamed to JavaScript in part of marketing deal with Sun - no relation to Java! I Today: Many implementations available JavaScript History I Developed by Brendan Eich at Netscape in 1995 as scripting language for Navigator 2 I Later standardized for browser compatibility, called ECMAScript Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 5/25 I Today: Many implementations available JavaScript History I Developed by Brendan Eich at Netscape in 1995 as scripting language for Navigator 2 I Later standardized for browser compatibility, called ECMAScript I Renamed to JavaScript in part of marketing deal with Sun - no relation to Java! Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 5/25 JavaScript History I Developed by Brendan Eich at Netscape in 1995 as scripting language for Navigator 2 I Later standardized for browser compatibility, called ECMAScript I Renamed to JavaScript in part of marketing deal with Sun - no relation to Java! I Today: Many implementations available Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 5/25 I Has >90% browser market share I Opportunity to define the HTML scripting language I Brendan Eich: \I hacked the JS prototype in 1 week in May, and it showed! Mistakes were frozen early.