Chapter 1 Programming Languages. Application Development: Top 10 Programming Languages to Keep You Employed 1. Java 2. C# 3. C++ 4. JavaScript 5. Visual.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Chapter 1: Computer Systems
Programming Languages
Programming with Java. Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: –Understand the.
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
1 Kursusform  13 uger med: Undervisning i klassen 1,5-2 timer Opgave ”regning” i databar (løsninger på hjemmeside) En midtvejsopgave der afleveres og.
The Java Programming Language
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
Outline Java program structure Basic program elements
Chapter 1 Introduction. © 2004 Pearson Addison-Wesley. All rights reserved1-2 Outline Computer Processing Hardware Components Networks The Java Programming.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Chapter 1 Introduction.
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Java: Chapter 1 Computer Systems Computer Programming II Aug
Chapter 1 Introduction.
Prepared by Uzma Hashmi Instructor Information Uzma Hashmi Office: B# 7/ R# address: Group Addresses Post message:
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley John Lewis, Peter DePasquale, and Joseph Chase Chapter 1: Introduction.
© 2004 Pearson Addison-Wesley. All rights reserved August 22, 2007 Compiling and Compiler Errors ComS 207: Programming I (in Java) Iowa State University,
© 2006 Pearson Education Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science A 2nd Edition.
Chapter 1.4 Programming languages Homework Due: Monday, August 11, 2014.
Java: Chapter 1 Computer Systems Computer Programming II.
Java Language and SW Dev’t
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
Chapter 1 Introduction 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All rights reserved.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
The Java Programming Language
CSC204 – Programming I Lecture 4 August 28, 2002.
Introduction. Objectives An overview of object-oriented concepts. Programming and programming languages An introduction to Java 1-2.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Chapter 2: Java Fundamentals
Chapter 1: Introduction Java Programming Language How the Java Virtual Machine Works (compiling, etc…) Update by: Dan Fleck Coming up: The Java Programming.
Java The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since A programming.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
Lecture 2 Software Concepts Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
1 Problem Solving b The purpose of writing a program is to solve a problem b The general steps in problem solving are: Understand the problemUnderstand.
ZObject-Oriented Software Development yproblem solving yprogram design and implementation yobject-oriented concepts xobjects xclasses xinterfaces xinheritance.
Intro to Programming  Chapter 1 Part 2  Problem Solving.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Java.
Chapter 1 Introduction. 2 Focus of the Course Object-Oriented Software Development problem solving program design, implementation, and testing object-oriented.
WEEK 2 1 Software Concepts -- Introduction Now we can begin to examine the basic ideas behind writing programs Chapter 2 focuses on: history.
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
Introduction to Java Programming by Laurie Murphy Revised 09/08/2016.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Working with Java.
CSE 190D, Winter 2013 Building Java Programs Chapter 1
1.3 Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: Understand the problem Dissect the.
Unit 41 – Programing in Java
null, true, and false are also reserved.
Introduction to Java Programming
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Instructor: Alexander Stoytchev
Chapter 1: Computer Systems
Units with – James tedder
Compiling and Compiler Errors
Units with – James tedder
Instructor: Alexander Stoytchev
Java Software Solutions Foundations of Program Design 9th Edition
Focus of the Course Object-Oriented Software Development
Instructor: Alexander Stoytchev
Chap 2. Identifiers, Keywords, and Types
Presentation transcript:

Chapter 1 Programming Languages

Application Development: Top 10 Programming Languages to Keep You Employed 1. Java 2. C# 3. C++ 4. JavaScript 5. Visual Basic 6. Php 7. Objective C 8. Peral 9. Python 10. Ruby If you want to make money in programming what are the best languages to learn? What do you think are the top programming languages? Development/Top-10-Programming- Languages-to-Keep-You-Employed /

Where is Java?

Java Life Video

What is Java technology and why do I need it? Java is a programming language and computing platform first released by Sun Microsystems in Sun Microsystems was acquired by Oracle. It is the underlying technology that powers state- of-the-art programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices.

Where is Java? 1.1 billion desktops run Java 930 million Java Runtime Environment downloads each year 3 billion mobile phones run Java 31 times more Java phones ship every year than Apple and Android combined 100% of all Blu-ray players run Java 1.4 billion Java Cards are manufactured each year Java powers set-top boxes, printers, Web cams, games, car navigation systems, lottery terminals, medical devices, parking payment stations, and more.

8 Programming Language Levels Different Programming language levels: 1.machine language 1s and 0s (What the computer understands – binary code) 2.assembly language - low level step above machine. Still hard to code and understand. 3.high-level language – use English words for code. Easy to use. Each type of CPU has its own specific machine language that interprets the 1s and 0s. The other levels were created to make it easier for a human being to read and write programs so we can use English words to code. 1s and 0s were too hard!

9 Programming Languages A program must be translated into machine language before it can be executed on a particular type of CPU This can be accomplished in several ways A compiler is a software tool which translates source code into a specific target language Often, that target language is the machine language for a particular CPU type

