Java: A Comprehensive Introduction to the Programming Language in CS-506, Lecture notes of Web Design and Development

An introduction to the java programming language in the context of cs-506, web design & development. It covers the design goals of java, its buzzwords, language features, libraries, and benefits such as simplicity, object-oriented nature, distributed capabilities, robustness, security, portability, high-performance, and multi-threading. Java's compiler structure and programmer efficiency are also discussed.

Typology: Lecture notes

2011/2012

Uploaded on 11/10/2012

taariq
taariq 🇵🇰

4.4

(16)

61 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Web Design & Development CS-506
- 1 -
HAND OUTS
WEB DESIGN AND DEVELOPMENT
pf3
pf4
pf5

Partial preview of the text

Download Java: A Comprehensive Introduction to the Programming Language in CS-506 and more Lecture notes Web Design and Development in PDF only on Docsity!

HAND OUTS

WEB DESIGN AND DEVELOPMENT

Java Features

This handout is a traditional introduction to any language features. You might not be able to comprehend some of the features fully at this stage but don’t worry, you’ll get to know about these as we move on with the course

Design Goals of Java

The massive growth of the Internet and the World-Wide Web leads us to a completely new way of looking at development of software that can run on different platforms like Windows, Linux and Solaris etc.

Right Language, Right Time

ƒ Java came on the scene in 1995 to immediate popularity.

ƒ Before that, C and C++ dominated the software development

  • compiled, no robust memory model, no garbage collector causes memory leakages, not great support of built in libraries

ƒ Java brings together a great set of "programmer efficient" features

  • Putting more work on the CPU to make things easier for the programmer.

Java – Buzzwords (Vocabulary)

ƒ From the original Sun Java whitepaper: " Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high- performance, multi-threaded, and dynamic language. "

ƒ Here are some original java buzzwords...

Java -- Language + Libraries

ƒ Java has two parts...

  1. The core language -- variables, arrays, objects
    • The Java Virtual Machine (JVM) runs the core language
    • The core language is simple enough to run on small devices -- phones, smart cards, PDAs.

checking. (Or put the other way, C can be faster since it doesn't check anything.)

ƒ The JVM "verifier" checks the code when it is loaded to verify that it has the correct structure -- that it does not use an uninitialized pointer, or mix int and pointer types. This is one-time "static" analysis -- checking that the code has the correct structure without running it.

ƒ The JVM also does "dynamic" checking at runtime for certain operations, such as pointer and array access, to make sure they are touching only the memory they should. You will write code that runs into

ƒ As a result, many common bugs and security problems (e.g. "buffer overflow") are not possible in java. The checks also make it easier to find many common bugs easy, since they are caught by the runtime checker.

ƒ You will generally never write code that fails the verifier, since your compiler is smart enough to only generate correct code. You will write code that runs into the runtime checks all the time as you debug -- array out of bounds, null pointer.

ƒ Java also has a runtime Security Manager can check which operations a particular piece of code is allowed to do. As a result, java can run untrusted code in a "sandbox" where, for example, it can draw to the screen but cannot access the local filesystem.

Portable

ƒ "Write Once Run Anywhere", and for the most part this works.

ƒ Not even a recompile is required -- a Java executable can work, without change, on any Java enabled platform.

Support for Web and Enterprise Web Applications

ƒ Java provides an extensive support for the development of web and enterprise applications

ƒ Servlets, JSP, Applets, JDBC, RMI, EJBs and JSF etc. are some of the Java technologies that can be used for the above mentioned purposes.

High-performance

ƒ The first versions of java were pretty slow.

ƒ Java performance has gotten a lot better with aggressive just-in-time-compiler (JIT) techniques. ƒ Java performance is now similar to C -- a little slower in some cases, faster in a few cases. However memory use and startup time are both worse than C.

ƒ Java performance gets better each year as the JVM gets smarter. This works, because making the JVM smarter does not require any great change to the java language, source code, etc.

Multi-Threaded

ƒ Java has a notion of concurrency wired right in to the language itself.

ƒ This works out more cleanly than languages where concurrency is bolted on after the fact.

Dynamic

ƒ Class and type information is kept around at runtime. This enables runtime loading and inspection of code in a very flexible way.

Java Compiler Structure

ƒ The source code for each class is in a .java file. Compile each class to produce “.class” file.

ƒ Sometimes, multiple .class files are packaged together into a .zip or .jar "archive" file.

ƒ On unix or windows, the java compiler is called "javac". To compile all the .java files in a directory use "javac *.java".

Java: Programmer Efficiency

ƒ Faster Development