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



Similar documents
BEST WEB PROGRAMMING LANGUAGES TO LEARN ON YOUR OWN TIME

Programming Languages

Evolution of the Major Programming Languages

Chapter 12 Programming Concepts and Languages

Programming Languages

CSE 130 Programming Language Principles & Paradigms

1/20/2016 INTRODUCTION

CS 40 Computing for the Web

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

C# and Other Languages

Chapter 13: Program Development and Programming Languages

CS 6371: Advanced Programming Languages

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

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

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

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

MEAP Edition Manning Early Access Program Nim in Action Version 1

1. Overview of the Java Language

Busy Java Developer's Guide to Functional Programming. Ted Neward Neward & Associates

Web 2.0 Technology Overview. Lecture 8 GSL Peru 2014

CSE 307: Principles of Programming Languages

What is a programming language?

The programming language C. sws1 1

Habanero Extreme Scale Software Research Project

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

General Introduction

Chapter 3.2 C++, Java, and Scripting Languages. The major programming languages used in game development.

Testing Automation for Distributed Applications By Isabel Drost-Fromm, Software Engineer, Elastic

Semantic Analysis: Types and Type Checking

Parrot in a Nutshell. Dan Sugalski dan@sidhe.org. Parrot in a nutshell 1

Objectif. Participant. Prérequis. Remarque. Programme. C# 3.0 Programming in the.net Framework. 1. Introduction to the.

What Perl Programmers Should Know About Java

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

Fall 2012 Q530. Programming for Cognitive Science

THE ROAD TO CODE. ANDROID DEVELOPMENT IMMERSIVE May 31. WEB DEVELOPMENT IMMERSIVE May 31 GENERAL ASSEMBLY

Shark Installation Guide Week 3 Report. Ankush Arora

Effective Java Programming. efficient software development

Instructor Özgür ZEYDAN BEU Dept. of Enve. Eng. CIV 112 Computer Programming Lecture Notes (1)

Business Information System Courses Description

YouTrack MPS case study

CSC Software II: Principles of Programming Languages

CSCI 3136 Principles of Programming Languages

02 B The Java Virtual Machine

Software: Systems and. Application Software. Software and Hardware. Types of Software. Software can represent 75% or more of the total cost of an IS.

CSCI E 98: Managed Environments for the Execution of Programs

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

CS 106 Introduction to Computer Science I

Introduction to Python

No no-argument constructor. No default constructor found

Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!

What is a stack? Do I need to know?

How to Design and Create Your Own Custom Ext Rep

The Decaffeinated Robot

Programming Language Inter-conversion

Database Management System Choices. Introduction To Database Systems CSE 373 Spring 2013

Overview. Elements of Programming Languages. Advanced constructs. Motivating inner class example

Dynamic Web Programming BUILDING WEB APPLICATIONS USING ASP.NET, AJAX AND JAVASCRIPT

Short notes on webpage programming languages

Semester Review. CSC 301, Fall 2015

Kotlin for Android Developers

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

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

Lecture 1: Introduction

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

CSC 551: Web Programming. Spring 2004

Java Application Developer Certificate Program Competencies

Efficiency of Web Based SAX XML Distributed Processing

Getting Started with the Internet Communications Engine

Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111

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

Why (and Why Not) to Use Fortran

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

Developing Embedded Software in Java Part 1: Technology and Architecture

2! Multimedia Programming with! Python and SDL

Introductory Concepts

by Pearson Education, Inc. All Rights Reserved.

opalang - Rapid & Secure Web Development

ASP &.NET. Microsoft's Solution for Dynamic Web Development. Mohammad Ali Choudhry Milad Armeen Husain Zeerapurwala Campbell Ma Seul Kee Yoon

The Need for Fourth Generation Static Analysis Tools for Security From Bugs to Flaws

An Easier Way for Cross-Platform Data Acquisition Application Development

Java (12 Weeks) Introduction to Java Programming Language

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Chapter 13: Program Development and Programming Languages

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

Thesis Proposal: Improving the Performance of Synchronization in Concurrent Haskell

Beyond the Mouse A Short Course on Programming

Programming Language Concepts for Software Developers


Crash Course in Java

Programming Languages

CPU Organization and Assembly Language

Trollhättan, Sweden

Programming Languages CIS 443

Structure of Presentation. The Role of Programming in Informatics Curricula. Concepts of Informatics 2. Concepts of Informatics 1

Programming Languages & Tools

Transcription:

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