10 Java is Unique The Java compiler translates Java source code into a special representation called bytecode Java bytecode is not the machine language for a particular CPU. Therefore the Java compiler is not tied to any particular machine or platform. An interpreter then coverts the bytecode to the language the machine understands. Therefore, Java is considered to be architecture-neutral and can run on PCs, Macs, Linux, anywhere.

IDE Programming languages must have a text editor called an Integrated Development Environment used to type the source code for the program. There are many integrated development environments for writing code. –Sun NetBeans –Borland JBuilder –MetroWerks CodeWarrior –Microsoft Visual J++ –IBM Eclipse –Monash BlueJ –Dr. Java

How does it work When we download Java, we don’t see it. It is a considered a virtual machine. To communicate we use an integrated development environment (in our case Dr. Java) which is a text editor where we type our code. Our code has to converted to 1s and 0s. Java has a compiler that converts code to bytecode. This is why it can be used on any platform (windows, linux, mac). Then the interpreter will convert it to the 1s and 0s for that particular platform. Steps: 1. Write a program using an IDE in Java source code. 2. Compile it (Java has a compiler which will convert it to bytecode which is platform independent.) 3. An interpreter then converts it to 1s and 0s for the platform it is on. (when we hit run) When you write, compile and run you have 3 files. Source file, java file, class file. Only the source file will open. The others are for execution by the compiler and interpreter.

Summary for IDE Integrated Development Environment is used to type java source code. It contains an editor, compiler and an interpreter and debugger in one package. The source code is compiled (by a compiler) into code called bytecode. A java interpreter converts the bytecode into instructions for that particular CPU.

Dr. Java as our IDE Dr. Java is a simple editor tool for entering program text and interaction space so that you can try things out in Dr. Java and crate new programs. Free under the DrJava Open Source License.

DrJava Features Works with multiple files –Files pane Color coded editor –Definitions pane Interpretation of Java code –Interactions pane Integrated debugger Files pane Interactions pane Definitions pane

How to use the console pane If you click on the console tab –You will see the console pane It shows just the items that you have printed to the console –Using System.out.println or –System.out.print

Open Dr. Java Files Pane – List the open files in Dr. Java Definitions pane – This is where you write your classes. Simply a text editor. You compile all current files open in the files pane b y clicking on the compile all Interactions Pane – You can type commands and it will execute but not save.

Java A programming language specifies the words and symbols that we can use to write a program called Syntax

Java Program Structure In the Java programming language: –A program is made up of one or more classes –A class contains one or more methods –A method contains program statements These terms will be explored in detail throughout the course A Java application always contains a method called main See Lincoln.java (page 27) Lincoln.java

20 Java Program Structure public class MyProgram {}{} // comments about the class class header class body Comments can be placed almost anywhere

21 Java Program Structure public class MyProgram {}{} public static void main (String[] args) {}{} // comments about the class // comments about the method method header method body

22 Comments Comments in a program are called inline documentation They should be included to explain the purpose of the program and describe processing steps They do not affect how a program works Java comments can take three forms: // this comment runs to the end of the line /* this comment runs to the terminating symbol, even across line breaks */ /** this is a javadoc comment */ They do not want you to use comments on your AP Exam

23 Identifiers – Identify yourself! Identifiers are the words a programmer uses in a program. Java looks for those words. An identifier can be made up of letters, digits, the underscore character ( _ ), and the dollar sign Identifiers cannot begin with a digit. They can only begin with an _ or a letter. Java is case sensitive - Total, total, and TOTAL are different identifiers By convention, Java programmers use different case styles for different types of identifiers, such as –title case for class names - Lincoln –upper case for constants (things that won’t change)- MAXIMUM

Reserved words as Identifiers Sometimes we choose identifiers ourselves when writing a program (such as Lincoln ) Sometimes we are using identifiers Java has created for special purposes. Those have special meaning so we can’t use those for our identifiers that we create. The identifiers reserved by Java are associated with methods and data created by Java that we don’t have to know about. (encapsulation). We just use them and they work.

25 Reserved Words The Java reserved words: abstract assert boolean break byte case catch char class const continue default do double else enum extends false final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws transient true try void volatile while

26 White Space Spaces, blank lines, and tabs are called white space White space is used to separate words and symbols in a program Extra white space is ignored A valid Java program can be formatted in many ways Programs should be formatted to enhance readability, using consistent indentation See Lincoln2.java (page 33)Lincoln2.java See Lincoln3.java (page 34)Lincoln3.java

27 Syntax and Semantics The syntax rules of a language define how we can put together symbols, reserved words, and identifiers to make a valid program The semantics of a program statement define what that statement means (its purpose or role in a program) A program that is syntactically correct is not necessarily logically (semantically) correct A program will always do what we tell it to do, not what we meant to tell it to do

Errors could be syntax or semantic Syntax – rules of a language –Java will not compile programs with syntax errors Semantics – How the program is put together. What will happen when it is executed. –Java will compile and run but results will not be correct.

Three kind of errors Compile time error – syntax error. Will not compile the program. Wrong syntax Runtime error – Will compile but will not run. It crashes during execution. Try to divide by 0 or index outbound in arrays Logical error – Will compile, Will run and print but produces the wrong output. (program is not put together correctly). Used wrong equation or steps in solving the solution.