Programming Languages



Similar documents
Language Processing Systems

CS 209 Programming in Java #1

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

1. Overview of the Java Language

How to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

An Overview of Java. overview-1

INTRODUCTION TO JAVA PROGRAMMING LANGUAGE

1/20/2016 INTRODUCTION

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution

Contents. Java - An Introduction. Java Milestones. Java and its Evolution

Mobile Application Languages XML, Java, J2ME and JavaCard Lesson 04 Java

12/22/11. } Android by Pearson Education, Inc. All Rights Reserved by Pearson Education, Inc. All Rights Reserved.

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

Fundamentals of Java Programming

Java CPD (I) Frans Coenen Department of Computer Science

Chapter 1 Introduction to Computers, Programs, and Java

Introduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages

Chapter 1. Dr. Chris Irwin Davis Phone: (972) Office: ECSS CS-4337 Organization of Programming Languages

Online Recruitment System 1. INTRODUCTION

CSCI 3136 Principles of Programming Languages

Chapter 1. Introduction to Computers, Programs, and Java

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

2 Introduction to Java. Introduction to Programming 1 1

System Structures. Services Interface Structure

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

02 B The Java Virtual Machine

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

Introduction to programming

CSC 551: Web Programming. Spring 2004

C Compiler Targeting the Java Virtual Machine

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Section 1.4. Java s Magic: Bytecode, Java Virtual Machine, JIT,

Compilers. Introduction to Compilers. Lecture 1. Spring term. Mick O Donnell: michael.odonnell@uam.es Alfonso Ortega: alfonso.ortega@uam.

Jonathan Worthington Scarborough Linux User Group

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz

Java (12 Weeks) Introduction to Java Programming Language

General Introduction

Java and Real Time Storage Applications

Introduction to Java

Chapter 13 Computer Programs and Programming Languages. Discovering Computers Your Interactive Guide to the Digital World

Java Platform, Micro Edition (Java ME) Mokoena F.R. The 7046 Team

Lecture 1 Introduction to Android

Developing Web Services with Eclipse and Open Source. Claire Rogers Developer Resources and Partner Enablement, HP February, 2004

Crash Course in Java

Tutorial 5: Developing Java applications

Compiler and Language Processing Tools

What Perl Programmers Should Know About Java

Java Programming Fundamentals

Habanero Extreme Scale Software Research Project

Developing Embedded Software in Java Part 1: Technology and Architecture

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

Effective Java Programming. efficient software development

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Semester Review. CSC 301, Fall 2015

Glossary of Object Oriented Terms

What is a programming language?

Enterprise Java. Where, How, When (and When Not) to Apply Java in Client/Server Business Environments. Jeffrey Savit Sean Wilcox Bhuvana Jayaraman

n Introduction n Art of programming language design n Programming language spectrum n Why study programming languages? n Overview of compilation

Semantic Analysis: Types and Type Checking

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

core. Volume I - Fundamentals Seventh Edition Sun Microsystems Press A Prentice Hall Title ULB Darmstadt

Evolution of the Major Programming Languages

Java Application Developer Certificate Program Competencies

DIABLO VALLEY COLLEGE CATALOG

Java in Education. Choosing appropriate tool for creating multimedia is the first step in multimedia design

The C Programming Language course syllabus associate level

Chapter 1 Java Program Design and Development

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

McGraw-Hill The McGraw-Hill Companies, Inc.,

Chapter 13: Program Development and Programming Languages

CS506 Web Design and Development Solved Online Quiz No. 01

Chapter 13: Program Development and Programming Languages

ATSBA: Advanced Technologies Supporting Business Areas. Programming with Java. 1 Overview and Introduction

TYLER JUNIOR COLLEGE School of Continuing Studies 1530 SSW Loop 323 Tyler, TX

Syllabus for CS 134 Java Programming

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

C# and Other Languages

picojava TM : A Hardware Implementation of the Java Virtual Machine

Glassfish, JAVA EE, Servlets, JSP, EJB

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Language Based Virtual Machines... or why speed matters. by Lars Bak, Google Inc

Computer Programming I

Java programming for C/C++ developers

