Programming Languages

Similar documents
CSCI 3136 Principles of Programming Languages

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

Compiler I: Syntax Analysis Human Thought

Lab Experience 17. Programming Language Translation

Compiler Construction

1/20/2016 INTRODUCTION

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

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

Semantic Analysis: Types and Type Checking

Chapter 13: Program Development and Programming Languages

An Introduction to Computer Science and Computer Organization Comp 150 Fall 2008

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

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

2) Write in detail the issues in the design of code generator.

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

Chapter 6: Programming Languages

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

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

Compiler Construction

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

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

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

OKLAHOMA SUBJECT AREA TESTS (OSAT )

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

Introduction to Software Paradigms & Procedural Programming Paradigm

Code Kingdoms Learning a Language

MICHIGAN TEST FOR TEACHER CERTIFICATION (MTTC) TEST OBJECTIVES FIELD 050: COMPUTER SCIENCE

Language Processing Systems

(Refer Slide Time: 00:01:16 min)

Base Conversion written by Cathy Saxton

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science

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

Parsing Technology and its role in Legacy Modernization. A Metaware White Paper

Lecture 1: Introduction

Programming Project 1: Lexical Analyzer (Scanner)

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

Lecture 9. Semantic Analysis Scoping and Symbol Table

Programming Languages

