JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha,...

10
JavaScript: An Analysis Michael Owen

description

Data Types Only three primitive types –String –Number –Boolean All numbers are stored as floating point numbers Variables are not explicitly declared

Transcript of JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha,...

Page 1: JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha, LiveScript, then JavaScript No apparent relation to Java.

JavaScript: An AnalysisMichael Owen

Page 2: JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha, LiveScript, then JavaScript No apparent relation to Java.

Brief History

• Founded at NetScape by Brendan Eich• Mocha, LiveScript, then JavaScript• No apparent relation to Java• Embedded in HTML• Interpreted language• Microsoft’s version is Jscript• Standardized in Nov. 1996

Page 3: JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha, LiveScript, then JavaScript No apparent relation to Java.

Data Types

• Only three primitive types– String– Number– Boolean

• All numbers are stored as floating point numbers

• Variables are not explicitly declared

Page 4: JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha, LiveScript, then JavaScript No apparent relation to Java.

Object-Oriented Support

• Prototype-oriented programming• Everything but primitive types are

considered objects• Objects seem hidden within the code• Arrays are dynamic which can be

dangerous• Fully supports inheritance, encapsulation,

and polymorphism

Page 5: JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha, LiveScript, then JavaScript No apparent relation to Java.

Subprograms

• Functions are treated as objects but act the same way you’d expect

• Parameters are more like guidelines• Can call functions recursively• Can declare functions within functions

Page 6: JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha, LiveScript, then JavaScript No apparent relation to Java.

Readability of JavaScript

• Easy to read if familiar with Java or C++• Suffers a bit since variables are never

declared with a type• Orthogonality is high with only three

primitive data types• Can perform any operation between any

two data types

Page 7: JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha, LiveScript, then JavaScript No apparent relation to Java.

Writability of JavaScript

• Only a few data types to learn• Don’t need to worry about declarations• No type checking• Objects are a little convoluted• Easy to write, but at what cost?

Page 8: JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha, LiveScript, then JavaScript No apparent relation to Java.

Reliability of JavaScript

• Suffers due to lack of type checking• Really depends on what purpose the code

is for• Better used for less important tasks

Page 9: JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha, LiveScript, then JavaScript No apparent relation to Java.

Cost of JavaScript

• Very small if the team is already familiar with Java or C++

• Does not need to compile• Does not require a lot of system resources

Page 10: JavaScript: An Analysis Michael Owen. Brief History Founded at NetScape by Brendan Eich Mocha, LiveScript, then JavaScript No apparent relation to Java.

Bottom Line

• Overall, a very good language• Does a lot of things right• Does one thing very wrong