CSCI E 98: Managed Environments for the Execution of Programs

Moving from CS 61A Scheme to CS 61B Java

Extreme Java G Session 3 Main Theme Java Core Technologies (Part I) Dr. Jean-Claude Franchitti

Programming Languages

Installing Java. Table of contents

Agent Languages. Overview. Requirements. Java. Tcl/Tk. Telescript. Evaluation. Artificial Intelligence Intelligent Agents

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Virtual Credit Card Processing System

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

Chapter 2: Elements of Java

9/11/15. What is Programming? CSCI 209: Software Development. Discussion: What Is Good Software? Characteristics of Good Software?

Transcription:

Programming Languages In the beginning To use a computer, you needed to know how to program it. Today People no longer need to know how to program in order to use the computer. To see how this was accomplished, lets investigate how programming languages evolved. First Generation - Machine Language (code) Second Generation - Assembly Language Third Generation - People-Oriented Programming Languages Fourth Generation - Non-Procedural Languages Fifth Generation - Natural Languages

Assembled, Compiled, or Interpreted Languages All programs must be translated before their instructions can be executed. Computer languages can be grouped according to which translation process is used to convert the instructions into binary code: Assemblers Interpreters Compilers

Assembled, Compiled, or Interpreted Languages Assembled languages: Assembler: a program used to translate Assembly language programs. Produces one line of binary code per original program statement. The entire program is assembled before the program is sent to the computer for execution.

Assembled, Compiled, or Interpreted Interpreted Languages: Languages Interpreter: A program used to translate high-level programs. Translates one line of the program into binary code at a time: An instruction is fetched from the original source code. The Interpreter checks the single instruction for errors. (If an error is found, translation and execution ceases. Otherwise ) The instruction is translated into binary code. The binary coded instruction is executed. The fetch and execute process repeats for the entire program.

Interpreters Read input program interpret the operations Program input... c = a * a; b = c + b;. Source code Interpreter Abstract machine Run time Program output

Assembled, Compiled, or Interpreted Compiled languages: Languages Compiler: a program used to translate high-level programs. Translates the entire program into binary code before anything is sent to the CPU for execution. The translation process for a compiled program: First, the Compiler checks the entire program for syntax errors in the original source code. Next, it translates all of the instructions into binary code.» Two versions of the same program exist: the original source code version, and the binary code version (object code). Last, the CPU attempts execution only after the programmer requests that the program be executed.

Compilers Read C/C++/Java program optimization translate into machine code Program input... c = a * a; b = c + b;. Source code Compiler.. 00000 01010 11110 01010.. Target code Program output Translation (compile) time Run time

Compilers Anatomy of a Computer Program written in a Programming Languages Compiler Assembly Language Translation

Anatomy of a Computer Lexical Analyzer (Scanner) Program (character stream) Token Stream Divides the string of input characters into single elements, tokens, based on strict computer punctuation

Lexical Analyzer (Scanner) 2 3 4 * ( 1 1 + - 2 2 ) Num(234) mul_op lpar_op Num(11) add_op Num(-22) rpar_op

Lexical Analyzer (Scanner) 2 3 4 * ( 1 1 + - 2 2 ) Num(234) mul_op lpar_op Num(11) add_op Num(-22) rpar_op 18..23 + val#ue Not a number Variable names cannot have # character

Anatomy of a Computer Lexical Analyzer (Scanner) Syntax Analyzer (Parser) Program (character stream) Token Stream Parse Tree Checks for errors in grammar rules

Syntax Analyzer (Parser) num * ( num + num ) <expr> <expr> <op> <expr> num * <expr> ( ) <expr> <op> <expr> num + num

