H212 Introduction to Software Systems Honors

Similar documents
Lecture 1: Introduction

Chapter 13 Computer Programs and Programming Languages. Discovering Computers Your Interactive Guide to the Digital World

What is a programming language?

Programming Languages

CS 106 Introduction to Computer Science I

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

Software. Programming Language. Software. Instructor Özgür ZEYDAN. Bülent Ecevit University Department of Environmental Engineering

CSE 307: Principles of Programming Languages

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

CSCI 3136 Principles of Programming Languages

Evolution of the Major Programming Languages

History OOP languages Year Language 1967 Simula Smalltalk

C# and Other Languages

CMPT 183 Foundations of Computer Science I

How To Understand Programming Languages And Programming Languages

LAB4 Making Classes and Objects

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

Principles of Programming Languages Topic: Introduction Professor Louis Steinberg

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

1/20/2016 INTRODUCTION

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

6.1. Example: A Tip Calculator 6-1

Java applets. SwIG Jing He

Java CPD (I) Frans Coenen Department of Computer Science

Chapter 1. Introduction to Computers, Programs, and Java

Install Java Development Kit (JDK) 1.8

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

Introduction to Software Paradigms & Procedural Programming Paradigm

1.1 WHAT IS A PROGRAMMING LANGUAGE?

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Discovering Computers Fundamentals, 2010 Edition. Living in a Digital World

1. Overview of the Java Language

CSC Software II: Principles of Programming Languages

Software Paradigms (Lesson 1) Introduction & Procedural Programming Paradigm

Chapter 1. Dr. Chris Irwin Davis Phone: (972) Office: ECSS CS-4337 Organization of Programming Languages

Programming in Python. Basic information. Teaching. Administration Organisation Contents of the Course. Jarkko Toivonen. Overview of Python

Announcements FORTRAN ALGOL COBOL. Simula & Smalltalk. Programming Languages

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution

Chapter 13: Program Development and Programming Languages

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

n Introduction n Art of programming language design n Programming language spectrum n Why study programming languages? n Overview of compilation

Chapter 5 Names, Bindings, Type Checking, and Scopes

Instructor Özgür ZEYDAN BEU Dept. of Enve. Eng. CIV 112 Computer Programming Lecture Notes (1)

McGraw-Hill The McGraw-Hill Companies, Inc.,

CSE 130 Programming Language Principles & Paradigms

GUI and Web Programming

CSC230 Getting Starting in C. Tyler Bletsch

Contents. Java - An Introduction. Java Milestones. Java and its Evolution

Fundamentals of Programming Languages

On the (un)suitability of Java to be the first programming language

ECE 122. Engineering Problem Solving with Java

Syllabus for CS 134 Java Programming

Chapter 1 Introduction to Computers, Programs, and Java

Ch. 10 Software Development. (Computer Programming)

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

The Application of Visual Basic Computer Programming Language to Simulate Numerical Iterations

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Functional Programming

Programming in Java Course Technology, a part of Cengage Learning.

LONG BEACH CITY COLLEGE MEMORANDUM

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Welcome to Introduction to Computers and Programming Course using Python

Asogwa Tochukwu Chijindu Department of Computer Engineering, Enugu State University of Science and Technology(ESUT), Enugu, Nigeria.

Programming Languages CIS 443

Introduction to Programming

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Levels of Programming Languages. Gerald Penn CSC 324

Lab 1A. Create a simple Java application using JBuilder. Part 1: make the simplest Java application Hello World 1. Start Jbuilder. 2.

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

THE ROLE OF PROGRAMMING PARADIGMS IN THE FIRST PROGRAMMING COURSES. 1. Introduction

Good FORTRAN Programs

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

C Compiler Targeting the Java Virtual Machine

Introductory programming languages at Australian. universities at the beginning of the twenty first century

Introduction to Python

Fundamentals of Java Programming

02 B The Java Virtual Machine

AP Computer Science Java Mr. Clausen Program 9A, 9B

C H A P T E R Regular Expressions regular expression

Fourth generation techniques (4GT)

ATSBA: Advanced Technologies Supporting Business Areas. Programming with Java. 1 Overview and Introduction

Chapter 3. Input and output. 3.1 The System class

