Welcome to COMP 10110 Computer Programming 1 Lecturer: Fintan Costello.

Slides:



Advertisements
Similar presentations
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Advertisements

Lecture 0 CSIS10A Overview. Welcome to CSIS10A (5 mins) – Typical format for class meetings New material first (monitors off, notebooks out) Practice.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. GCOC – A.P. Computer Science A College Board Computer Science A Topics Covered Program Design - Read and understand.
Chapter 1 These slides for CSE 110 Sections are based in part on the textbook-authors’ slides, which are copyright by the authors. The authors state that.
How do we make our Welcome.java program do something? The java in our Welcome.java file won’t do anything by itself. We need to tell the computer to execute.
How to Create a Java program CS115 Fall George Koutsogiannakis.
Lecturer: Fintan Costello Welcome to Hdip 001 Introduction to Programming.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
How do we make our Welcome.java program do something? The java in our Welcome.java file won’t do anything by itself. We need to tell the computer to execute.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Welcome to COMP 1001 First Year Computer Science Lecturer: Fintan Costello.
A tour around Java General introduction to aspects of the language (these will be covered in more detail later) After this tour you should have a general.
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Getting Started with Java
Chapter 1 - Introduction. Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Unit 2: Java Introduction to Programming 2.1 Initial Example.
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
ITP © Ron Poet Lecture 1 1 IT Programming Introduction.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Introducing Java.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Chapter 1 CSIS-120: Java Intro. What is Programming?  A: It is what makes computer so useful.  The flexibility of a computer is amazing  Write a term.
Programming With C.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Marie desJardins University of Maryland, Baltimore County.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. Chapter 1 – Introduction ( ปรับปรุง )
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
Introduction to programming in the Java programming language.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
1 C++ Programming Basics Chapter 1 Lecture CSIS 10A.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
Software Development. Software Development Loop Design  Programmers need a solid foundation before they start coding anything  Understand the task.
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
Chapter 1 - Introduction. Announcements Info Sheet Web Site: Lab Hours NotecardsPictures.
CS 177 Recitation Week 1 – Intro to Java. Questions?
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
C++ Programming Basics C++ Lecture 1 Stacy MacAllister.
Lecture 1b- Introduction
Component 1.6.
John Woodward A Simple Program – Hello world
GC101 Introduction to computer and program
Chapter 3 GC 101 Java Fundamentals.
CS190/295 Programming in Python for Life Sciences: Lecture 1
Fundamentals of Programming
Programming.
CMPT 120 Lecture 3 - Introduction to Computing Science – Programming language, Variables, Strings, Lists and Modules.
Week 1 - Friday COMP 1600.
Presentation transcript:

Welcome to COMP Computer Programming 1 Lecturer: Fintan Costello

Where you are COMP 10110:  ComputerProgramming  / This class is for  Computer Science Denominated Entry students

What will you learn on this course? How to make a computer do what you want: Write computer programs to respond to different situations You will also develop a useful attitude: Not to be afraid when things go wrong Write computer programs to manipulate data in various ways Write computer programs to solve problems. To try things on your computer and learn from mistakes To solve problems in a clear, unambiguous & precise way.

What is a computer program? A general definition: A computer program is a set of written instructions which, when running (executing) on a computer, allow the computer Remember things (by placing them in ‘variables’) Produce new things by combining things in different ways Make decisions Work until an aim is achived Communicate with the user (or other programs) These are all things we do when thinking. There is an interesting relationship between computer programs & our thought processes.

Why learn to program? By learning to program, we gain the ability to control and understand the most complex, sophisticated, and flexible tools humanity has ever created, and ones which dominate many aspects of our lives. The technological reason: To make useful & interesting things The scientific reason: To gain understanding of our world The psychological reason: To gain understanding of ourselves By learning to program, we gain tools that contribute to scientific understanding of our world (simulation of things around us, data analysis, applying the computing viewpoint to things around us) By learning to program, we learn to think about our own thought processes, to examine how we think in different situations, and to transfer written versions of those thought processes into a computer.

COMP10110 intro to programming: what to do Attend programming lectures twice weekly Attend practicals once weekly (1 * 2 hours) Practicals start next week in Comp Sci building Go through some of the textbook yourself (The book is “Java Concepts”, by Cay Horstmann) Marks based on practical work (40%) plus an exam at christmas (60%). Practical work must be submitted each week. Practical work must be satisfactory to pass COMP 10110

What is programming? A computer program is a set of written instructions which explain how to do a certain task or solve a certain problem. These instructions are written in a ‘programming language’ which the computer can understand. When we give these instructions to a computer it can carry out that task or solve that problem. A computer can carry out lots of tasks and solve lots of problems, because it can run lots of different programs.

What’s so special about programming? When we give people instructions on how to solve a problem, we can rely on their natural intelligence to understand any steps we’ve fogotten to mention. With a computer, we must fully specify every single step: we must give an absolutely complete explanation of how to solve the problem. This need to competely specify our solutions to problems is unique to programming. Programming, therefore, is the study of problem-solving.