Syntax Analyzer (Parser) int * foo(i, j, k)) int i; int j; { for(i=0; i j) { fi(i>j) return j; } Not a keyword Not an expression Extra parentheses Missing increment

Anatomy of a Computer Lexical Analyzer (Scanner) Syntax Analyzer (Parser) Semantic Analyzer Program (character stream) Token Stream Parse Tree Intermediate Representation Determines the meaning of the string

Semantic Analyzer int * foo(i, j, k) int i; int j; { int x; x = x + j + N; return j; } Type not declared Mismatched return type Uninitialized variable used Undeclared variable

Anatomy of a Computer Lexical Analyzer (Scanner) Syntax Analyzer (Parser) Semantic Analyzer Code Optimizer Program (character stream) Token Stream Parse Tree Intermediate Representation Optimized Intermediate Representation

Optimizer int sumcalc(int a, int b, int N) { int i; int x, y; x = 0; y = 0; for(i = 0; i <= N; i++) { x = x+4*a/b*i+(i+1)*(i+1); x = x + b*y; } return x; } int sumcalc(int a, int b, int N) { int i; int x, t, u, v; x = 0; u = ((a<<2)/b); v = 0; for(i = 0; i <= N; i++) { t = i+1; x = x + v + t*t; v = v + u; } return x; }

Anatomy of a Computer Lexical Analyzer (Scanner) Syntax Analyzer (Parser) Semantic Analyzer Code Optimizer Code Generator Program (character stream) Token Stream Parse Tree Intermediate Representation Optimized Intermediate Representation Assembly code

Code Generator int sumcalc(int a, int b, int N) { int i; int x, t, u, v; x = 0; u = ((a<<2)/b); v = 0; for(i = 0; i <= N; i++) { t = i+1; x = x + v + t*t; v = v + u; } return x; } sumcalc: xorl %r8d, %r8d xorl %ecx, %ecx movl %edx, %r9d cmpl %edx, %r8d jg.l7 sall $2, %edi.l5: movl %edi, %eax cltd idivl %esi leal 1(%rcx), %edx movl %eax, %r10d imull %ecx, %r10d movl %edx, %ecx imull %edx, %ecx leal (%r10,%rcx), %eax movl %edx, %ecx addl %eax, %r8d cmpl %r9d, %edx jle.l5.l7: movl %r8d, %eax ret

Programming for Everyone Several ways to control what your computer does or the way it accomplishes a particular task: Using Macros Using HTML to create Web Pages Scripting Each allows customization of current applications.

Building a Program Whatever type of problem needs to be solved, a careful thought out plan of attack, called an algorithm, is needed before a computer solution can be determined. 1) Developing the algorithm. 2) Writing the program. 3) Documenting the program. 4) Testing and debugging the program.

Introduction to Java technology

Introduction to Java technology Java technology is both: - a programming language and - a platform.

Introduction to Java technology The Java programming language is a high-level language that can be characterized by all of the following buzzwords: Simple Object oriented Distributed Multithreaded Dynamic Architecture neutral Portable High performance (JIT) Robust (memory) Secure (several layers of defense discuss )

Introduction to Java technology The Java programming language is a high-level language that can be characterized by all of the following buzzwords: Simple: - The fundamental concepts of Java technology are grasped quickly; programmers can be productive from the very beginning. - Java design team examined many aspects of the "modern" C and C++ languages to determine features that could be eliminated in the context of modern object-oriented programming. No More Typedefs, Defines, or Preprocessor No More Structures or Unions No Enums No More Functions No More Multiple Inheritance No More Goto Statements No More Operator Overloading No More Automatic Coercions. You must do so explicitly by using a cast. No More Pointers

Introduction to Java technology The Java programming language is a high-level language that can be characterized by all of the following buzzwords: Object oriented: To be truly considered "object oriented", a programming language should support at a minimum four characteristics: - Encapsulation--implements information hiding and modularity (abstraction) - Polymorphism--the same message sent to different objects results in behavior that's dependent on the nature of the object receiving the message - Inheritance--you define new classes and behavior based on existing classes to obtain code re-use and code organization - Dynamic binding--objects could come from anywhere, possibly across the network. You need to be able to send messages to objects without having to know their specific type at the time you write your code. Dynamic binding provides maximum flexibility while a program is executing

Introduction to Java technology The Java programming language is a high-level language that can be characterized by all of the following buzzwords: Multithreaded: Built-in support for threads provides Java programmers with a powerful tool to improve interactive performance of graphical applications. If your application needs to run animations and play music while scrolling the page and downloading a text file from a server, multithreading is the way to obtain fast, lightweight concurrency within a single process space. Threads are sometimes also called lightweight processes or execution contexts.