Java Basics: Data Types, Variables, and Loops

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Introduction to programming

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

Solar Power Systems Web Monitoring

The Context of Software Development

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

Moving from CS 61A Scheme to CS 61B Java

Software: Systems and Application Software

Parameter passing in LISP

Java Crash Course Part I

RARITAN VALLEY COMMUNITY COLLEGE ACADEMIC COURSE OUTLINE. CISY 105 Foundations of Computer Science

Programmierpraktikum

Transcription:

Introduction to Software Systems Honors Lecture #02: First program in Java Fall 2015 1/26

Programming: early days First steps: Isolated individuals, skillful enough to produce a piece of software Languages: Assembly, Fortran, Cobol, Basic Used a lot of GOTO instructions, which resulted in hard to understand spageti code Fortran was developed between 1954-1956 by John Backus at IBM. The main innovations: use of mathematical notation in expressions subroutines arrays, formatted input and output. A lot of Fortran software is still in use. 2/26

C Over the time, hardware became widely available and the demand for software soared. C language was a major step in creating structured software and improving the productivity of the programming teams. Major programming language in 1980s. 3/26

Also called procedural approach to software design. Structured programming The software is organized around the notion of procedures (subroutines or functions). A procedure is called with some inputs, it returns values. Software consists of main program, procedures, sub procedures and sub-subprocedures. Main Sub 1 Sub 2 Sub 3 Sub 11 Sub 12 Sub 21 Sub 22 Sub 31 4/26

Procedures and data The procedures pass data to each other. Procedures and data are clearly separated. Call with input parameters Returns results Procedure A Access to data Data Call with input parameters Returns results Procedure B Access to data 5/26

Procedural abstraction When you call a procedure you don t care about what is inside the procedure, you are just interested in what comes out. The abstraction of the inner details of a procedure was a powerful procedural abstraction because you could change a procedure, or even replace it as long as in and out parameters stay the same. This was the understanding of abstraction before object orientation came in the late 80 s and early 90s. 6/26

Complex data Procedures and procedural abstraction worked fine when you deal with simple data, like integers, strings or even arrays. But data became quite complex, records or structures were introduced. It became like a mess where all procedures access the complex data all over the place. And the procedures were hard to reuse. 7/26

Need for something new With the increase of software size and complexity, structured programming was pushed to the limits. At certain size, a program becomes so complex that a programmer could not grasp the whole picture. Eventually, structured programming languages could not manage software complexity. There was a need for something new, which could give programmer tools to handle complexity. 8/26

Object oriented idea OO idea was to organize programs around data and to encapsulate them into a single entity. Program Program Program Program data Program Program Program Program 9/26

Object oriented approach Organization of programs around data gave rise to a concept of the class. In programs you represent the data with classes; the procedures are put in the classes. This helps simplify the overall structure of the system, as we are able to develop complex systems but at the same time maintain the understandability of programs. 10/26

Object oriented language: C++ C++ was invented by Bjarne Stroustrup in 1979, while he was working at Bell Laboratories in Murray Hill, New Jersey. C++ added features that allow programmers to comprehend and manage larger programs. But, soon C++ was not able to meet the challenges of the new era of computing. Why did we need another OO programming language? World Wide Web and the Internet came in, reached critical mass, and required a new tool. 11/26

Object oriented language: Java Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc. in 1991. Originally, Java was not invented for the Internet! The primary motivation was the need for a platform-independent language that could be used to create software to be embedded in various consumer electronic devices. About the time when Java was worked out, the World Wide Web emerged and played a crucial role in the future success of Java. 12/26

What influenced programming languages Hardware Imperative languages model changes in state (e.g., in the values in registers, memory, and on disk). Languages - Algol 60, C, C++, Java, Pascal, Perl, Python, Parallel machines - there are languages for parallel computing Mathematics Lambda calculus - LISP Functional languages view programs as functions - ML, Scheme, LISP: characterized by use of higher-order functions Logic programming view programs as mathematical proofs: a program computes by trying to prove a theorem - Prolog 13/26