Programming languages. Just as there are lots of different natural languages (French, English, Swahili…) there are lots of different programming languages. We’re going to learn a language called Java (a widely- used and powerful general-purpose language). Our aim in studying Java is not simply to learn the language; instead, we’re going to learn how to solve problems, and will use this language to write and test our solutions. But first: How can a computer understand a language anyway?

How do computers understand instructions? A computer is made out of rock (silicon; that is, sand) and metal. How can it understand instructions in a language? The basic idea is simple: instructions are represented by codes or patterns of switches (patterns like ‘on-off-on-on-off-off-on-on’) A given code or pattern not only stands for a given instruction; when certain switches deep inside the computer (in the ‘central processing unit’: the CPU) are set in that pattern, they cause the action required by that instruction to be carried out. In other words, the code representing the instruction (‘on-off-on-on-off- off-on-on’) also produces the action required by that instruction, when the switches are set in that code. So, for example ‘on-off-on-on-off-off-on-on’ (or : we usually represent these codes by 1s and 0s) could mean ‘start a new page on the printer’ because when the switches in CPU are set in that code, they cause a new page to be fed to the printer.

off switches wires wheel motors A very simple example: a toy car. Codes: on-on means ‘go forward’ on-off means ‘go left’ off-on means ‘turn right’ off-off means ‘do nothing’ 0 0 Rather than using the words ‘on’ and ‘off’ to represent switches turned on or off, we use the numbers 1 and 0. If this switch is on, an electric signal goes down these wires, activating the wheel motors

A very simple example: a toy car. Codes: 1-1 means ‘go forward’ 1-0 means ‘go left’ 0-1 means ‘turn right’ 0-0 means ‘do nothing’

Very rough structure of a computer Memory: each switch is on/off (1 or 0) Arithmetic unit: circuits that add together signals from memory Control unit: different settings of switches make different things happen (select rows from memory, cause arithmetic computations, etc) Loads signals from memory into control unit

Very rough structure of a computer Memory: each switch is on/off (1 or 0) Arithmetic unit: circuits that add together signals from memory Control unit: different settings of switches make different things happen (select rows from memory, cause arithmetic computations, etc) Loads signals from memory into control unit

Programming languages The commands controlling a computer are sequences of 1 and 0 (switches on and off). A given set of 1s and 0s will cause the computer to carry out some specific action (because it will set the switches to produce that action). It’s very hard to write instructions for a computer in 1s and 0s (in “machine code”). Instead, we will write our instructions for our computers in a programming language (which is a bit like english), and use a special program to translate our programming language instructions into machine code instructions. In the Java language, this translation process has two stages: we’ll first use the Java “compiler” to translate our instructions into an intermediate form called “bytecode” which all computers can understand, and then use the Java “interpreter” to translate that intermediate form into the machine code which our particular computer uses.

Programming languages Natural languages: French, English, Swahili… Programming languages: C, perl, Java... Natural languages are forgiving: if you have wrong the grammar, pronounciation, or speling, people can still understanding you be. Computers are not as smart as people: if you don’t have your program’s grammar and spelling exactly right, the computer will not understand and will give an error. There are two different types of error. Can you guess what they are? Errors can arise if the compiler cannot translate your instructions into machine code (a ‘compiler error’), or if the computer cannot actually do what you have asked it to do (a ‘run-time error’).

Your first java program HelloTester.java (Book, p. 15) public class HelloTester { public static void main(String[] args) { // displays a greeting at the console System.out.println("Welcome to Java"); }

Reserved words public class HelloTester { public static void main(String[] args) { // displays a greeting at the console System.out.println("Welcome to Java"); } The words in bold are reserved words: they mean something special in the java programming language. Reserved words are case-sensitive: P ublic is wrong.

What do these words mean? public class HelloTester { public static void main(String[] args) { // displays a greeting at the console System.out.println("Welcome to Java"); } class is a word identifying a class (a set) of things in Java. In this case, it’s the class of things that will print out a hello message. public is a modifier which identifies something as publicly accessible (other programs can “call” it, which means run it) main identifies the main part of a program (the bit that does most of the work). We’ll explain static and void later.

Blocks {......} A block is a sequence of code between matching curly brackets This block identifies everything that is in the public class HelloTester This block identifies everything that is in the main part of the class. public class HelloTester { public static void main(String[] args) { System.out.println("Welcome to Java"); }

Statements (commands) A statement is an action. A statement ends with a semi-colon ; System.out.println("Welcome..."); println means ‘print this on a line of its own’ (you can also use print, which doesn’t start a new line). System.out means that println is an action carried out by the out put part of a java class which you can use to interact with your computer’s System. We’ll learn more about this later when we talk about methods

Comments in Java Comments are simply notes for the programmer to remind themseleves and other programmers what a program is meant to do. Comments can contain any text you like // this is a one line comment // and here is another /* this comment can extend over several lines */ Comments are not java commands. Always comment your programs! It helps you remember what’s going on.

A more interesting program Next time I’ll explain exactly the steps you go through to get the HelloTester.java program to run. I’ll also introduce a more complex program: one that uses all the facilities of java to do some animation. You can see that program running here: I’ll first explain how we get this program to run, and then use it to give you a tour around the java programming language. You can get all lecture slides etc for this course via blackboard or at