Lesson 06: Basics of Software Development (W02D2

CA Compiler Construction

MACHINE ARCHITECTURE & LANGUAGE

Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration

Chapter 12 Programming Concepts and Languages

CS 40 Computing for the Web

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

COMPUTER SCIENCE TRIPOS

1.1 WHAT IS A PROGRAMMING LANGUAGE?

Chapter 13: Program Development and Programming Languages

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

Glossary of Object Oriented Terms

Computer Programming I

Lexical Analysis and Scanning. Honors Compilers Feb 5 th 2001 Robert Dewar

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

50 Computer Science MI-SG-FLD050-02

COMPUTER SCIENCE (5651) Test at a Glance

Operating Systems. Notice that, before you can run programs that you write in JavaScript, you need to jump through a few hoops first

03 - Lexical Analysis

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

XML Processing and Web Services. Chapter 17

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

Course MS10975A Introduction to Programming. Length: 5 Days

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

CS101 Lecture 26: Low Level Programming. John Magee 30 July 2013 Some material copyright Jones and Bartlett. Overview/Questions

CPU Organisation and Operation

02 B The Java Virtual Machine

CS 51 Intro to CS. Art Lee. September 2, 2014

CSE 130 Programming Language Principles & Paradigms

Programming Languages

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Python Programming: An Introduction to Computer Science

Cobol. By: Steven Conner. COBOL, COmmon Business Oriented Language, one of the. oldest programming languages, was designed in the last six

It is the thinnest layer in the OSI model. At the time the model was formulated, it was not clear that a session layer was needed.

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

The C Programming Language course syllabus associate level

İSTANBUL AYDIN UNIVERSITY

Object-Oriented Software Specification in Programming Language Design and Implementation

Managing Variability in Software Architectures 1 Felix Bachmann*

Lumousoft Visual Programming Language and its IDE

CS Matters in Maryland CS Principles Course

Notes on Assembly Language

Image credits:

A Python Tour: Just a Brief Introduction CS 303e: Elements of Computers and Programming

Levels of Programming Languages. Gerald Penn CSC 324

Limitations of Data Encapsulation and Abstract Data Types

1. What are Data Structures? Introduction to Data Structures. 2. What will we Study? CITS2200 Data Structures and Algorithms

Pattern Insight Clone Detection

Software: Systems and Application Software

Database Programming with PL/SQL: Learning Objectives

Figure 1: Graphical example of a mergesort 1.

02-201: Programming for Scientists

Software Engineering

Programming Languages CIS 443

CSE 307: Principles of Programming Languages

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

KS3 Computing Group 1 Programme of Study hours per week

Transcription:

Programming Languages Programming languages bridge the gap between people and machines; for that matter, they also bridge the gap among people who would like to share algorithms in a way that immediately allows others to study and execute those algorithms on a machine Put another way, the area of programming languages is where these ideas meet: The way a machine operates at a low level The algorithms that people design The desire to get machines to perform these algorithms Programming Language Evolution Recall that computers only really understand bits; a machine language defines the basic operations that a computer can perform Over time, we ve tried to make things easier for people to express programs: Assembly language Replaces numeric instructions with mnemonic abbreviations (e.g., mov instead of 0100; addi instead of 0101) High level languages Adds more concepts that are closer to how we (people) understand, represent, and express our ideas The search hasn t ended we keep looking for easier and more reliable ways to express algorithms

From Language to Bits So how do we get from this: var total = 0; var n = 252; var i = 0; while (i < n) { total = total + i; i = i + 1; } to this (using a hypothetical machine language where 1 is assign, b is branch, a is add, and 2 is jump ): 1500 16fc 1700 b476 aa57 ab71 2ffe 5000 As a reminder, hex is just a more compact binary: 0001 0101 0000 0000 0001 0110 1111 1100 0001 0111 0000 0000 1011 0011 0111 0110 1010 1010 0101 0111 1010 1011 0111 0001 0010 1111 1111 1110 0101 0000 0000 0000 Central to programming languages is the need to translate the human-readable program (called source code) into a computer-readable (and runnable!) form There are two primary approaches to this translation: With compilation, a translator processes the source code once, and produces an executable that users then invoke once the executable is produced, the source code is no longer needed, at least until it s time to modify or improve the program With interpretation, a translator processes and performs the source code as it goes in a sense, the executable is determined along the way, and isn t saved into a separate form (JavaScript is interpreted, for example: the browser serves as its interpreter)

Machine or Platform Independence You may have noticed that JavaScript is not married to a specific type of machine or operating system this is because most platforms have a Web browser that can interpret JavaScript This is a nice side effect of programming language implementation it opens the possibility of machine or platform independence: the ability for the same source code to work well on different devices Note how machine or assembly language isn t that way: it has to run on the CPU for which it was written Interpreted languages attain platform independence when interpreters are available for multiple devices how about compiled languages, which produce executables for machines to read and run directly? There s actually a little white lie in the language translation example from the previous page: the translated version of a program doesn t immediately have to be CPU-level machine code Many languages compile their source code into intermediate byte code or p-code instead of a hardware machine language, this can be viewed as a software machine language This way, a software or virtual machine can be used to execute the code this is how Java is implemented

Programming Paradigms Somewhat analogously to how writers, artists, and musicians belong to certain styles or genres, it turns out that programming languages also tend to favor certain approaches or philosophies These approaches are referred to as programming paradigms and so far, we have actually only seen one such paradigm: the imperative or procedural paradigm Imperative or procedural programming views a program as a series of commands do this, then do that that affect some state-of-the-world Not surprisingly, the imperative approach is one of the oldest paradigms, since machines, at the physical level, are ultimately built that way: recall fetch-decode-execute It turns out that many other paradigms have evolved over the years, allowing us to write programs in ways other than do this, then do that: Declarative paradigm Perhaps the closest thing to an opposite of imperative programming, declarative programming focuses on stating what problem to solve instead of how to solve the problem This paradigm requires a general-purpose algorithm for solving a given problem; while there is no such thing for solving any possible problem, there are general algorithms for special classes of problems, such as database retrieval, simulation, and formal logic Functional paradigm This paradigm views a program as a set of self-contained units, each of which takes some input and produces some output; instead of doing things, this paradigm evaluates or calculates things Object-oriented (OO) paradigm This paradigm represents a program as a set of objects that interact with each other through their methods; it s the reigning industry paradigm as of now, with languages like Java, JavaScript, C#, and Objective-C all having OO capabilities

Programming Concepts It should be no surprise if the following ideas sound somewhat familiar we ve seen them all before This time, however, we address them from the perspective of how these constructs are common across many programming languages, though they may look different from one language to another This is ultimately the secret to being multilingual the ability to recognize ideas that are common from one language to another, even if those ideas are written or expressed in a different way Literals These are the directly-typed values in a language: numbers, text, booleans; some languages allow more complex literals such as arrays, maps, and objects Variables and assignments Of course, once we ve specified some values, we want to manipulate them; to do this, we assign them to the named boxes that are variables Expressions A key part of manipulating values is putting them together; these are expressions, which can vary widely in complexity (and readability!): a + b factorial(n) str[i++].substring(mark, length * 2) ((*handle)->location.x - screen->dimensions.x) / 2 Control flow Many algorithms require the ability to selectively control what to do next (as opposed to non-changing, linear sequences of activities); these elements fall under the category of control flow, and include conditional statements, loop constructs Data types The recurring theme of finding ways to make digital data (bits) easier for people to understand leads to the concept of data types, or how some set of bits must be interpreted: whether bits are interpreted as numbers, other times as text, and so on Procedures and functions Technically a part of control flow, but complex enough to merit their own mention, procedures and functions (or subroutines) allow us to abstract common activities under a single, reusable, named block of code Modules Old code never dies, they just get placed in modules: the module constructs in many languages allow us to organize our code into self-contained units, for easy reuse and encapsulation of private code from the rest of a program

Implementation Details If you think about it, the process of compiling or interpreting a programming language is yet another algorithm albeit one of the most complex and sophisticated ones around This subject of compiler construction is one of the final highlights of an undergraduate computer science education, and can be specialized upon even further in both graduate school and industry We won t say much more about it here, except to provide an overview of what a compiler does No need to sweat the details this is just meant to give you an idea of how a genuinely complex algorithm may look like: Character stream Scanner (lexical analysis) Token stream Parse tree Abstract syntax tree or other intermediate form Modified intermediate form Assembly, machine, or other target language Parser (syntax analysis) Semantic analysis, intermediate code generation Machine-independent code improvement Target code generation Symbol table front end back end Machine-specific code improvement Modified target language