Interpreted and Dynamic: Introduction to Java technology The Java programming language is a high-level language that can be characterized by all of the following buzzwords: Java source code is stored as text in a.java file. The.java file is compiled into.class files (with the same name). A.class file contains Java bytecodes (instructions). The bytecodes are interpreted at run time. The Java.class file is the executable code. Compile (javac) JVM (java) Movie.java Movie.class Running program

Introduction to Java technology The Java programming language is a high-level language that can be characterized by all of the following buzzwords: Interpreted and Dynamic:

Introduction to Java technology How Does JVM Work? The class loader loads (in JVM) all required classes. JVM uses a CLASSPATH setting to locate class files. The classpath can be added in run time by using the java -cp or - classpath option. JVM Verifier checks for illegal bytecodes. This validation ensures that there are no memory access violations or other illegal actions performed. JVM Verifier executes bytecodes. JVM may invoke a Just-In-Time (JIT) compiler. Memory Manager releases memory used by the dereferenced object back to the OS. JVM handles Garbage collection.

Introduction to Java technology Benefits of Just-In-Time (JIT) Compilers JIT compilers: - Improve performance - Are useful if the same bytecodes are executed repeatedly - Translate bytecodes to native instruction - Optimize repetitive code, such as loops - Use Java HotSpot VM for better performance and reliability

Introduction to Java technology The Java programming language is a high-level language that can be characterized by all of the following buzzwords: Architecture neutral: The solution that the Java system adopts to solve the binary-distribution problem is a "binary code format" that's independent of hardware architectures, operating system interfaces, and window systems. The format of this system-independent binary code is architecture neutral. If the Java run-time platform is made available for a given hardware and software environment, an application written in Java can then execute in that environment without the need to perform any special porting work for that application.

Introduction to Java technology The Java programming language is a high-level language that can be characterized by all of the following buzzwords: Portable: The primary benefit of the interpreted byte code approach is that compiled Java language programs are portable to any system on which the Java interpreter and run-time system have been implemented. Java specifies the sizes of all its primitive data types and the behavior of arithmetic on them. Here are the data types:

Introduction to Java technology The Java platform : A platform is the hardware or software environment in which a program runs. Most platforms can be described as a combination of the operating system and underlying hardware. The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms.

Using Java with Enterprise Internet Computing Client Web server Application server Data Presentation Business logic Servlets JavaServer Pages (JSPs) Enterprise JavaBeans (EJB) CORBA

Using the Java Virtual Machine Operating system JVM Application Running Java Applications All Java applications run within a Java Virtual Machine (JVM). JVM is invoked differently depending on whether the Java program is an application or an applet.

Java Software Development Kit Sun Java J2SE (known as JDK and Java SDK) provides: Compiler (javac) Core class library classes.zip rt.jar Debugger (jdb) Bytecode interpreter: The JVM (java) Documentation generator (javadoc) Java Archive utility (jar) Others J2SE

Typical Java Development Environment Integrated development environments (IDEs) Provide tools that support the software-development process, including editors for writing and editing programs and debuggers for locating logic errors errors that cause programs to execute incorrectly. Popular IDEs Eclipse (www.eclipse.org) NetBeans (www.netbeans.org) JBuilder (www.codegear.com) JCreator (www.jcreator.com) BlueJ (www.bluej.org) jgrasp (www.jgrasp.org)

Using the Appropriate Development Kit Java2 comes in three sizes: J2ME (Micro Edition): geared toward developing applications for small, memory-constrained devices, such as cell phones, pagers and PDAs. J2SE (Standard Edition): Complete ground-up development environment for the Internet J2EE (Enterprise Edition): Everything in the J2SE plus, geared toward developing large-scale, distributed networking applications and web-based applications.

lolo.java package ex4d; // collection of classes of similar functionality import java.util.* ; // import for date class Interface Monster { void menace(); } interface DangerousMonster extends Monster { void destroy(); } public class lolo { static void w (Lethal l) { l.kill(); } public static void main (String[] args) { DangerousMonster barney = new DragonZilla(); w(vlad); } }