Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1 Chapter 1 Programming Languages

2 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? http://www.eweek.com/c/a/Application- Development/Top-10-Programming- Languages-to-Keep-You-Employed- 719257/

3 Where is Java?

4

5 Java Life Video

6 What is Java technology and why do I need it? Java is a programming language and computing platform first released by Sun Microsystems in 1995. 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.

7 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 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 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 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.

11 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

12 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.

13 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.

14 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.

15 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

16 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

17 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.

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

19 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 20 Java Program Structure public class MyProgram {}{} // comments about the class class header class body Comments can be placed almost anywhere

21 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 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 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

24 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 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 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 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

28 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.

29 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.


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

Similar presentations


Ads by Google