300 likes | 797 Views
Java vs. Javascript. Jessi Style. Java. Compiled Can stand on its own Written once, run anywhere Two-stage debugging. Java is an Object Oriented Programming (OOP) language created by James Gosling of Sun Microsystems. Five Primary Goals.
E N D
Java vs. Javascript Jessi Style
Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming (OOP) language created by James Gosling of Sun Microsystems
Five Primary Goals It should be "simple, object-oriented and familiar” It should be "robust and secure” It should be "architecture-neutral and portable” It should execute with "high performance” It should be "interpreted, threaded, and dynamic"
Syntax Derived mainly from C++ Source files must be named after the public class they contain The compiler will generate a class file for each class defined in the source file The keyword public denotes that a method can be called from code in other classes The keyword static indicates that the method is associated only with the class and not with any specific instance of that class. The keyword void indicates that the main method does not return any value to the caller class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); // Display the string. } }
Javascript JavaScript is a scripting language that was created by Netscape, originally known as LiveScript • Most commonly used as part of web browsers • Also being used in server-side programming, game development and the creation of desktop and mobile applications • Supports much of the structured programming syntax from C • Functions are objects, which have properties and methods • Variables can be defined using var
Javascript Interpreted Must be placed inside an HTML document Different browsers Runtime-only debugging
Similarities • Object Oriented languages • Both can run in a browser • Both can run on a server • Both are influenced by the programming community • Both have libraries and frameworks
Object Oriented Programming • Language model organized around objects rather than actions • Terminology- • Class: Defines the characteristics of the Object • Object: An Instance of a Class • Property: An Object characteristic, such as color • Method: An Object capability, such as walk • Package: a namespace for organizing classes and interfaces in a logical manner • Inheritance: A Class can inherit characteristics from another Class
Libraries and Frameworks • Help programmers by providing access to general and purpose-specific code that can be reused over and over again for different products Java • Struts • Tapestry • Maverick Javascript • jQuery • Prototype • MooTools
Resources • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript • http://www.seguetech.com/blog/2013/02/15/java-vs-javascript • http://www.htmlgoodies.com/beyond/javascript/article.php/3470971 • http://www.java.com/en/download/faq/java_javascript.xml
Questions • What is the difference between compiled and interpreted? • Compiled means the code is changed into bytecode which is not readable by humans and any Java Virtual Machine can run it. Interpreted is executed in the same syntax in which it is written • What is Object Oriented Programming? • Object-oriented programming is a programming paradigm that represents concepts as "objects" that have data fields (attributes that describe the object) and associated procedures known as methods. • How are Java and Javascript similar? • Refer to slide 7