What is a Programming Language? A set of symbols and associated tools that translate (if necessary) collections of symbols into instructions to a machine Compiler, execution platform (e.g. Java Virtual Machine) Designed by someone or some people Syntax Can have flaws, poor decisions, mistakes What combinations of symbols are allowed Semantics What those combinations mean These can be defined in different ways for different languages There are a lot of languages Wikipedia lists 675 excluding dialects of BASIC and esoteric languages 2

Before High-Level Languages Everything done machine code or an assembly language Arithmetic operations (add, multiply, etc.) Memory operations (storing, loading) Control operations (jump, branch) Example: move 8-bit value into a register 1101 is binary code for move followed by 3-bit register id 1101000 01100001 B0 61 MOV AL, 61h ; Load AL with 97 decimal (61 hex) 3

Programming Language timeline C: 1973 C++: 1980 MATLAB: 1984 Objective-C: 1986 Mathematic (Wolfram): 1988 Python: 1991 Ruby: 1993 Java: 1995 Javascript: 1995 PHP: 1995 C#: 2001 Scala: 2003 4

Choosing a Programming Language Most of the time you won t have a choice about what programming language to use Software is already written in a particular language Platform requires a specific language (Objective-C for ios) Language required by computational tool (Mathematica, etc.) Still important to understand capabilities and limitations of language When you do get to choose, your choice can have tremendous impact This is despite theoretical equivalence! 5

Turing Completeness A programming language is said to be Turing complete if it can compute every computable function Famous non-computable function is the Halting Problem So every Turing complete language can approximately simulate every other Turing complete language (do the same stuff) Virtually every programming language you might encounter is Turing complete Data or markup languages (e.g. JSON, XML, HTML) are an exception So a choice of language is about how computation is described, not about what it s possible to compute 6

What we might want from a Language Readable (good syntax, intuitive semantics) High-level of abstraction (but still possible to access low level) Fast Good concurrency and parallelism Portable Manage side effects Expressive Make dumb things hard Secure Provably correct etc. 7

Type System Collection of rules to assign types to elements of the language Values, variables, functions, etc. The goal is to reduce bugs Logic errors, memory errors Governed by type theory, an incredibly deep and complex topic The type safety of a language is the extent to which its type system prevents or discourages relevant type errors Via type checking We ll cover the following questions: When does the type system check? What does the type system check? What do we have to tell the type system? 8

When Does It Check? Static type checking Static type-checking (check at compile-time) Based on source code (program text) If program passes, it s guaranteed to satisfy some typesafety properties on all possible inputs Catches bugs early (program doesn t have to be run) Possibly better run-time performance Less (or no) checking to do while program runs Compiler can optimize based on type Not all useful features can be statically checked Many languages use both static and dynamic checking 9

When Does it Check? Dynamic type checking Dynamic type-checking (check at run-time) Performed as the program is executing Often tag objects with their type information Look up type information when performing operations Possibly faster development time edit-compile-test-debug cycle Fewer guarantees about program correctness 10

What Does it Check? Nominal type system (name-based type system) Equivalence of types based on declared type names Objects are only subtypes if explicitly declared so Can be statically or dynamically checked Structural type system (property-based type system) Equivalence of types based on structure/definition An element A is compatible with an element B if for each feature in B s type, there s an identical feature in A s type Duck typing Not symmetric, subtyping handled similarly Type-checking only based on features actually used Only generates run-time errors 11

How Much do we Have to Tell it? Type Inference Automatically determining the type of an expression Programmer can omit type annotations Instead of (in C++) std::vector<int>::const_iterator itr = myvec.cbegin() use (in C++11) auto itr = myvec.cbegin() Can make programming tasks easier Only happens at compile-time Otherwise, types must be manifest (always written out) 12

How Flexible is it? Type conversion (typecasting) Changing a value from one type to another, potentially changing the storage requirements Reinterpreting the bit pattern of a value from one type to another Can happen explicitly or implicitly double da = 3.3 double db = 3.3; double dc = 3.4; int result = (int)da + (int)db + (int)dc; int result = da + db + dc; 13

What Does it All Mean? Most of these distinctions are not mutually exclusive Languages that do static type-checking often have to do some dynamic type-checking as well Some languages use a combination of nominal and duck typing Terminology is useful for describing language characteristics The terms strong or weak typing are often applied These lack any formal definition Languages aren t necessarily limited to official tools 14

