1 / 46

Algorithmic Programming I

Algorithmic Programming I. COM136 Week 1 – Solving problems with Computers. Who Am I?. Name: Aiden McCaughey Senior Lecturer School of Computing & Intelligent Systems Email: a.mccaughey@ulster.ac.uk Tel: 028 71 675131 Room: MG126. Lab Group Allocations.

ivy-richard
Download Presentation

Algorithmic Programming I

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. Algorithmic Programming I COM136 Week 1 – Solving problems with Computers

  2. Who Am I? Name: Aiden McCaughey Senior Lecturer School of Computing & Intelligent Systems Email: a.mccaughey@ulster.ac.uk Tel: 028 71 675131 Room: MG126

  3. Lab Group Allocations • Group 1 - Monday 11.15-14.05 MF124/125 / MG122 • 2134 BSc (Hons) Computer Science • 6245 BSc(Hons) Computer Science (Software Systems Development) • Group 2 – Monday 14.05-17.05 MF124/125 • 7096 BEng (Hons) Computer Engineering • 4239 BEng (Hons) Computer Games Development • 7098 BSc (Hons) Information Technology • 7100 BSc (Hons) Computer Games Modeling & Animation • Lab Team Leaders: Heather Sayers hm.sayers@ulster.ac.uk Staff Rosaleen Hegarty hegarty-r@email.ulster.ac.uk Staff Tom Lunney tf.lunney@ulster.ac.uk Staff Alastair McKee mckee-a14@email.ulster.ac.uk Final Year Student Felix Stuart Wentworth wentworth-f@email.ulster.ac.uk Final Year Student Ciaran McCauley mccauley-c9@email.ulster.ac.uk Final Year Student John McElreavey mcelreavey-J@email.ulster.ac.uk Final Year Student Kenneth Vaughan vaughan-K1@email.ulster.ac.uk Final Year Student Patrick Kelly kelly-p27@email.ulster.ac.uk Final Year Student Ronan Duddy duddy-r4@email.ulster.ac.uk Final Year Student

  4. Content of Module • Module material available on Blackboard • http://learning.ulster.ac.uk

  5. Reading Material • Course Text • Currie E; Fundamentals of Programming Using Java; Thomson Learning Europe. • Reading List • Malik D.S & Nair P.S; Java Programming: From Problem Analysis To Program Design; 4th Edition; Course Technology, Cengage Learning. • Lewis J & Loftus W; Java Software Solutions Foundations of Program Design; 4th Edition; Addison Wesley • The Java Tutorial http://java.sun.com/docs/books/tutorial/

  6. Purchase Books • Course text and supplementary text can be purchased at 40% discount from the following website using the discount code: 2014UK40 (expires 31st October) • http://www.cengagebrain.co.uk • Currie: Fundamentals of Programming using Java, 1st Ed • Malik: Java™ Programming : From Problem Analysis to Program Design, International Edition, 4th Edition

  7. Learning Outcomes • Learning outcomes of this lecture: • Understand the relationship between the hardware and software parts of a computer system • Understand that computers are digital devices and that data is represented digitally. • Familiarity with the evolution of programming languages. • Be able to explain the concepts of compilation, interpretation, virtual machines and program portability in relation to the Java programming language. • Describe the stages in a structured program development cycle.

  8. Computer Systems - calculations • The Abacus was first device used to carry out calculations • First Abacus dates from around 2300BC

  9. Computer Systems – first design • 1837AD - Babbage analytical engine consisted of • input device, • memory storage, • a control unit to process instructions and • an output device • These are the fundamental elements of the modern computer system

  10. Computer Systems – Turing machine • Alan Turing 1912-1954 – English mathematician regarded as the father of Computer Science and artificial intelligence. • 1936 published concept of the Turing machine – a theoretical device that manipulated symbols on a strip of tape according to a table of rules • Provided theoretical basis for modern CPU

  11. Computer Systems – first implementation • 1946 - Eniac – first working electronic computer for US war department. • Weighed 28 metric tons, consumed 170Kw of power • 40x8ft, 18,000 vacuum tubes (valves) • Cost $487,000 to develop

  12. Computer Systems – first commercial • 1951- Univac – first commercial computer sold to US Census • Weighed 13 metric tons, consumed 125Kw of power • Could process 1905 instructions per second (IPS) • Intel Core i7 Extreme – 76 trillion IPS

  13. Computer Systems - revolution • Introduction of transistor (1956) and then microprocessor in (1971) revolutionized the development of the modern computer – replacing use of valves microprocessor transistor valves

  14. Modern Computer Systems

  15. Computer Systems Are Everywhere Home Automation Car ECU Airbus A320 first fly by wire

  16. Hardware – what is it? • Hardware is the term given to the physical tangible pieces of a computer system • things you can touch e.g. keyboard, screen, mouse, processor box etc.

  17. Hardware – key components • Key hardware components of a computer include • Central Processing Unit (CPU) • Input/Output devices • Main memory • Secondary memory (storage) devices

  18. Simplified View of Computer System CD-ROM Main Memory CPU Keyboard Monitor Hard disk

  19. Software

  20. Software • Software is the generic term applied to computer programs and it is the intangible counterpart to the physical hardware element of a computer system. • Computer programs contain instructions which are executed by the hardware one after the other and these instructions tell the computer what to do. • As an analogy think of a recipe as a program containing instructions a cook will follow to create a particular food dish.

  21. Software Categories • System Programs – e.g. operating system • Computer – Windows, Linux, OS X (apple) • Smartphone – iOS, Android, Windows Phone. • Embedded Systems: Sky EPG, Car ECU • Makes computer functional and manages all the other programs in a computer. • Application Programs • Just about any application developed to run on a computer. e.g. for Windows – Microsoft Office, Internet Explorer, Any program you will write! etc

  22. Digital Computers • What is stored in computer when you press ‘X’ on the keyboard? • Two techniques for storing/managing • Analog signals are continuous and continuously varying. e.g. Light dimmer switch • Digital signals are discrete and based on binary numbers. e.g. Light on/off switch • Computers use digital technology to store information as a series of binary numbers

  23. Binary

  24. Binary Numbers • You are used to decimal numbers, but computers use binary numbers • Binary number system (0 and 1) • Binary digit is called a bit • Sequence of eight bits is called a byte • ASCII coding scheme used to represent each character on keyboard • Characters numbered 0-127 • ‘A’ is 65th ASCII character or 1000001 in binary • See http://en.wikipedia.org/wiki/ASCII

  25. ASCII Table • This partial ASCII table shows the character ‘A’ with its decimal and Binary values circled.

  26. Computer programs • The programs that computers understand consist of ‘machine code’ instructions… • … Sequences of 1s and 0s (binary) • Each processor has its own set of machine code instructions that it recognises.

  27. Machine Language • Its difficult for humans to work with such programs • All instructions look the same to humans • Hard to find and correct errors • For example expression (wages = hours * rate) might require following machine code 100100 010001 100110 010010 100010 010011 • Can you see why this might be difficult and error prone?

  28. Assembler Language • Short words used to represent the machine code instructions. For example to perform a simple calculation e.g. wages = hours * rate • Easier for humans to follow • Computers cannot execute them • Must be translated into the equivalent machine code … by a program called an assembler LOAD rate STOR hours MULT wages

  29. High level languages • More abstract, problem-oriented instructions • Each instruction corresponds to several machine instructions. We can use high level expressions such as • wages = hours * rate • A program called a compiler is required to translate the instructions into machine code so that they can be executed by the processor • Compiler produces machine code directly 100100 010001 100110 010010 100010 010011

  30. Compiler does syntax check Errors? Fix them Compiler makes machine code Host computer runs compiled program independently Traditional Compilation Process • A compiler is used to translate source code directly into machine code which can then be executed directly by the host machine High-level program wages = hours * rate; 100100 100110 100010 101111 …

  31. Popular programming languages 1950s and 1960s • Fortran - dedicated to mathematical calculations. • Algol – general purpose language • Basic – designed to be easy to use and learn • COBOL – used for business data processing • Lisp - Functional language for list processing. 1970s • Pascal – popular for teaching programming • C – created to implement the UNIX operating system • Prolog – logic programming language – used in AI

  32. Popular programming languages 1980s • C++ - object-oriented extension of C • Perl – widely used scripting language 1990s • Java – object oriented portable language • Python – object oriented scripting language • Ruby – object oriented scripting language • PHP – object oriented web scripting language • Javascript – object oriented scripting language New Millenium • C# - object oriented language for .NET platform • Scala – object/functional language for Java JVM • Groovy – object oriented language for Java JVM

  33. Java • In this module we will concentrate on use of the Java language • Developed by Sun Microsystems (now owned by Oracle) circa 1991. Main aims: • An object oriented language with built in GUI support, that could be used on the web • Platform Independence • A simpler C++?

  34. Platform independent - JVM • Java program compiled to Java byte code • Byte-code runs on Java Virtual Machine (JVM) • JVM interprets the byte code instructions • Byte code can be executed on any computer that has the JVM installed • NOTE • Modern JVM’s use Just in Time Compilation (JIT) to compile byte-code to native machine code on the fly – provides greater performance

  35. Java Compiler does syntax check Errors? Fix them Java Compiler creates class file (byte-code) Java Interpreter (JVM) executes byte-code Machine Code produced by JVM executed on host CPU Java Compilation Process • Java requires a compiler to translate source code into byte-code and an interpreter (JVM) to execute the byte-code on the host machine. wages = hours * rate; Java source program 0: bipush 45 2: istore_3 3: iload_3 4: i2d 5: ldc2_w #2; 8: dmul 9: dstore 4 100100 100110 100010 101111

  36. Java Software development kit • The Java SE 8 JDK can be found at • http://www.oracle.com/technetwork/java/javase/downloads/ • When installed we have access to: • The compiler: c:\> javac • The interpreter: c:\> java • Online documentation (the Java application programming interface - API) is found at: • http://docs.oracle.com/javase/8/docs/api/

  37. What does a Java program look like? // Prints 'Hello world!' on the screen public class Hello { public static void main(String[] args) { System.out.println("Hello world!"); } }

  38. First Java program • This is just to give an idea of what a Java program looks like. The details will be covered later. Some things to note are: • Any text following // on a line is a comment – an explanation of what the program does. • Braces { } delimit sections of the program • The program consists of English-like words • The program is long for what it does (outputs ‘Hello world’ to the screen).

  39. Classes • Used to structure and organise programs • Instructions are inside methods, which are inside classes • The previous program contains one method called main • This contains one instruction System.out.println(“Hello world!"); • Every program must contain a main method, the instructions of which get executed first

  40. Interactive development environments • Combine the edit-compile-run stages • Launch compiler and interpreter via menus • Interactive debugging • Examples BlueJ, Netbeans, Eclipse

  41. Script engine does syntax check Errors? Fix them Scripting language interpreter executes script Scripting Languages • Scripting languages are popular and widely used • Major difference is that programs written in a scripting language are not compiled in the traditional sense • Rather an interpreter executes the script • They are therefore known as interpreted languages High-level script wages = hours * rate; • Scripting languages are a great way to learn programming

  42. Script Engines to Try Out • Javascript shell • http://www.squarefree.com/shell/shell.html • Python Shell • C:\>python • http://shell.appspot.com/ • Groovy Shell • groovysh • Ruby • irb • http://tryruby.org

  43. Languages Summary • Traditional high-level languages (e.g. C++) are compiled using a compiler that translates source code into machine code for execution on underlying processor • Java language is also compiled, however the compiler produces byte-code (not machine code). This byte-code is then executed by the Java Virtual Machine (JVM). The JVM provides byte-code portability between different processors. • Scripting languages are not compiled. Rather they are interpreted by the script engine when the program is executed. They are slower than compiled languages, but are very popular due to their ease of use, and are a great way to learn programming

  44. Software Development • Programs are developed via a number of levels of abstraction • First Level of Abstraction: idea in someone’s mind or on paper. Specifies what not how. • Second Level of Abstraction: a model - more detail but still far short of a program • Third Level of Abstraction: the program is produced from the model • Levels 1 & 2 may only be in mind of programmer rather than on paper (expert programmer)

  45. Software Development Activities • The traditional “Waterfall Software Lifecycle” activities: • Analysis and modelling • System design • Implementation • Testing and evaluation • Maintenance and enhancement • This along with other models will be covered in Systems Analysis & Development module

  46. Summary • In this section we have covered: • The relationship between the hardware and software parts of a computer system • Computers are digital devices and that data is represented digitally. • The evolution of programming languages. • The concepts of compilation, interpretation, virtual machines • Program portability in relation to the Java programming language. • The traditional set of software development activities (waterfall lifecycle).

More Related