Influences Programming Methodology 1960s - larger and larger systems 1970s - top-down design - Pascal late 1970s, early 80s - data-oriented design (ADTs) Ada and Modula 1980s - object-oriented design - C++, Smalltalk 1990s - concurrency; graphics; libraries - Java 2000s - automatic storage management; security; vast amounts of code, good and bad to follow as examples throughout - increasing trend to use of types finally - make the computer do more of the work Special purpose languages Visual languages for designing user interfaces - Visual Basic Markup Languages - HTML, XML, SGML 14/26

Criteria for Evaluating Languages Readability, writeability, reliability, maintainability, security,... Cost: Training. Writing. Compilation (in terms of time and size of produced code) Execution. A dominant cost in some applications. Often, optimization can reduce the cost, at the expense of increasing the cost of compilation/writing/and or training. Language implementation - is the compiler free? Reliability - Failure in produced code/run-time environment can be very costly, think of a program running an X-ray machine. Maintenance - Useful code is always refined, updated, debugged. This cost can overshadow development cost. 15/26

Programming language Java Java was initiated in 1991 by James Gosling at Sun Microsystems as a set-top box project. Java was introduced to the public in 1995 and has gained tremendous popularity since. There are variations of the Java Platform, including the Standard Edition, which is the mainstream version of the language and the associated tools. Java is an object-oriented programming language. Objects are fundamental elements that make up a program. We will explore object-oriented programming concepts by using Java. The Java is accompanied by a library of extra software that we can use when developing programs. This software is referred to as the Java API (Application Programmer Interface) or the standard class library. We will use DrJava development environment for writing Java programs. It is easy to use and provides and intuitive interface and ability to interactively evaluate Java code. 16/26

Download DrJava 17/26

Run DrJava 18/26

A simple program in Java public class Test01 { public static void main (String[] args) { System.out.print( "Hello, world! ); } } You have to save and compile the program. After that you will be able to run it. To save the program, choose a working directory. Execution of a Java program starts with main method, each statement is the main is executed one at a time in sequential order. When the execution reaches the end, the program ends (terminates). > run Test01 Hello, world!> 19/26

Program syntax public class Test01 { public static void main (String[] args) { System.out.print( "Hello, world! ); } } Print statement. The argument is a character string. This is a class. Class name main is entry point main can be called without instantiating the class Semicolon required! IDE color codes the words of the program. 20/26

Different ways to print public class Test01 { public static void main (String[] args) { System.out.print( "Hello, world! ); } } Change the print statement: System.out.print("Hello! ); Hello!> System.out.print("Hello! ); System.out.print("Hello! ); System.out.print("Hello! ); Hello!Hello!Hello!> System.out.println("Hello! ); System.out.println("Hello! ); Hello! Hello! > 21/26

Comments //------------------------------------------------------ // This is my first Java program //------------------------------------------------------ /* Author: Vel Malbasa Date: August 26, 2015 Version: 01 */ public class Test01 { public static void main (String[] args) { System.out.print( "Hello, world! ); } } Comments are important for documenting the program. 22/26

Identifiers and reserved words Identifiers are words used to write a program. Three types of words: Words that we make up (Test01) Words that are in other programs (System, println) Reserved words (class, public, static, void) have special meanings Java is case sensitive. An identifier can not begin with digit. Choose meaningful identifiers! Think about another person reading your program. 23/26

Formatting Have your program look readable. Use the elements of a program that are ignored by compiler: Comments to document the code Blank lines to separate blocks of code Indentation to make a block of code stand out White spaces to increase readability of code 24/26

Argument can be evaluated class Divide { public static void main(string[] args) { System.out.println( 3 / 2 ); } } What will this program print? Arguments 3 and 2 are integers, the program will make an integer division, and the result will be an integer. 25/26

Java can make GUI import javax.swing.jframe; class MyFrame { public static void main(string[] args) { JFrame f = new JFrame(); f.setvisible(true); f.setsize(300, 500); System.out.println( f ); } } The program will create a frame on the screen. > run MyFrame javax.swing.jframe[frame0,0,0,300x500,invalid,lay out=java.awt.borderlayout,title=,resizable,normal,defaultcloseoperation=hide_on_close,rootpane=jav ax.swing.jrootpane[,8,31,124x0,layout=javax.swing.jrootpane$rootlayout,alignmentx=0.0,alignmenty=0.0,border=,flags=16777673,maximumsize=,minimumsiz e=,preferredsize=],rootpanecheckingenabled=true] 26/26