1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.

Slides:



Advertisements
Similar presentations
Programming for Beginners
Advertisements

CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
1 Pass Compiler 1. 1.Introduction 1.1 Types of compilers 2.Stages of 1 Pass Compiler 2.1 Lexical analysis 2.2. syntactical analyzer 2.3. Code generation.
CPSC Compiler Tutorial 9 Review of Compiler.
Software Lesson #1 CS1313 Spring Software Lesson 1 Outline 1.Software Lesson 1 Outline 2.What is Software? A Program? Data? 3.What are Instructions?
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Chapter 16 Programming and Languages: Telling the Computer What to Do.
CS 153: Concepts of Compiler Design August 25 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
9-Aug-15 Vocabulary. Programming Vocabulary Watch closely, you might even want to take some notes. There’s a short quiz at the end of this presentation!
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Powered by DeSiaMore1 Programming Concepts David T. Makota Department of Computing & Information Technology (CIT) The Institute of Finance Management Dar.
1 Chapter-01 Introduction to Computers and C++ Programming.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Introducing Java.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
ICS611 Introduction to Compilers Set 1. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
1.2 What is a Computer? Computer –Device capable of performing computations and making logical decisions –Computers process data under the control of sets.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Evolution of Programming Languages Generations of PLs.
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
CSC 338: Compiler design and implementation
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Programming With C.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Python From the book “Think Python”
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Programming and Languages Dept. of Computer and Information Science IUPUI.
Textbook C for Scientists and Engineers © Prentice Hall 1997 Available at NUS CO-OP at S$35.10.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Software Engineering Algorithms, Compilers, & Lifecycle.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Component 1.6.
CSCI-235 Micro-Computer Applications
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
CS 363 – Chapter 1 What is a programming language? Kinds of languages
Translators & Facilities of Languages
Computer Programming.
Course supervisor: Lubna Siddiqui
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Chapter 1 Introduction(1.1)
CMP 131 Introduction to Computer Programming
Programming.
Software Lesson 2 Outline
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
15-110: Principles of Computing
Instructions in Machine Language
Chapter 10: Compilers and Language Translation
Presentation transcript:

1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal rules Cannot mix the words of multiple languages, or the syntax of multiple languages, in the same program Cannot be ambiguous Words and syntax must be EXACTLY correct in every way

2 Programming Language Hierarchy High Level Languages Assembly Languages Machine Languages

3 High Level Languages Human-readable Most are standardized, so they can be used on just about any kind of computer. Examples: C, Fortran 90, Java, HTML, Haskell, SAS Typically they are designed for a particular kind of application; for example: – C++ for operating system design – HTML for hypertext (webpages) But often, their uses in real life are broader their original purpose.

4 Assembly Languages Human-readable Specific to a particular CPU family; for example: – Intel/AMD x86 (PC) – IBM POWER (Macintosh a while back; big IBM machines) – Qualcomm MSM/ARM (cell phones) So, for example, a program in x86 assembly language cannot be directly run on a POWER machine. Set of simple commands; for example: – Load a value from a location in main memory – Add two numbers – Branch to an instruction out of sequence

5 Machine Languages Not human-readable, except with immense effort Binary code that the CPU family understands directly Binary representation of the CPU family’s assembly language

6 Converting Between Languages Compilers, interpreters and assemblers are programs that convert human-readable source code into machine-readable executable code.

7 Compiler Converts a human-readable high level language source code of a program into a machine language executable program Converts an entire source code all at once Must be completed before executing the program Examples: Fortran 90, C, C++, Pascal

8 Interpreter Converts a human-readable high level language source code into actions that are immediately performed Converts and executes one statement at a time

9 Assembler Converts a human-readable CPU-specific assembly code into CPU-specific, non-human- readable machine language Like a compiler, but for a low level assembly language instead of for a high level language

10 Our Old Friend hello_world.c % cat hello_world.c /* ************************************************* *** Program: hello_world *** *** "Hello, world!" to standard output. *** ************************************************* */ #include int main () { /* main */ /* ******************************** *** Execution Section (body) *** ******************************** * * Print the sentence to standard output * (i.e., to the terminal screen). */ printf("Hello, world!\n"); } /* main */

11 Compiler Details

12 Compiler Details (cont’d)

13 Elements of a Compiler #1 Lexical Analyzer: identifies program’s “word” elements – Comments (ignored by compiler) – Keywords (for example, int, while ) – Constants (for example, 5, 0.725, "Hello, world!" ) – User-defined Identifiers (for example, addend ) – Operators; for example: Arithmetic: + - * / % Relational: == != >= Logical: && || !

14 Elements of a Compiler #2 Parser: determines the program’s grammar Semantic Analyzer: determines what the program does Intermediate Code Generator: expresses, as an assembly-like program, what the program does Optimizer: makes code more efficient (faster) Assembly Code Generator: produces the final assembly code that represents what the program does

15 Phases of Compiling Compiler Assembler: turns assembly code into machine code Linker/loader: turns machine code into an executable file Both the assembler and the linker/loader are invoked automatically by the compiler, so you don’t have to worry about them.

16 Compiling a C Statement

17 Machine Code for hello_world.c

18 Why Not Do Everything in Machine Language? Incredibly tedious and ridiculously error-prone! Fun and easy! Not nearly as tedious or error-prone!

19 Why Not Do Everything in Assembly Language? Can’t be run on any other kind of computer. Portable to many kinds of computers. Will still be useable in 20 years (“legacy” codes).

20 The Programming Process Formulate Problem Construct Algorithm Choose Programming Language Write Program Compile Run Debug Get an A/Impress Your Boss Bugs? No Yes No Yes

21 What is an Algorithm? An algorithm is: a step-by-step method that is written in a natural language (for example, English) or in pseudocode (something that sort of looks like a programming language but isn’t as accurate), rather than in a programming language, that solves a well-defined (but not necessarily useful) problem, on a well-defined set of inputs using finite resources (for example, computing time and storage), and that produces a well-defined set of outputs.

22 Algorithms An algorithm is a language-independent way of expressing the method of solving a problem; that is, an algorithm could be expressed in two different languages (for example, English and Japanese) and still be the same algorithm. A program, by contrast, is a language-dependent implementation of the method of solving a problem; that is, the same set of steps expressed in two different programming languages would be two different programs, even if the two programs accomplished exactly the same result.