1 / 24

Software

Software. Bits and Bytes. http://www.flickr.com/photos/75578935@N07/6854660925/sizes/l/in/photostream/. Software. Computer software is an encoding of data and instructions where the instructions are to be executed by the CPU. Software is synonymous with computer program. Recall that:

alina
Télécharger la présentation

Software

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Software Bits and Bytes http://www.flickr.com/photos/75578935@N07/6854660925/sizes/l/in/photostream/

  2. Software • Computer software is an encoding of data and instructions where the instructions are to be executed by the CPU. Software is synonymous with computer program. • Recall that: • A CPU is a physical device • A CPU can only do “simple” things like • add/subtract/multiply/divide two numbers • compare two numbers • copy data from one storage location to another

  3. Computer Software • A computer program must use only instructions that the CPU understands and is able to perform. • Follow these directions to travel for free to Los Angeles. • Stand at the center of the UW-L football field. • Turn to face West-South-West • Run as fast as you can for 20 yards. • Jump 1960 miles. • Land safely. • Will this work?

  4. Computer Software • Learning to program a computer means • Knowing what the computer can actually do • Knowing how to use these ‘simple’ commands to perform more ‘complex’ tasks • A programming language is used to represent the actions that a computer can actually perform. • A set of CPU instructions can be rendered in different programming languages just as one textbook can be rendered in English, Japanese, and Spanish. • Modern programming languages allow a programmer to “say more than” the CPU understands by translating these instructions into the simple language of the CPU.

  5. Languages High Level close to English LISP, C++, Java, Python FORTAN, C, PASCAL ASSEMBLY Low Level close to the CPU’s native language add/sub/mul/divide/compare MICROCODE

  6. Can you understand this program? Low Level Language Machine Language (Pentium III Linux Box) 01111111 01000101 01001100 01000110 00000001 00000001 00000000 00000000 …

  7. Can you understand this program? Intermediate Level Language Assembly (Pentium III Linux Box) .file “hello.c” .version “01.01” .section .rodata .LCO: .string “Hello World\n” .text .align 4 .globl main .type main,@function main: pushl %ebp movl %esp,%ebp pushl $.LCO call printf addl $4,%esp xorl %eax,%eax jmp .L1 .p2 align 4,,7 .L1: leave ret

  8. Can you understand this program? Intermediate Level Language C #include <stdio.h> void main() { printf(“Hello World\n”); }

  9. Can you understand this program? High Level Language Python print “Hello World” Each of these programs mean the same thing. They are just written in different languages!

  10. print “Hello World” Python (English-level) 01111111 01000101 01001100 01000110 00000001 00000001 00000000 00000000 … Microcode (CPU-level) Languages and Compilation Compiler • Programmers write at a high level • The CPU can’t understand the high level and so a translator converts into low level • The translator is itself a program called a compiler.

  11. Software: Compilation and the JVM • In Java, there is a virtual CPU known as the JVM • Java Virtual Machine • The JVM is a program that, when run on a real CPU, makes the real CPU act like the ‘Java’ CPU. • A Java compiler converts a Java program into bytecode (the JVM’s microcode)

  12. Software: Compilation and the JVM Java Program bytecode JVM JVM JVM Intel Pentium (Windows) PPC (Mac) MIPS 32 (Unix)

  13. Important ConceptsSyntax and Semantics • A programming language • is a language! • All written languages (whether programming or natural) • Have rules about syntax • The way the language “looks”. More specifically, what symbols are in the language and how those symbols must be arranged. • Have rules about semantics • What the symbols “mean”

  14. Programming Languages • A programming language • is a language! • All written languages (whether programming or natural) • Have rules about syntax • The way the language “looks”. More specifically, what symbols are in the language and how those symbols must be arranged. • Have rules about semantics • What the symbols “mean”

  15. Syntax identifies the symbols that can be used and how they must be arranged to form “words” かさ Umbrella Syntax and Semantics: Example

  16. Syntax and Semantics: Example Syntax also defines how “words” can be arranged to form “sentences”

  17. Syntax and Semantics: Example Umbrella • Semantics gives meaning to symbols. • A device for protection from the weather consisting of a collapsible, usually circular canopy mounted on a central rod. (From Yahoo’s online dictionary) • Given the first statement below: identify whether the following statements contain changes in SYNTAX or SEMANTICS or BOTH. The college student ate three large pizzas. The high-school student made five large pizzas. The coLLage stoodaent, 8te three larj pissas$

  18. Syntax and Semantics: Programming • Consider Java • A programming language • Java has a set of syntax rules • Java has a set of semantic rules • Syntax Rule Example: • Integer numbers are 1 or more consecutive digits optionally preceded by a ‘+’ or ‘-’ symbol (must not have space(s) between them). 918 -3 +54.21 00005 3 5 http://www.flickr.com/photos/7989285@N07/1794265047/sizes/z/in/photostream/

  19. Syntax and Semantics: Programming • Syntax Rule Example: • The symbol ‘<‘ and the symbol ‘>’ can only appear immediately between two integer numbers. Spaces may separate the numbers from these two symbols. 9<8 > 35 3 >1 0 < 10>>5 • Semantic Rule Example: • If a ‘<‘ appears between two numbers, it means the following: • TRUE if the left number is less than the right number • FALSE if the left number is not less than the right number 9<8 0< 35 3 <11 -3 <2 10<5

  20. Programming: the Big Idea • A programmer must • know the syntax of their programming language • know the semantics of their programming language • follow these rules to construct software that solves specific problems. Example Problem: Write software that computes shipping cost for Amazon.com. Amazon is running a special where they give free shipping for any transaction totaling $25 or more. All other transactions are charged a flat fee of $7.00 for shipping. if(totalPurchaseAmount < 25) { shippingCost = 7.0; } else { shippingCost = 0.0; }

  21. Software • Software is a sequential set of instructions for the CPU • What qualities does good software have? • unambiguous- can’t mean more than one thing • readable – a human can look at it and understand it • correct – doing exactly what it should do all the time

  22. Software: Engineering • Software engineering manages the process of writing software • Java is an Object-Oriented language (more on this later) • Three general phases in the process of software development • Analysis – learn what the software should do. Write the requirements document. • Design – decide how to structure the software (classes / objects / variables / methods). Write the design document. • Implementation – Write the software using some language. We will use Java.

  23. Software: Engineering • These phases can be completed in various ways. The ‘simplest’ is the ‘waterfall’ cycle. Each phase is completed prior to the next. Analysis Design Implementation Testing

  24. Source code file ( className.java ) Java compiler (javac) Bytecode file ( className.class ) Java Virtual Machine (java) Process Action Software Tool Deliverable Text editor (NotePad) Programmer types the software into the computer. The software is translated into a form that is “understood” by the computer. The program executes. 24

More Related