230 likes | 478 Views
Java Buzzwords. Java!. Java is a language characterized by buzzwords buzzword: A trendy word or phrase that is used more to impress than explain From Sun Microsystems , the developers of Java: What do all of those terms mean?. “Java is a simple, object-oriented, distributed,
E N D
Java! • Java is a language characterized by buzzwords • buzzword: A trendy word or phrase that is used more to impress than explain • From Sun Microsystems, the developers of Java: • What do all of those terms mean? “Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.”
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamiclanguage.” • A programming language • a vocabulary and set of syntactical (grammatical) rules for instructing a computer to perform specific tasks • you can do most anything in any programming language • a particular language encourages one to do things in a certain way • Question: Is this a fair characterization?
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • Based on popular languages called C and C++ • C: old, pretty bare bones language • C++: newer, more complicated language • Start from C and add some of C++’s more useful features “Java omits many rarely used, poorly understood, confusing features of C++ that in our experience bring more grief than benefits” (Gosling) • Question: Is Java really all that simple?
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • The object-oriented paradigm • problems and their solutions are packaged in terms of classes • the information in a class is the data • the functionality in a class is the method • a class provides the framework for building objects • Object-oriented programming (OOP) allows pieces of programs to be used in other contexts more easily
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • A distributed system is one where multiple separate computer systems are involved • the Internet is a very large distributed system • interconnected collection of computer networks • heterogeneous components • large number of services: WWW, file services, audio/video channels • Java was designed for the web
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • Java a high-level language • High-level languages must be translated to a computer’s native tongue, machine language • Interpreted high-level languages are translated to an intermediate form and then converted to machine language and run • Java bytecodes • bytecode (class) file is executed by a Java bytecode interpreter
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • Programs will have errors, but a good program degrades reasonably • A robust program may not do exactly what it is supposed to do, but it should not bring down other unrelated programs down with it • Reliability • early (compile time) checking • dynamic (runtime) checking • eliminating situations that are error prone.
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • Security • techniques that ensure that data stored on a computer cannot be read or compromised • Java is intended for use in networked/distributed environments • a program is running on your computer … what is to stop it from erasing all of your data, accidentally or otherwise? • Java enables the construction of virus-free, tamper-free systems • authentication based on public-key encryption
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • A language is architecture-neutral if it does not prefer a particular type of computer architectures • Example: • not too hard to construct a program that will run faster on a Macintosh than on a PC, and vice-versa • each have their own respective strengths and weaknesses • A particular program is never entirely architecture neutral though • Question: When is being architecturally neutral a bad thing?
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • Program once, run anywhere • A program is portable if it will work the same (more or less) on many different computer systems • platform-independent • Much effort is currently spent porting non-portable code • Java has no "implementation dependent" aspects • HTML is also portable or platform-independent
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • Performance: speed in completing some task • performance is everything to most computer and software manufacturers! • Think about this … • if the transportation industry kept up with the computer industry, one would be able to now buy a Rolls Royce that could drive across country in 5 minutes for $35 • However … • it would crash once a week, killing everyone on board
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • A thread is a part of the program that can operate independently of its other parts • Multi-threaded programs can do multiple things at once • example: • download a file from the web while still looking at other web pages • Question: What is the problem with multiple agents working at the same time? • synchronization
“Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” • Dynamic: actions that take place at the moment they are needed rather than in advance • antonym: static • A dynamic program can • ask for more or less resources as it runs • use the most recent version of some code that is available • Question: Why is being dynamic a good thing? • upgrades
Trees • Hierarchical data structure • Set of elements or nodes • one node as root • every other node has a single predecessor (parent) and zero or more successors (children) • nodes without successors are called leaf nodes • Nodes are connected by edges • The level or depth of a node is the number of edges on the path to the root • The depth of the tree is the number of edges on the longest path from root to any leaf • A complete tree has all leaves at same level, all other nodes have the same number of children
root depth of tree = 3 edge leaf Example tree structure leaf leaf leaf leaf leaf
Decision trees • A decision tree begins with a decision you need to make • start with an initial decision node • ask a question • Structure for investigating options and the possible outcomes of choosing those options • result of a decision can be another decision • outcome is a terminal node • Tree should have unique paths from the decision node to each of the terminal nodes. • help you to choose between several courses of action
Examples • Real life decision trees • which route to take to class? • which {cell phone, computer, camera} is best for me? • what to wear? • where to go on vacation?
He received the Physics Prize in 1921. Would you like to read about Einstein? Try the Medicine Prize in 1962. Would you like to read about a scientist? Look up the Peace Prize in 1991. Would you prefer a humanitarian? Try A. Solzhenitsyn, Literature 1970. A Decision Tree yes yes no yes no no
yes no a b c a c? yes no a c b c a b A decision tree for sorting a b? no yes b c? a c? yes no b a c b c? yes no b c a c b a
Binary trees • Nodes have at most two children • In a complete binary tree of depth 3, • how many nodes are in the tree? • how many leaves are in the tree? • In a complete binary tree of depth 4, • how many nodes are in the tree? • how many leaves are in the tree? • How many nodes in a depth d tree? • How many leaves in a depth d tree?