1 / 47

G51PR1

G51PR1. Introduction to Programming I 2000-2001 University of Nottingham Unit 1 : Introduction. Background Teaching Staff Course Details Assessment PR1 Summary Resources Programming Programming Languages High Level Languages Interpreters / Compilers. Introduction to Java

breck
Download Presentation

G51PR1

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. G51PR1 Introduction to Programming I 2000-2001 University of Nottingham Unit 1 : Introduction

  2. Background Teaching Staff Course Details Assessment PR1 Summary Resources Programming Programming Languages High Level Languages Interpreters / Compilers Introduction to Java Java History Java Properties Types of Programs JDK tools The HelloWorld program Using CourseMaster Overview

  3. Teaching Staff • Lecturer : Tsintsifas Athanasios (thanassis) • azt@cs.nott.ac.uk Room:C73 (mon 10-12) (wed 9-10) (fr 10-12) • CourseMaster Administrator : Pavlos Symeonidis • pxs@cs.nott.ac.uk Room:C73 (tues 2-6) (thur 2-6) • Help Desk: Tarek Hegazy, • tmh@cs.nott.ac.uk Room : C75 • Lab Assistants (terminal room - lab hours). • CourseMaster help (via email), cm-help@cs.nott.ac.uk

  4. Course Details • 20ish lectures plus lab sessions. • One to three coursework exercises per week. • You will be assigned to 1 of 4 lab sessions • 2-4 & 4-6 Tuesday • 2-4 &, 4-6 Thursday • Prerequisites : None (but you must do CUA concurrently). • Objectives : To learn to think algorithmically and to express in sound implementations.

  5. Assessment • 100% coursework via the CourseMaster system (used to be called Ceilidh, check www.cs.nott.ac.uk/~ceilidh).

  6. Assessment • Starting on Friday 13th of October • Exercises close 10 days after opening (every Monday 12:00) • Usually you have three attempts to submit. • The last attempt is always the final. • Feedback after each submission gives you enough information to infer the correct the solution. • More on the process of using CourseMaster on Friday.

  7. Summary of PR1 • 9-10 units of 1-2 lectures

  8. Resources • Sun file servers (jdk is installed in solaris) • PCs (jdk is installed in all lab PCs) • CourseMaster installed in all lab PCs • PFE editor or Emacs-JDE • JDK 1.3 • Course Transparencies : http://www.cs.nott.ac.uk/~azt/pr1

  9. Reading Recommended: • Java Gently by Judy Bishop (Addison-Wes). • Java. How to Program by Deitel & Deitel (Prentice Hall). • Developing Java Software by Winder & Roberts (Wiley). • Java in a Nutshell by Flanagan (O’Reilly). • Thinking in Java (Bruce Eckel) (available on the web) Other Sources of Information: • CourseMaster : http://www.cs.nott.ac.uk/CourseMaster • Sun Java Tutorial : • http://java.sun.com/docs/books/tutorial/getStarted/index.html • WWW – general : search in www.google.com! • Intense Java Course : http://www.cs.nott.ac.uk/~azt/java.htm

  10. Programming • "A program is a sequence of instructions. A recipe, a musical score, and a knitting pattern are all programs." P Grogono, Programming in Pascal. • The way to deal with an impossible task is to chop it down into a number of merely very difficult tasks, and break each one of them into a group of horribly hard tasks, and each one of them into tricky jobs, and each one of them... (Terry Pratchet, Truckers)

  11. Programming Languages • There are four basic programming language levels: • machine language • assembly language • high-level language • fourth-generation language • Each CPU has its own specific machine language • The other levels were created to make programming easier

  12. 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 • The Java approach is somewhat different

  13. High Level Languages Old-fashioned languages include: • BASIC - often used by beginners on home computers. • FORTRAN - old but still popular with some scientists and engineers, new versions are introduced every few years. • Algol - an elegant little-used internationally designed language, whose features are being incorporated into other languages. • COBOL - a widely used and well standardised language used in commerce. • APL - an interactive scientific language with a very mathematical notation. • PL/I - a failed attempt by IBM at achieving an all-purpose language, now almost dead.

  14. High Level Languages Other Languages : • Pascal - good for beginners, often taught as a first language. • Modula2 - a development of Pascal to make it more realistic for large programs, and to enable modern program design techniques to be used. • C - a practical language, see below. • C++ - an object-oriented development of C. • ADA - a USA Department of Defense standard, now adopted by the UK Ministry of Defense also, aimed at safe programming for real-time embedded systems. • Java – A robust, secure, portable, network enabled variation on C/C++.

  15. High Level Languages Compare the COBOL: rate_per_hour multiplied by hours_worked gives gross_pay with C/C++: pay = rate * hours Some language aims: understanding, documentation –> commercial (eg COBOL). handling vectors or complex numbers –> scientific/engineering (FORTRAN). simplicity –> beginners (Basic, Pascal). safety –> real time systems (ADA, Modula-2). complexity –> object-oriented (C++, Eiffel, Java).

  16. Interpreters vs Compilers Interpretation : • BASIC & APL are interpreted. • Each line is decoded and interpreted by the computer as it is executed. • Instructions in loops may have to be interpreted many times. • This is inefficient and causes the computer to run slowly. Compilation : • Most other languages are compiled. • Whole program first analysed by a compiler (another program). • Converted into a machine executable form. • Runs much faster (an order of magnitude or more). • Can apply many types of optimisation during or after compilation. • In two parts – compilation into an object module, then loading/linking into the executable.

  17. Java: What is it? Sun’s Description…. Java is a : • Simple • Object Oriented • Distributed • Interpreted • Robust • Secure • Architecture Neutral • Portable • High Performance • Multithreaded and Dynamic programming language. It contains an extensive library of classes for graphics programming, input/output, string handling, maths functions, basic data structures, etc.

  18. Java History • C language was evolved as a portable operating system language • Dennis Ritchie (at Bell labs) developed it from B (which came from BCPL). • Originally ran on a DEC PDP-11 computer in 1972. • C++ is an object-oriented extension to C developed by Bjarne Stroustroup early 80’s. • Sun had an internal corporate research project, Green, in 1991, to develop intelligent consumer devices. • Project lead to the language Oak (James Gosling) based on C/C++. • Oak about to be cancelled when WWW came along. • Sun saw renamed Oak to Java and saw potential for use on the web • Java formally announced in May ’95. • Since then, Java generated huge interest.

  19. Java’s Versions • Java was officially announced in May 1995 Java 1.2.2 Java 1.1 First Idea Java 1.3 Java 1.2 Java 1.02 99 91 92 93 94 95 96 97 98 00 OAK Green Project

  20. Simple • Has a small set of Language Constructs. • Borrows the C and C++ syntax. • Is free from pointers. • Uses Garbage Collection. • Does not use header files and preprocessors.

  21. Object Oriented • Not hybrid like C++. • Supports the basic notions of OO : • Abstraction, • Modularity, • Encapsulation, • Hierarchy, • Typing, • Concurrency, • Persistance.

  22. Distributed • Works on a variety of platforms. • Provides support for : • Networking, • Internet, • Remote Objects.

  23. Interpreted • The Java compiler translates Java source code into a special representation called bytecode • Java bytecode is not the machine language for any traditional CPU • Another software tool, called an interpreter, translates bytecode into machine language and executes it • Therefore the Java compiler is not tied to any particular machine • Java is considered to be architecture-neutral Java Bytecode File Java Source File Java Compiler Java Bytecode File Java Bytecode File JVM

  24. Robust • Exception and Error handling. • Multi-Tasking. • Memory protection and management. • Allows Modular development. • Extensive compile-time checking.

  25. Secure • The features of bytecode and its interpretation, prevent unintentional or intentional sabotage of compiled programs. • Security has been considered in many levels.

  26. Java Bytecode Mac VM Solaris VM Win95 VM Java HW Solaris MacOS Win95 Architecture Neutral • Bytecode can run on any JVM on any platform. • “Write Once run Anywhere”. • JDK implementation on many platforms.

  27. Portable • The bytecode can run on virtual machines (VM) above different operating systems : • MacOS • Windows95/NT/CE • Solaris • OS2 • etc • It can also run directly on hardware.

  28. High - Performance • Multithreading allows more than one task in a program. • With JIT compilers the interpreted code compiles at run time and gives almost native code speed. Java Bytecode Native Java VM JIT Java OS Java HW Operating System Hardware

  29. Dynamic • Java has been built to support the development of dynamically extendable systems. • Java provides dynamic linking of the binary code at runtime.

  30. Java’s Genealogy

  31. Java : Types of Programs • Applets : • Execute on HTML Browsers. • Have severe security restrictions. • GUI Applications : • Are Interpreted and Executed. • Use the current’s platform’s GUI widgets. • Mostly use Java’s AWT or JFC packages. • Console Applications : • Simple Text Console.

  32. JDK basic tools • javac (Compiler) .java->.class • The Java Language Compiler that you use to compile programs written in Java into bytecodes. Example : java HelloWorld.java • java (Interpreter) executes .class • The Interpreter that you use to run programs written in Java. Example : javac HelloWorld • javadoc (Doc. generator) .java html • Generates documentation in HTML format from Java source code. Example : javadoc HelloWorld.java

  33. The First Java Program Filename: HelloWorld.java public class HelloWorld { public static void main(String argv[] ) { System.out.println("Hello World!!!"); } }

  34. CourseMaster • CourseMaster is a “Courseware” system that provides for : • The presentation of Information • summaries, notes, coursework questions, hints, daily messages • The administration of coursework • coursework delivery, • submission management, • overall class management • The automatic assessment of coursework • solution space modeling, • assessment and feedback mechanisms, • plagiarism checking tools

  35. Logging in CM client: • To login to CM you need both a windows and a unix password. • Once you are in windows you can click the “CM” icon • This will get you to the login screen : Unix Password!

  36. Message of the day : • Informs you about the latest in exercises • Do read it!

  37. CourseMaster Course Level : • Options • Exit • MOTD • Notes • Summary

  38. CourseMaster Unit Level • Notes • Summary

  39. CourseMaster Exercise Level : • Setup • Develop • Submit • Question • View TD • Marks • Run • Run TD

  40. Setup : • Puts the skeleton source and other files in your working area • Do not setup over your solution

  41. Develop : • PFE is CM’s standard editor for Java source • You can always change it later on!

  42. Compile : • From Menu : Execute->javac

  43. After Compilation : Good News Bad News Ctrl + G Gets you to any line number

  44. Run a program Two options : • 1. From PFE, Execute->java • PFE : Options->Preferences->Execute Menu->java->Edit : • Start command (as independent process OR capture output) • 2. From CourseMaster, Exercise Level->Run

  45. Submit • After having developed the solution you need to refresh the CM browser by refreshing the course tree structure. • You will be asked to confirm and then wait for the result. Expanded Result tree Feedback for every check Submission Number

  46. Other Options : • View TD : Allows you to see the testing input that CM uses for the particular exercise. • Marks : Allows you to check the exercise’s last submission • Options : Allows you to change : • Visual properties. • Editor command.

  47. Background Teaching Staff Course Details Assessment PR1 Summary Resources Programming Programming Languages High Level Languages Interpreters / Compilers Introduction to Java Java History Java Properties Types of Programs JDK tools The HelloWorld program Using CourseMaster Summary

More Related