Computer Components. Software{ User Programs. Operating System. Hardware

Similar documents
Computer Components. Software{ User Programs. Operating System. Hardware

Basic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2

3. Java - Language Constructs I

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

COMP 202 Java in one week

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Java Programming. Atul Prakash

CSC 1214: Object-Oriented Programming

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

Program Fundamentals

2 rd class Department of Programming. OOP with Java Programming

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

DM550 Introduction to Programming part 2. Jan Baumbach.

3. Java - Language Constructs I

Lecture 2: Variables and Operators. AITI Nigeria Summer 2012 University of Lagos.

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Accelerating Information Technology Innovation

CS 231 Data Structures and Algorithms, Fall 2016

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

For the course, we will be using JCreator as the IDE (Integrated Development Environment).

Basics of Java Programming

DM503 Programming B. Peter Schneider-Kamp.

CompSci 125 Lecture 02

JAVA Ch. 4. Variables and Constants Lawrenceville Press

BASIC ELEMENTS OF A COMPUTER PROGRAM

Chapter 3: Operators, Expressions and Type Conversion

Chapter 2. Elementary Programming

Chapter. Focus of the Course. Object-Oriented Software Development. program design, implementation, and testing

An overview of Java, Data types and variables

Programming Lecture 3

Introduction to C# Applications

Java Bytecode (binary file)

6.096 Introduction to C++ January (IAP) 2009

DEPARTMENT OF MATHS, MJ COLLEGE

PROGRAMMING FUNDAMENTALS

Expressions and Data Types CSC 121 Spring 2017 Howard Rosenthal

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods

Language Fundamentals Summary

Introduction to Programming Using Java (98-388)

Last Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2

Fundamental of Programming (C)

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Java for Python Programmers. Comparison of Python and Java Constructs Reading: L&C, App B

Building Java Programs. Introduction to Programming and Simple Java Programs

Variables and Operators 2/20/01 Lecture #

Algorithms and Programming I. Lecture#12 Spring 2015

Fundamentals of Programming

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

The MaSH Programming Language At the Statements Level

Intro to Computer Science & Programming. A Cranes Club Initiative

CS313D: ADVANCED PROGRAMMING LANGUAGE

Course Outline. Introduction to java

Java: framework overview and in-the-small features

Java Language Basics: Introduction To Java, Basic Features, Java Virtual Machine Concepts, Primitive Data Type And Variables, Java Operators,

Lecture Set 2: Starting Java

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1

Creating a C++ Program

Java Identifiers. Java Language Essentials. Java Keywords. Java Applications have Class. Slide Set 2: Java Essentials. Copyright 2012 R.M.

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Lecture Set 2: Starting Java

Java language. Part 1. Java fundamentals. Yevhen Berkunskyi, NUoS

C: How to Program. Week /Mar/05

CSCI 2101 Java Style Guide

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

Index COPYRIGHTED MATERIAL

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

The Java Language Rules And Tools 3

Welcome to CSE 142! Zorah Fung University of Washington, Spring Building Java Programs Chapter 1 Lecture 1: Introduction; Basic Java Programs

UNIT- 3 Introduction to C++

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

Operators and Expressions

Chapter 2 - Introduction to C Programming

Introduction to Java

Introduction to Programming (Java) 2/12

Ex: If you use a program to record sales, you will want to remember data:

A.A. 2008/09. Why introduce JavaScript. G. Cecchetti Internet Software Technologies

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Datatypes, Variables, and Operations

Syntax and Variables

COMP Primitive and Class Types. Yi Hong May 14, 2015

Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Operators. Java operators are classified into three categories:

Getting Started with Python

Sir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Section 2.2 Your First Program in Java: Printing a Line of Text

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

JAVA OPERATORS GENERAL

Preview from Notesale.co.uk Page 9 of 108

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Pace University. Fundamental Concepts of CS121 1

The Java language has a wide variety of modifiers, including the following:

Transcription:

Computer Components Software{ User Programs Operating System Hardware

What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point B from point A. A program may say... if starting at location B go north 3 blocks then go East 2 blocks

Programming Tree 2013 Andrew Case 4

Programming Popularity 2013 Andrew Case 5

Programming History First programmer: Ada Lovelace Different paradigms Functional (lisp, scheme, etc.) Procedural (C, PHP, etc.) Object Oriented (Java, C++, etc.) Note: Most object oriented languages can also be procedural 2013 Andrew Case 6

What are Programs? Input Processing Output

High vs. Low Level Languages Low level programming languages - High level programming languages -

High vs. Low Level Languages Low level programming languages tied to hardware High level programming languages - provides a layer of abstraction that allows for the programmer to only have to learn a hardware independent language

Pros/Cons of High Level Languages Pros Faster development (libraries/etc.) Easier to understand (abstraction) Can be platform independent Cons Usually larger executables Abstraction layer usually adds overhead for processing resulting in slower executables

Assembly Example (Low Level) mov ax,cs mov ds,ax mov ah,9 mov dx, offset Hello int 21h xor ax,ax int 21h Hello: db "Hello World!",13,10,"$"

Python Example (High Level Scripting Language) print( hello World! )

Java Example (High Level Strongly Typed Language) class HelloWorld { static public void main( String args[] ) { System.out.println( "Hello World!" ); } }

Anatomy of a Program Traditional Language Source Code Compiler Virtual Machine Language Source Code Interpreter and/or Bytecode Compiler Compiled Code Bytecode Linker Virtual Machine Executable Execution

Bytecode vs. Executable Bytecode Cross platform Allows for replacement of small components without recompiling entire programs Generally slower performance Executable Runs on one platform Programs generally compile down to larger executables Generally faster performance

Algorithms

Algorithms A series of instructions that solve a problem

Algorithms A series of instructions that solve a problem. Example, sorting a list of numbers: repeat: swapped = false for i = 1 to length(numbers) 1: /* if this pair is out of order */ if numbers[i-1] > numbers[i] then /* swap and remember change */ swap( numbers[i-1], numbers[i] ) swapped = true end if end for until no swaps occur

Natural Languages Syntax: punctuation and spacing Semantics: The meaning of the words Example: The quick brow fox jumped over the lazy dog.

Programming Languages Syntax: punctuation (e.g. parentheses, colons, spacing) Semantics: The meaning of the words What does System.out.println() mean?

Coding Style Just as in natural languages the style of coding matters. Style determines the level of readability and maintainability Several things make up a coding style: Formatting, naming schemes, comments, design

Pseudo-Code The expression of programming logic in a language independent nature. Good for design phase of coding Example: the last slide!

Bugs

Bugs All programmers run into bugs... lots and lots of bugs. Bugs are errors in a program. Bugs come in different varieties: Compile time errors: (syntax/type/etc.) The rules of the language have been violated. Examples: improper spacing, missing colon, etc.

Bugs All programmers run into bugs... lots and lots of bugs. Bugs are errors in a program. Bugs come in different varieties: Compile time errors: (syntax/type/etc.) The rules of the language have been violated. Examples: improper spacing, missing colon, etc. Runtime errors (crashes): Errors during execution Example: input file may not be readable

Bugs All programmers run into bugs... lots and lots of bugs. Bugs are errors in a program. Bugs come in different varieties: Compile time errors: (syntax/type/etc.) The rules of the language have been violated. Examples: improper spacing, missing colon, etc. Runtime errors (crashes): Errors during execution Example: input file may not be readable Logic errors: A problem that is caused by a flawed algorithm or set of instructions used to solve a problem

Basic Programming Concepts Keywords Statements Operators Data Types Variables

Keywords Keywords - reserved words that have special meaning in a particular programming language. These words can not be used for any other purpose (e.g. variable names). Java keywords are: abstract, continue, for, new, switch, assert, default, goto, package, synchronized, boolean, do, if, private, this, break, double, implements, protected, throw, byte, else, import, public, throws, case, enum, instanceof, return, transient, catch, extends, int, short, try, char, final, interface, static, void, class, finally, long, strictfp**, volatile, const*, float, native, super, while

Statements Instructions telling the computer what to do

Basic Data Type (primitive data types) Integers (Real numbers): short (16 bits), int (32 bits), long (64 bits) Single text character: char 32bit decimal numbers: float 64bit (more precise) decimal numbers: double True/False (similar to a bit): boolean 8 bits: byte Strings (are actually objects): store a series of characters

Operators Different data types have different operators Operators are part of a statement Operators act on the operands around them Unary operators take 1 argument e.g. setting a number to a negative value: -3 Binary operators take 2 arguments e.g. arithmetic operators: 1-3 Ternary operators takes 3 arguments // if x < y set largest to y, else set it to x largest = x < y? y : x;

Operators on Numbers In order of increasing precedence, with respect to dividers (i.e. + and have the same precedence, but execute after *,/,%.) + Additive operator (also used by strings) - Subtraction operator * Multiplication operator / Division operator % Remainder operator ( ) Dictate order of operations

Comments Provides: Documentation Clarifying what specific code is doing Make code easy for the author or other programmers to understand Line comments start with the // characters // this is a comment Block comments start with /* and end with */ /* this is a block comment comment, it spans multiple lines */

Variables Variables are labels refer to the storage of some data Variables give us access to data that is stored in memory. Two types of variables: Primitives (char/int/float/boolean/etc.) Objects/Arrays (Strings/Integer/Float/etc.)

Variables Variable name in java: Can be long Are case sensitive (Alpha!= alpha) Can contain letters, numbers, and underscores ( _ ) Must not start with a number Can not be a keyword

Variables The variable's data type (boolean, int, float, double, char, etc.) must be declared when created! The variable's data type will never change (i.e. it will always store that type of data)

Variables Primitives refer to the actual value and are stored in the stack Objects/Arrays store a reference to the location in memory where the data is stored in the heap

Variables Names (Examples) thisvariablenameisvalid = "valid naming conventions" this_variable_name_is_valid = "also valid" names = "names are valid" Names = "not the same as names" numbers_between_0_and_9 = "another valid" 0_9_can_not_start_a_name = "invalid" if = "keywords are not allowed" special_chars_!_allowed = "invalid"

Variable Assignment Statements // constant PI static final float PI = 3.14159265; // variables radius/area_circle float radius = 5; float area_circle = PI * radius * radius;

Constants A constant is a stored value that doesn't change Used for things that will remain constant throughout the program. (e.g. pi, conversions between metric and standard units, etc) When representing data that doesn't change it's often a good idea to use constants Generally constants are in all CAPITAL letters