Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 An intro to programming

2 The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding problem or opportunity.  Breaking the problem into manageable pieces (decomposing).  Designing a solution.  Considering alternatives to the solution and refining the solution.  Implementing the solution.  Testing the solution and fixing the problems.

3 What is a program? A program is computer coding that: Takes input Performs some calculation on the input Displays output

4 What is a program? A program is… –A collection of statements –Written in a programming language –A specification of the steps taken to solve a problem Programs have grammar rules –Specify how the statements are formed –How the statements are combined

5 Writing programs You need: –Knowledge of a coding language –Problem solving skills –Familiarity with analysis and design process –Software development tools

6 Programming Language Hierarchy

7 The highs and lows of programming languages... High-Level Language (HLL) –closest to natural language –words, numbers, and math symbols –not directly understood by hardware –“portable” source code (hardware independent) –Java, C, C++, COBOL, FORTRAN, BASIC, Lisp, Ada, etc. Machine Language (lowest level) –least natural language for humans, most natural language for hardware –just 0s and 1s –directly understood by hardware –not portable (hardware dependent) In order for a program to run on a computer, it must be in that computer’s machine language. Each type of CPU has it’s own language.

8 Getting from Source to Machine Code “Compiling a program” translating from a high-level language source code to machine (object, or executable) code. “Compiler” a program that translates HLL source code to machine (object, or executable) code. “Assembly” translating from assemble language source code to machine (object, or executable) code. “Assembler” a program that translates assembly source code to machine (object, or executable) code. Compilers need to know the specific target hardware

9 Compilers vs. Assemblers vs. Interpreters Compilers and Assemblers –translation is a separate user step –translation is “off-line,” i.e. not at run time Interpreters - another way to translate source to object code –interpretation (from source to object code) is not a separate user step –translation is “on-line,” i.e. at run time Source Code

10 Java Program Translation Both Compilation and Interpretation Intermediate Code: “Byte Code” –portable low-level code –similar to assembly code, but hardware independent –invisible to Java programmer Interpreter translates from generic byte code to hardware-specific machine code Java Program Data for Java Program Java Compiler Byte-Code Program Byte-Code Interpreter Machine-Language Instructions Computer Execution of Machine-Language Instructions Output of Java Program Java Virtual Machine

11

12 1 Basic Program Development errors Edit and save program Compile program Execute program and evaluate results

13 The Java Software Development Kit (SDK) Can be downloaded free from Sun website. a development environment for building applications, applets, and components using the Java programming language These tools are designed to be used from the command line. Except for the appletviewer, these tools do not provide a G raphical U ser I nterface

14 Java Java was released in 1995 by Sun Microsystems. It is written in the language C++. Java is platform-independent, object-oriented, and easy to use on the Internet.

15 STOP

16 A closer look at Java SDK and JCreator IDE.

17 Java™ SDK, Standard Edition a development environment for building applications, applets, and components using the Java programming language includes tools useful for developing and testing programs written in the Java programming language and running on the Java platform Except for the appletviewer, these tools do not provide a graphical user interface

18 API Specification Application Programming Interface (API) documentation online and downloadable Contains detailed documentation on all classes and packages in the java standard library java API Specification

19 The Java Virtual Machine (JVM) – key to portability is an abstract (virtual) computer that runs compiled Java programs –virtual" because it is generally implemented in software on top of a "real" hardware platform and operating system Makes java code portable code compiled on any platform will run on any other platform having Java Virtual Machine

20 For Home Computer Download and Install JCreator LE JSDK Java API documentation All from jcreator.com/download.htm jcreator.com/download.htm

21 Organizing Work The H drive is your personal workspace in the classroom. Create folders to organize work by topic, week, semester …

22 Your first Java Program Start Jcreator Follow instructions to create a Java program named HelloWorld public class HelloWorld { public static void main(String[] args) { }

23 Your first Java Program public class HelloWorld { public static void main(String[] args) { System.out.println(“Hello World”); }

24 Creation of a.class file - bytecode Go back to your project directory and look at the new files: –HelloWorld.java – source code –HelloWorld.class - bytecode

25 On Your Own Open HelloWorld source code and add more output lines. Open java program named Basics –Compile, execute, modify, compile …


Download ppt "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."

Similar presentations


Ads by Google