Cs205: engineering software university of virginia fall 2006 Introducing Java David Evans www.cs.virginia.edu/cs205 Don’t forget to email your registration.

Slides:



Advertisements
Similar presentations
In Review JAVA C++ GUIs - Windows Webopedia.com.
Advertisements

David Evans CS201j: Engineering Software? University of Virginia Computer Science Lecture 2: Java Semantics, Validation.
Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Java Basic Training HaiNH - FQA. Agenda Introduction to Java Java Programming Environment Language Fundamental Object Oriented Programming with Java.
Lab#1 (14/3/1431h) Introduction To java programming cs425
Java Array, Game of Life Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Cs2220: Engineering Software Class 2: Introduction Java Fall 2010 University of Virginia David Evans.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
1 Are you ready?. 2 Professor: Vladimir Misic Office : Phone: Office Hours : Mon, Tue; 2:00pm – 4:00pm Website :
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
Computer Programming 12 Mr. Jean March 3 rd, 2014.
Chapter 1 Coding Introduction.
+ 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.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Advanced Java New York University School of Continuing and Professional Studies.
Cs205: engineering software university of virginia fall 2006 Validation David Evans
Java Beserkers Group 4. Start of Java Development began on June of 1991 by a group of computer scientist at the Sun Mircrosystems Company Development.
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Cs205: engineering software university of virginia fall 2006 Data Abstraction David Evans
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004.
Class 14: Object-Oriented Programming Fall 2010 University of Virginia David Evans cs2220: Engineering Software.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
Introduction To JAVA By Ihtesham Ul Haq. Course Objectives Upon completing the course, you will understand Upon completing the course, you will understand.
Chapter 2: A Brief History Object- Oriented Programming Presentation slides for Object-Oriented Programming by Yahya Garout KFUPM Information & Computer.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 3: Levels of Abstraction
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
1 The JAVA Language Object Oriented Technology Mithani Binjan M.
Java L1 Array Prof. Sin-Min Lee Department of Computer Science San Jose State University.
What is Java? Object Oriented Programming Language Sun Microsystems “Write Once, Run Everywhere” Bytecode and Virtual Machine Java Platform (Java VM and.
Introduction Mehdi Einali Advanced Programming in Java 1.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Cs2220: Engineering Software Class 13: Behavioral Subtyping Fall 2010 University of Virginia David Evans.
David Evans CS201J: Engineering Software University of Virginia Computer Science Lecture 5: Implementing Data Abstractions.
Cs205: engineering software university of virginia fall 2006 David Evans Object-Oriented Programming.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 15: Java Basics Fundamentals of Web Programming.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Chapter 1 Coding Introduction.
COMP 2100 From Python to Java
Done By: Ashlee Lizarraga Ricky Usher Jacinto Roches Eli Gomez
Chapter No. : 1 Introduction to Java.
David Evans Lecture 1: Engineering Software, Constructing Poetry and Dancing about Architecture CS201j: Engineering Software?
CS216: Program and Data Representation
PROGRAMMING IN JAVA. INTRODUCTION TO JAVA  Java is a general purpose computer programming language that is concurrent, class-based, object- oriented.
Chapter 1 Coding Introduction.
Concurring Concurrently
Security in Java Real or Decaf? cs205: engineering software
Data Abstraction David Evans cs205: engineering software
Sridhar Narayan Java Basics Sridhar Narayan
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
Lecture 4: Data Abstraction CS201j: Engineering Software
(Computer fundamental Lab)
Java History, Editions, Version Features
By Rajanikanth B Overview Of Java By Rajanikanth B
Introducing Java.
Lecture 2: Java Semantics, Validation CS201j: Engineering Software?
Presentation transcript:

cs205: engineering software university of virginia fall 2006 Introducing Java David Evans Don’t forget to your registration survey – if you haven’t yet, please do it today

2 cs205: engineering software Course Announcements Assistant Coaches: Drew Abott and Dan Marcus –Lab hours: after class today, Sunday 7- 8:30pm Office Hours –Posted time conflicts with cs202 –New time is 10:30-noon on Thursdays –My door is almost always open – feel free to stop by outside of office hours

3 cs205: engineering software Why so many programming languages?

4 cs205: engineering software Fundamental Differences All equivalently powerful! –Universal languages: all capable of simulating each other Fundamental differences –Expressiveness: how easy it is to describe a computation –“Truthiness”: likelihood that a program means what a programmer things it means –Safeness: impact of programmer mistakes There is usually a conflict between expressiveness and truthiness/safeness

5 cs205: engineering software Pragmatic Differences Performance of available compilers, interpreters Tools available Libraries Portability Availability/cost of programmers

6 cs205: engineering software What is Java? A.Island in Indonesia known for coffee and volcanoes B.A Programming Language (Java) C.A Portable Low-Level Language (JVML) D.A Platform (JavaVM) E.A (semi-)successful marketing strategy –JavaScript is not related to Java or Java F.All of the above

7 cs205: engineering software Java History 1991: “Stealth Project” formed at Sun –Computing for consumer electronics market James Gosling tasked with selecting a programming language for project –Started with C++, but found inadequate In later classes, we’ll talk about why –Developed extensions and subtractions that led to new language “Oak” 1993: Web arrives 1995: Sun releases HotJava browser and Java PL, Netscape incorporated into browser

8 cs205: engineering software Buzzword Description “A simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high- performance, multithreaded, and dynamic language.” [Sun95] Later in the course, we will discuss how well it satisfies these “buzzwords”.

9 cs205: engineering software Non-Buzzword Description Java sacrifices expressiveness for safety and “truthiness” –A Java program is ~5x larger than the corresponding Scheme or Python program Java sacrifices performance for safety and “truthiness” –A Java program is ~2x slower than the corresponding C program (but 5x faster than the corresponding Scheme/Python program) Caveat: these numbers are “guesses” and gross simplifications. Real numbers depend on the program (and programmer!).

10 cs205: engineering software Java Programming Language Syntax –Similar to C++ –Designed to be easy for C and C++ programmers to learn Semantics (what programs mean) –Similar to Scheme –Designed to make it easier to reason about properties of programs

11 cs205: engineering software Programming Systems Scheme Interpreter Scheme Program C++ Compiler C++ Program Machine Object Files

12 cs205: engineering software Portability –If you can implement a Java VM on your machine, then you can run all Java programs Security –A VM can limit what programs can do to the real machine Simplicity –VM instructions can be simpler than machine instructions Java VM Java Compiler Java Program Java Virtual Machine Class Files Machine Why use a virtual machine?

13 cs205: engineering software Programming in Java Program is composed of classes A class: –Defines a new datatype –Defines methods and state associated with that datatype We call a value of a class datatype an object –Objects package state and code

14 cs205: engineering software // CS205 Fall 2006 // CellState.java public class CellState { // OVERVIEW: A CellState is an immutable object that represents // the state of a cell, either alive or dead. private boolean alive; private CellState(boolean isalive) // EFFECTS: Initializes this to alive if isalive is true, // otherwise initializes this to the dead state. { this.alive = isalive; }... Comments: // to end of line instance variable: state of this object constructor A Java Class

15 cs205: engineering software Types Every entity in a Java program has a type –Primitive types: int, char, boolean, etc. –Object types: all classes Variables are declared with a type Compiler checks and requires type correctness boolean alive; CellState state; // in Cell.java

16 cs205: engineering software // CS205 Fall 2006 // CellState.java public class CellState { // OVERVIEW: A CellState is an immutable object that represents // the state of a cell, either alive or dead. private boolean alive; private CellState(boolean isalive) // EFFECTS: Initializes this to alive if isalive is true, // otherwise initializes this to the dead state. { this.alive = isalive; }... Visibility Modifiers public : any code can read and modify private : only accessible inside class How do these help manage complexity?

17 cs205: engineering software private CellState(boolean isalive) // EFFECTS: Initializes this to alive if isalive is true, // otherwise initializes this to the dead state. static public/* nonnull */CellState createAlive() // EFFECTS: Returns an alive cell state. { return new CellState(true); } static public/* nonnull */CellState createDead() // EFFECTS: Returns a dead cell state. { return new CellState(false); } public Color getColor() // EFFECTS: Returns the display color for this state { if (alive) return Color.green; else return Color.white; }

18 cs205: engineering software ExtremeLifeCell Class public class ExtremeLifeCell extends Cell { public CellState getNextState() // EFFECTS: Returns the next state for this cell. // The next state will be alive if this cell or any of its neighbors is currently alive. { Enumeration neighbors = getNeighbors(); while (neighbors.hasMoreElements()) { SimObject neighbor = neighbors.nextElement(); if (neighbor instanceof Cell) { Cell cell = (Cell) neighbor; if (cell.isAlive()) { // If the cell has at least one neighboring cell that is alive, this cell becomes alive. return CellState.createAlive(); } // No alive neighbor found, next state is current state return getState(); } All this code is needed to walk through the list of neighbors! Hint: you probably will want the same code for ConwayLifeCell

19 cs205: engineering software Charge Problem Set 1 (Due Monday) –Lots of new concepts, but only a few lines of code –You are not expected to understand everything in the provided code (yet) –Take advantage of scheduled lab hours: Now Sunday, 7-8:30pm