Memory Safety Memory errors Buffer overflow Dynamic Uninitialized variables Out of memory Often closely tied to type safety Can be checked at compile-time or run-time (or not at all) Memory can be managed manually or automatically Garbage collection is a type of automatic management Some languages make use of both 15

Programming Paradigms A programming paradigm describes some fundamental way of constructing and organizing computer programs A programming language supports one or more paradigms Imperative A program is a series of statements that explicitly change the program state. Declarative A program describes what should happen without describing how it happens Functional (can be considered a type of declarative) Computation done by evaluation of functions, avoiding state and mutable data Object-oriented (as opposed to procedural) Computation done via objects (containing data and methods) 16

Language Development Many attempts to develop a universal language have failed due to diverse needs program size, programmer expertise, program requirements, program evolution, and personal taste Languages often change over time Generics were added to Java 9 years after initial release Take extreme care not to break existing code One standard, many implementations Standard defines syntax and semantics Whether a language will become popular is unpredictable Some research suggests things like library availability and social factors may be more important than language features 17

Java Age: 19 years Developer: Oracle Corporation Paradigms: imperative, object-oriented Type system: static, nominative, manifest One of the most popular languages in use today Lots of great tools and other resources Write Once, Run Anywhere approach (via JVM) Used to be considered slow, improved by JIT optimization Other languages using JVM (Scala, Jython, Clojure, Groovy) Can be quite verbose Sees lots of use in large-scale enterprise software I like Java (I ve used it a lot). Some people hate java. 18

C/C++ Age: 42/31 years Developer: International Organization for Standardization Paradigms: imperative, procedural, object-oriented (C++ only) Type system: static, nominative, manifest (C++11 has inference) Two of the most popular languages in use today Closer to the hardware than Java Used where predictable resource use is necessary OS, graphics, games, compilers Manual memory management, less protection from memory errors, sometimes inscrutable compiler errors Generally easier to do dumb things I ve used C/C++ for systems programming and for building graphics/vision applications. 19

20

C# Age: 14 years Developer: Microsoft Paradigms: imperative, object-oriented, functional Type system: static, nominative, partially inferred optionally dynamic Runs on the.net Framework Provides things like garbage collection (similar to the JVM) Allows access to system functions with unsafe keyword Less verbose than Java, safer than C++ Primary use is writing Windows applications I have programmed a little in C# (when at Microsoft), but Windows-only can be a big drawback 21

Haskell Age: 24 years Developer: many (research language) Paradigm: pure functional, lazy evaluation Type system: static, inferred Pure functional programming is a different way of thinking maybe liberating, maybe frustrating Functional programming has seen only limited industrial use Safer and more transparent than an imperative language Same function with same args always returns same value Allows for compiler optimizations Performance suffers as hardware better suited to mutable data I think functional programming is fascinating, and enough languages include functional elements to make it worth learning 22

SQL (Structured Query Language) Age: 40 years Developer: ISO Paradigms: declarative Type system: static Used as a database query language Declarative paradigm perfect for this application Using SQL is both easy and very powerful If you have a lot of data, definitely consider using free database software like MySQL 23

Python Age: 23 years Developer: Python Software Foundation Paradigm: imperative, object-oriented, functional, procedural Type system: dynamic, duck Has a Read-Eval-Print-Loop (REPL) Useful for experimenting or one-off tasks Scripting language Supports scripts, small programs run without compilation Often used in web development or scientific/numeric computing Variables don t have types, only values have types Whitespace has semantic meaning Lack of variable types and compile-time checks mean more may be required of documentation and testing Python is my language of choice for accomplishing small tasks 24

JavaScript Age: 19 years Developer: Mozilla Foundation Paradigm: imperative, object-oriented, functional, procedural Type system: dynamic, duck Also a scripting language (online/browser REPLs exist) Primary client-side language of the web Takes a continue at any cost approach Shared by many web-focused languages (PHP, HTML) Things that would be errors in other languages don t stop execution, and are allowed to fail silently JavaScript is nice for simple things, immediately running on the web is great, but doing larger/more complex software is terrible 25

PHP Age: 19 years Developer: The PHP Group Paradigm: imperative, object-oriented, functional, procedural Type system: dynamic Works with Apache (>50% all websites), so very common server-side language Minimal type system, lots of strange behavior, just awful If two strings are compared with ==, PHP will silently cast them to numbers (0e45h7 == 0w2318 evaluates to true) I hope none of you will ever have to use (or choose to use) PHP 26