CPS 001 5.1 Today’s topics Algorithms Java Syntax and Grammars Upcoming More Java Reading Great Ideas, Chapter 2.

Slides:



Advertisements
Similar presentations
compilers and interpreters
Advertisements

Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Grammars.
Java.  Java is an object-oriented programming language.  Java is important to us because Android programming uses Java.  However, Java is much more.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
Excerpts from Introduction to Java Programming, 4E Author: Y. Daniel Liang (Copyright by Prentice Hall)
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
Introduction to Java Programming, 4E
Chapter 16 Programming and Languages: Telling the Computer What to Do.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
Chapter 10 Application Development. Chapter Goals Describe the application development process and the role of methodologies, models and tools Compare.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.
Getting Started with Java
1 CS101 Introduction to Computing Lecture 19 Programming Languages.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
CS102 Introduction to Computer Programming
Computer Programming 12 Mr. Jean March 3 rd, 2014.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
CS 355 – Programming Languages
Grammars.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
CS101 Introduction to Computing Lecture Programming Languages.
CompSci Today’s topics Designing and Implementing Algorithms Problem solving Pseudocode Java Syntax and Grammars Upcoming More Java Acknowledgements.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
1 2. Program Construction in Java Programming Fundamentals.
Introduction to Java Programming with Forte Y. Daniel Liang.
1 Programming Fundamentals AITI-GP. 2 Introduction to Programming.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Compiling and the Java Virtual Machine (JVM). The syntax of Pseudocode is pretty loose –visual validation encourages a permissive approach –emphasized.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
Java Buzzwords.
Today’s topics Java Syntax and Grammars Sample Programs Upcoming More Java Reading Great Ideas, Chapter 2.
Introduction to Programming. The Programming Process Create/Edit Program Compile Program Execute Program Compile Errors?Run-Time Errors? Source Program.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
CS 106 Introduction to Computer Science I 01 / 22 / 2007 Instructor: Michael Eckmann.
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
Introduction to OOP CPS235: Introduction.
การเขียนโปรแกรมภาษา จาวา Java Programming อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 1.
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.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
Introduction to Java Programming, 4E Y. Daniel Liang.
How does a computer works Hyoungshick Kim Department of Computer Science and Engineering College of Information and Communication Engineering Sungkyunkwan.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Component 1.6.
Done By: Ashlee Lizarraga Ricky Usher Jacinto Roches Eli Gomez
CSCI-235 Micro-Computer Applications
Chapter 1 Introduction to Computers, Programs, and Java
Lecture 1: Introduction to JAVA
Introduction Enosis Learning.
Introduction Enosis Learning.
Introducing Java.
Chapter 10: Compilers and Language Translation
Presentation transcript:

CPS Today’s topics Algorithms Java Syntax and Grammars Upcoming More Java Reading Great Ideas, Chapter 2

CPS Java! l Java is a buzzword-enabled language l From Sun (the developers of Java), “Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.” l What do all of those terms mean?

CPS l 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 l A Question for the course: What makes a good language? “Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.”

CPS l Based on popular languages called C and C++ l C: old, pretty bare bones language l C++: newer, more complicated language l Start from C and add some of C++’s more useful features à From Gosling, the creator, “Java omits many rarely used, poorly understood, confusing features of C++ that in our experience bring more grief than benefits.” l 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.”

CPS l 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 l 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.”

CPS l A distributed system is one where multiple separate computer systems are involved à Electronic card catalogs à The web l Java was designed for the web l Question: What are examples of a distributed task in your lives? “Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.”

CPS l Java a high-level language l High-level languages must be translated to a computer’s native tongue, machine language l Interpreted high-level languages are translated to an intermediate form and then converted to machine language and run l Why? l We’ll learn more about this later “Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.”

CPS l Programs will have errors, but a good program degrades reasonably l 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 l Question: Give me an example of a non-robust program you have seen? “Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.”

CPS l Security: techniques that ensure that data stored on a computer cannot be read or compromised l A program is running on your computer. What is to stop it from erasing all of your data, accidentally or otherwise? l Question: Is Java really all that secure? “Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.”

CPS l A language is architecture-neutral if it does not prefer a particular type of computer architectures l E.g. The Macintosh processor family (PowerPC) and the PC (x86-Pentium) family have their own respective strengths and weaknesses. It is not too hard to construct a program that will run faster on one than an other. l A particular program is never entirely architecture neutral though l 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.”

CPS l A program is portable if it will work the same (roughly) on many different computer systems l HTML is also platform-independent or portable l A whole lot of effort is currently spent porting non-portable code “Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.”

CPS l Performance: speed in completing some task l Performance is everything to most computer and software manufacturers. l Story: à If the transportation industry kept up with the computer industry, one would be able to now buy a Roll Royce that could drive across country in 5 minutes for $35. l Rebuttal: à 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.”

CPS l A thread is a part of the program that can operate independently of its other parts l Multi-threaded programs can do multiple things at once à e.g. download a file from the web while still looking at other web pages l 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.”

CPS l Dynamic refers to actions that take place at the moment they are needed rather than in advance à Antonym: static l A dynamic program can à Ask for more or less resources as it runs à Use the most recent version of some code that is available l Question: Why is being dynamic a good thing? “Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language.”

CPS A Java Program import java.awt.*; public class HelloWorld extends java.applet.Applet { TextField m1; public void init() { m1 = new TextField(60); m1.SetText(“Hello World”); add(m1); }

CPS Definitions l Algorithm : ordered set of unambiguous executable steps, defining a terminating process l Program : instructions executed by a computer Applet : Java program that is executed in a program such as appletviewer or a Java-enabled web browser l Class : family of components sharing common characteristics consisting of: à Data : information à Method : functionality l Object : instance of a class l Variable : represent value stored in computer memory. A variable must be defined or declared before being used à Sometimes synonymous with object

CPS Grammar l English and other natural languages have structure => => | | => | => DOG | FLEAS | PERSON |... => RAN | BIT |... l Process of taking sentence and fitting it to grammar is called parsing DOG BIT PERSON l Parsing English is complex because of context dependence

CPS Formal specifications l Need a precise notation of syntax of a language l Grammars can be used for generation and also can be used l Context-free grammars => sequence of letters and/or digits that begins with a letter => guessB => msg42 l Substitute as many times as necessary. All legal statements can be generated this way  Want person = firstn + " " + lastn; à How do we get this from our grammar?

CPS Random Sentence Generator l C onstructs sentences, paragraphs, and even papers that fit a prescribed format. l The format is specified by a set of rules called a grammar l A grammar consists of a set of definitions l Each definition is a set of productions l Examples of grammars à Extension request à College rejection à Poem à l Natual languages have grammars =>

CPS Poem Grammar l All grammars begin with start rule { The tonight. ; } l Nonterminals are indicated by angle brackets { waves ; big yellow flowers ; slugs ; }

CPS More on the poem grammar l Nonterminals can refer to other nonterminals { sigh ; portend like ; } { warily ; grumpily and ; }

CPS Generating a poem à all sentences start with à There is only one production in the definition of The tonight. à Expand each grammar element from left to right à "The" is a terminal, so it is simply printed – à is a non-terminal, so it must be expanded à Choose one: waves big yellow flowers slugs à Suppose that 'slugs' is chosen

CPS Generating a poem The slugs tonight. à - is a non-terminal, so it must be expanded – à Choose one: 1.sigh 2.portend like The slugs sigh tonight. à is a non-terminal, so it must be expanded 1.warily 2.grumpily The slugs sigh grumpily tonight. à "tonight." is a non-terminal so it is simply printed à There are no more non-terminals to expand! à The grammar has generated a complete poem