Scala. Functional and Object-oriented Features. Stefan Hinterkörner, Andreas Rottmann

Size: px
Start display at page:

Download "Scala. Functional and Object-oriented Features. Stefan Hinterkörner, Andreas Rottmann"

Transcription

1 Scala Functional and Object-oriented Features Stefan Hinterkörner, Andreas Rottmann Seminar aus Informatik, SS 2010 o. Univ.-Prof. Dr. Wolfgang Pree Department of Computer Sciences, University of Salzburg July 12, 2010

2 Contents 1 Introduction 2 2 Functional Features Proper tail recursion Functions as first-class Values Syntactic Sugar Closures Currying and Control Abstraction Conclusion Object-oriented Features Abstract classes Extending classes Overriding methods and fields Traits Scala in the Real World Framework: Lift Application: Twitter

3 1 Introduction In this paper, we present a selection of advanced concepts of the Scala programming language. The reader is assumed to have some experience in Java, and preferably a basic understanding of Scala syntax. Scala is covered in detail in its de-facto reference [5]. In particuliar, the topics covered in the following are discussed by [5] in Chapters 8, 9, 10 and 12. We conclude with Section 4, giving two examples of Scala usage in the real world. 2

4 2 Functional Features Before looking at the features that make Scala worthy of the predicate functional programming language, it is illustrative to have a short look at what exactly constitutes the functional programming paradigm. Essentially, a functional language emphasizes the application of functions over the explicit manipulation of state, as is the case with imperative programming languages. The use of assignment statements to change the implicit state of a program is a primary symptom of an imperative programming style. A functional program, on the other hand, explicitly passes state around, and eschews assignment statements completely [3]. Clearly, Scala supports the imperative style, inheriting from the Java tradition, but it also allows for a functional style. For example, consider the imperative and functional implementations of the factorial given in Figure 1 and Figure 2, respectively. Note that the functional definition of factorial does not use assignment statements, only variable binding; all variables occurring in the program are immutable vals, whereas the imperative version relies on mutation and vars. Another notable thing about the functional version is the use of the local, nested function definition fact, a feature that is not available in Java. def factorial(n: Int) = { var result = 1; var i = n; while (i > 0) { result = result * i i = i - 1 result; Figure 1: Imperative factorial 2.1 Proper tail recursion An attentive reader will have noticed that the local function fact is recursive, and may have wondered about the space and time overhead; after all, each recursive call will need to allocate a stack frame and also be more expensive 3

5 def factorial(n: Int) = { def fact(acc: Int, n: Int): Int = { if (n > 0) fact(n * acc, n - 1) else acc fact(1, n) Figure 2: Functional factorial in terms of time than the jump implied by the while loop in the imperative version, right? Actually, neither is the case for this example: the Scala compiler will eliminate the recursion, thus yielding equivalent performance characteristics for both programs. This important optimization can only be applied in special circumstances, however: 1. The recursive call must be the final expression to be evaluated in the function; there must be no further work remaining to be done before the function returns. This is also referred to as the call being in tail position. 2. The call must be directly recursive, calls to other functions will indeed require stack frame allocation, even if they are in tail position. The first of these requirements is fundamental: a stack frame needs to be created if there is further work to be done inside the calling function, otherwise the calling function could not be resumed after the called function has returned. The second requirement, however, is a limitation of Scala (or, to be fair, of the underlying Java Virtual Machine); in languages like ML[4] or Scheme[1], this restriction is lifted, and all calls in tail position are optimized. 2.2 Functions as first-class Values Another hallmark of functional languages, besides their disregard for mutability, is that they elevate functions into first-class citizen status: functions 4

6 can be treated just like any other value, for example, they can be passed as arguments to other functions and can be stored in data structures. The following example shows the syntax for expressing function literals; they are written as the type signature of the function followed by an arrow (=>) and the body of the function: val add3 = (x: Int) => x + 3 add3(4) // evaluates to 7 This syntax allows for the concise specialization of a general function by passing it appropriate functions as parameters. For instance, to find all numbers divisible by three in a Scala collection, one can use the filter method of the Iterable trait 1, which will return a new Iterable containing only elements matching the predicate passed to it: val input = List(2, 3, 5, 6, 7, 9) val result = input.filter((x: Int) => x % 3 == 0) In the above example, result will contain 3, 6 and 9. Another illustration for the power and usefulness of first-class functions is given in Figure 3, which could be part of a simple calculator, where run-time lookup of operators is needed. val builtinops = Map("+" -> ((x: Int, y: Int) => x + y), "-" -> ((x: Int, y: Int) => x - y), "*" -> ((x: Int, y: Int) => x * y), "/" -> ((x: Int, y: Int) => x / y)) builtinops("*")(6, 7) // evaluates to 42 Figure 3: A map containing functions Syntactic Sugar Scala allows for some ways to shorten the notation of function literals: In certain contexts, Scala can infer the parameter types, hence the types can be left out in these cases. The parentheses around a parameter whose type is inferred may be omitted. 1 Traits will be discussed in more detail in Section

7 Placeholder syntax allows parameters in the body of a function literal to be replaced by underscores, and the parameter list and arrow to be omitted. This is only feasible when each parameter occurs once in the body, of course. _ + _ // is the same as: (x, y) => x + y Partially applied functions are a way derive a function from an existing function by fixing some of its parameters: def max(x:int, y:int) = if (x > y) x else y val atleast5 = max(_: Int, 5) atleast5(4) // results in 5 atleast5(42) // results in 42 One can also specify a placeholder for the whole argument list using the following syntax: List(1, 2, 3).foreach(println _) Note the omission of the parentheses around the underscore Closures Scala also supports closures, functions that refer to variables from their enclosing scope or scopes. An example is provided in Figure 4. Similiar to the code given above, it finds multiples of a given number, however this time the number is not a constant, but a variable defined in an outer scope. The function expression is said to close over (or be a closure over) the variable n. A closure can also be returned from a function, as in Figure 5. In this case, the variables closed over have an extent (lifetime) that exceeds the duration of the call to the function that declares them. In Figure 5, the variable amount is available to the closure after makeadder has returned. Closures can be used to encapsulate state, similiar to a class instance. There is a saying, Classes are a poor man s closures, attributed to Norman Adams in a paper by Kenneth Dickey[2], which shows how once you have closures, 2 In most functional languages, there is no special syntax needed for this case, as you can just pass the function itself as an argument, without having to construct a partially applied function. See [5], Section 8.7 for a rationale of why the trailing underscore is needed in Scala. 6

8 def multiples(n: Int, collection: Iterable[Int]) = { collection.filter((x: Int) => x % n == 0); val result = multiples(3, List(2, 3, 5, 6, 7, 9)) def makeadder(amount: Int) = { (x: Int) => x + amount val add3 = makeadder(3) add3(4) // evaluates to 7 Figure 4: A closure in action Figure 5: Returning a closure you can implement a variety of Object Models, including classical ones like the one found in Java. We ll leave aside how to implement inheritance and other advanced concepts, and just provide a small example to illustrate state encapsulation with closures. Figure 6 shows a simple counter, implemented as a single-method Scala class, while Figure 7 shows the same mechanism implemented with a closure. Note that like in makeadder above, makecounter returns a closure, but this time it closes over the var counter and mutates that, in the same way the count method mutates the instance variable counter. In fact, with a bit of squinting, the closure version looks almost the same as the class-based version. 2.4 Currying and Control Abstraction Currying in Scala allows the programmer to write functions returning functions in a more concise way; instead of specifying a single argument list for a function, multiple ones may be specified. In Figure 8, the curried function curriedtimes is defined, then fully applied to compute a numerical result. After that, it is partially applied (only the first argument list is specified), yielding a function that will multiply its argument by three. Curried functions are employed in Scala to facilitate writing new control abstractions that look like being built right into the language. As Scala allows 7

9 class Counter(start: Int) { var counter = start def count() = { val result = counter counter = counter + 1 result val c1 = new Counter(0) val c2 = new Counter(5) for (i <- 1 to 3) { println("c1.count() = " + c1.count()) println("c2.count() = " + c2.count()) Figure 6: A simple counter class Figure 7: A counting closure def makecounter(start: Int): () => Int = { var count = start () => { val result = count count = count + 1 result val c1 = makecounter(0) val c2 = makecounter(5) for (i <- 1 to 3) { println("c1() = " + c1()) println("c2() = " + c2()) 8

10 def curriedtimes(x: Int)(y: Int) = x * y curriedtimes(6)(7) // evaluates to 42 val times3 = curriedtimes(3)_ times3(5) // evaluates to 15 Figure 8: A curried function parentheses to be replaced by curly brackets for argument lists that consist of a single argument, and curried functions can be used to break the argument list into pieces, natural-looking control abstractions can be written. For example, consider Figure 9, which implements a function withlock that executes an operation during which the specified lock is acquired. This example uses a further syntactic feature of Scala, by-name parameters, which allows leaving out an empty parameter list in a function signature, as is the case with op in the example. See [5], Section 9.5, more information about by-name parameters. import scala.concurrent.lock def withlock(lock: Lock)(op: => Unit) { lock.acquire try { op finally { lock.release val lock = new Lock() withlock(lock) { println("hello World!") Figure 9: Control abstraction 2.5 Conclusion Scala offers a range of features, most importantly first-class functions, that allow programming in a functional style, making Scala a multiple-paradigm 9

11 language. Using functional style makes reasoning about programs easier by avoiding manipulation of implicit state. Moreover, Scala allows for easy and concise expression of concepts such as new control operators which are not directly expressible in languages without support for functional programming (like Java). 10

12 3 Object-oriented Features This chapter will explain some advanced object-oriented aspects of Scala. First of all we will explore the differences between Java and Scala in Abstract classes, Overriding of methods/fields and Inheritance. The last section will explain so called Traits, a special variant of Mixins introduced in Scala. 3.1 Abstract classes Abstract classes are identified by the abstract modifier. It is written prior the class keyword and ensures that abstract classes cannot by instantiated. Abstract classes must have only declared methods. From this it follows that methods are not allowed to have an implementation. There is one exception to this rule: Parameterless methods. As you can see in Figure 10 the method height is implemented. Parameterless methods should be used whenever there are no parameters for the method and even more important, the method only reads fields of the containing object. Those methods are comparable to Java getter methods. We could write parameterless methods with parentheses, but if we leave the parentheses out we indicate that the method has no side-effect. abstract class Element { def contents: Array[String] def height: Int = contents.length Figure 10: Basic structure of an abstract class [5] 3.2 Extending classes To make a subclass of another class, like in Java, the extends keyword is used. When a plain class is written without inheriting any other class, Scala implicitly uses AnyRef. AnyRef is the root class of all Scala classes. If we create a subclass we have to note that private members of the superclass and members with the same name and parameters already implemented in the subclass are not inherited. Figure 11 demonstrates how we implement a subclass of our abstract class defined in the previous Figure. Now we are able to create an object out of the 11

13 new class with our methods defined in the superclass. Class ArrayElement is a subclass of Element and so we can use Subtyping to create a new object. class ArrayElement(conts: Array[String]) extends Element { def contents: Array[String] = conts val elem: Element = new ArrayElement(Array("hello")) Figure 11: Inheritance in Scala [5] 3.3 Overriding methods and fields In Scala fields and methods belong to the same namespace, i.e. if you have a superclass with a method write, you could simply override this method in a subclass with a field write. Thus it s not possible to define a field and method with the same name in the same class. To invoke superclass constructors we have to pass the parameters of the subclass to the superclass. This is done by placing the parameters in parentheses after the superclass name. In Scala we use the modifier override to override members of the superclass. It s compulsory and so almost solves the fragile base class problem. If you have a subclass with a method called test and later you add a method test to the superclass, the subclass will not compile. Thereupon you will notice that you have to check the subclass method and, if necessary, refactor it. Figure 12 is an excellent example to explain overriding in Scala and to demonstrate how well Java and Scala are working together. The example, written by Daniel Spiewak[7], shows us a Scala class StrikeLabel, which inherit from the Java class JLabel. It will display Text that is crossed out with a red line. As we can see in the first line, StrikeLabel passes the default constructor parameter text to the JLabels default constructor. Furthermore it invokes the default constructor with an empty String, if text is empty. Therefore it uses the this keyword. JLabel defines a method paintcomponent which takes a Graphics object as parameter. StrikeLabel overrides this method and invokes the superclass method by using the keyword super. 12

14 class StrikeLabel(text:String) extends JLabel(text) { def this() = this("") override def paintcomponent(g:graphics):unit = { super.paintcomponent(g) g.setcolor(color.red) g.drawline(1, getheight() / 2, getwidth() - 1, getheight() / 2) Figure 12: Mixing Scala Code with Java [7] 3.4 Traits Scala has its own special implementation of Mixins called Traits. A Mixin is a unit of functionality, which can be added to a class. A trait has to have the same base class as the class which uses the trait. Like in multiple inheritance a class can use any number of traits. Unlike multiple inheritance, traits do not cause a diamond problem because of linearization. We will see what linearization and traits are in the following example (inspired by Spiewak [7]). First we discuss the Java code in Figure 13 and later we will see the improved version written in Scala. Our starting point is an abstract class called Vehicle. It has a method getengine which returns the vehicles engine. Furthermore there are two interfaces called ICar and IPlane. Obviously ICar is able to drive and IPlane is able to fly. The class Car inherits from our abstract class Vehicle and implements interface ICar. Car has an engine and can drive. Plane is also a vehicle with an engine and has the ability to fly. Because we are enthusiastic drivers and pilots, so we want a flying Car. To build our FlyingCar we have to implement both interfaces IPlane and ICar. Skilled developers have already identified some code smells. First of all we have to implement the methods drive and fly multiple times. That s unpopular code duplication. Secondly the hierarchy is already a little bit complicated. In bigger application this can become confusing very fast. And lastly, its possible to create a Car or Plane without being a Vehicle. Looking at the Scala code in Figure 14 we see that there is also have an abstract class called Vehicle. Instead of the two interfaces we now have two traits. Traits inherit from a base class. In our case the base class is Vehicle. 13

15 public abstract class Vehicle { public abstract Engine getengine(); public interface ICar { public void drive(); public interface IPlane { public void fly(); public class Car extends Vehicle implements ICar { private Engine carengine; public Car(TyreType type) {... public Engine getengine() { return carengine; public void drive() {... public class Plane extends Vehicle implements IPlane { private Engine planeengine; public Plane(WingType type) {... public Engine getengine() { return planeengine; public void fly() {... public class FlyingCar extends Vehicle implements IPlane, ICar { public FlyingCar(WingType wingtype, TyreType tyretype) {... public Engine getengine() {... public void fly() {... public void drive() {... Figure 13: Java example 14

16 Both traits have their own engine. Trait car has an implemented method drive and trait Plane has a method fly. To create our FlyingCar we mix in both Traits. That s the point where linearization comes into play. Our FlyingCar has now two engines. One from Plane and the other one from Car. Which one will be used? Scala interprets traits from right to left. So, in the first example, the engine from Car is used because we mix in Car after Plane. In the other example, the engine from Plane is the winner. With the keyword with we can mix in as many traits as we want. There is one minor detail: Traits cannot have any class parameters. 15

17 abstract class Vehicle { def engine:engine trait Car extends Vehicle { private var carengine:engine =... override def engine = carengine def drive() = {... trait Plane extends Vehicle { private var planeengine:engine =... override def engine = planeengine class def fly() = {... FlyingCar(wingType:WingType, tyretype:tyretype) extends Plane with Car { class // engine from Car FlyingCar(wingType:WingType, tyretype:tyretype) extends Car with Plane { // engine from Plane Figure 14: Scala example 16

18 4 Scala in the Real World Learning a new programming language can be a waste of time, if the language disappears from the scene after a while. Existing frameworks and application with a active community can give you a reliable prediction about the future of a language. Scala is still young and has not (yet) a big community as other languages. However there are the well known Webframework Lift and the famous microblogging service Twitter. Both are (partly) written in Scala. 4.1 Framework: Lift Lift[6] is a Webframework fully written in Scala. Founder David Pollak has invented Lift to get an elegant framework for writing web applications. Because Lift is written in Scala you can use Java APIs and deploy your web application to a Servlet Container (e.g. Tomcat). By way of example location-based social networking website Foursquare is written in Lift. It is now available in Version 2 and licensed under the Apache 2.0 License. 4.2 Application: Twitter Social network Twitter was originally implemented in Ruby on Rails. It still uses Ruby on Rails for the web application, but the back-end services were replaced with Scala applications. Due to performance limitations at runtime the Twitter developers decided to switch. Main advantages they mentioned are basically the advantages of the JVM (Threads, long lived processes, Garbage collector, JIT,...) and the easy to maintain Scala Code with it s functional features. An interview with three Twitter developers can be read on artima.com[8]. 17

19 References [1] N. I. Adams, IV, D. H. Bartley, G. Brooks, R. K. Dybvig, D. P. Friedman, R. Halstead, C. Hanson, C. T. Haynes, E. Kohlbecker, D. Oxley, K. M. Pitman, G. J. Rozas, G. L. Steele, Jr., G. J. Sussman, M. Wand, and H. Abelson. Revised5 report on the algorithmic language scheme. SIGPLAN Not., 33(9):26 76, [2] Kenneth Dickey. Scheming with objects. ftp://ftp.cs.indiana.edu/ pub/scheme-repository/doc/pubs/swob.txt, [Online; 11. Juli 1010]. [3] Paul Hudak. Conception, evolution, and application of functional programming languages. ACM Comput. Surv., 21(3): , [4] Robin Milner, Mads Tofte, and David Macqueen. The Definition of Standard ML. MIT Press, Cambridge, MA, USA, [5] Martin Odersky, Lex Spoon, and Bill Venners. Programming in Scala: A Comprehensive Step-by-step Guide [6] David Pollak. Lift webframework [Online; 6. Juli 2010]. [7] Daniel Spiewak. Scala for java refugees. blog/scala/scala-for-java-refugees-part-3, [Online; 6. Juli 2010]. [8] Bill Venners. Twitter on scala. articles/twitter_on_scala.html, [Online; 6. Juli 2010]. 18

Scala. The scalabale Language. May 30, Department of Computer Sciences University of Salzburg. Functional Features Object oriented Features

Scala. The scalabale Language. May 30, Department of Computer Sciences University of Salzburg. Functional Features Object oriented Features Functional Features The scalabale Language Stefan Hinterkörner Andreas Rottmann Department of Computer Sciences University of Salzburg May 30, 2010 Overview Functional Features 1 Functional Features 2

More information

Programming in Scala Second Edition

Programming in Scala Second Edition Programming in Scala Second Edition Martin Odersky, Lex Spoon, Bill Venners artima ARTIMA PRESS WALNUT CREEK, CALIFORNIA Contents Contents List of Figures List of Tables List of Listings Foreword Foreword

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

Scala. Fernando Medeiros Tomás Paim

Scala. Fernando Medeiros Tomás Paim Scala Fernando Medeiros fernfreire@gmail.com Tomás Paim tomasbmp@gmail.com Topics A Scalable Language Classes and Objects Basic Types Functions and Closures Composition and Inheritance Scala s Hierarchy

More information

CPS 506 Comparative Programming Languages. Programming Language

CPS 506 Comparative Programming Languages. Programming Language CPS 506 Comparative Programming Languages Object-Oriented Oriented Programming Language Paradigm Introduction Topics Object-Oriented Programming Design Issues for Object-Oriented Oriented Languages Support

More information

Lecture 21: The Many Hats of Scala: OOP 10:00 AM, Mar 14, 2018

Lecture 21: The Many Hats of Scala: OOP 10:00 AM, Mar 14, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 21: The Many Hats of Scala: OOP 10:00 AM, Mar 14, 2018 Contents 1 Mutation in the Doghouse 1 1.1 Aside: Access Modifiers..................................

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

CSE 341, Autumn 2015, Ruby Introduction Summary

CSE 341, Autumn 2015, Ruby Introduction Summary CSE 341, Autumn 2015, Ruby Introduction Summary Disclaimer: This lecture summary is not necessarily a complete substitute for atting class, reading the associated code, etc. It is designed to be a useful

More information

Notes from a Short Introductory Lecture on Scala (Based on Programming in Scala, 2nd Ed.)

Notes from a Short Introductory Lecture on Scala (Based on Programming in Scala, 2nd Ed.) Notes from a Short Introductory Lecture on Scala (Based on Programming in Scala, 2nd Ed.) David Haraburda January 30, 2013 1 Introduction Scala is a multi-paradigm language that runs on the JVM (is totally

More information

Data Structures (list, dictionary, tuples, sets, strings)

Data Structures (list, dictionary, tuples, sets, strings) Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Week 13 - Part 1 Thomas Wies New York University Review Last lecture Object Oriented Programming Outline Today: Scala Sources: Programming in Scala, Second

More information

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017 Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable

More information

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

More information

Using Scala for building DSL s

Using Scala for building DSL s Using Scala for building DSL s Abhijit Sharma Innovation Lab, BMC Software 1 What is a DSL? Domain Specific Language Appropriate abstraction level for domain - uses precise concepts and semantics of domain

More information

Scala, Your Next Programming Language

Scala, Your Next Programming Language Scala, Your Next Programming Language (or if it is good enough for Twitter, it is good enough for me) WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing

More information

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction Lecture 13: Object orientation Object oriented programming Introduction, types of OO languages Key concepts: Encapsulation, Inheritance, Dynamic binding & polymorphism Other design issues Smalltalk OO

More information

Lecture Notes on Programming Languages

Lecture Notes on Programming Languages Lecture Notes on Programming Languages 85 Lecture 09: Support for Object-Oriented Programming This lecture discusses how programming languages support object-oriented programming. Topics to be covered

More information

Java Fundamentals (II)

Java Fundamentals (II) Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Java Fundamentals (II) Marco Piccioni static imports Introduced in 5.0 Imported static members of a class

More information

Unifying functional and object-oriented programming with Scala 齐琦, 海南大学计算机发展前沿系列课程

Unifying functional and object-oriented programming with Scala 齐琦, 海南大学计算机发展前沿系列课程 Unifying functional and object-oriented programming with Scala, 海南大学计算机发展前沿系列课程 2 原文引用 Odersky, M. and T. Rompf (2014). "Unifying functional and objectoriented programming with Scala." Communications of

More information

JVM ByteCode Interpreter

JVM ByteCode Interpreter JVM ByteCode Interpreter written in Haskell (In under 1000 Lines of Code) By Louis Jenkins Presentation Schedule ( 15 Minutes) Discuss and Run the Virtual Machine first

More information

Overview. Elements of Programming Languages. Objects. Self-Reference

Overview. Elements of Programming Languages. Objects. Self-Reference Overview Elements of Programming Languages Lecture 10: James Cheney University of Edinburgh October 23, 2017 Last time: programming in the large Programs, packages/namespaces, importing Modules and interfaces

More information

Java: introduction to object-oriented features

Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

CS205: Scalable Software Systems

CS205: Scalable Software Systems CS205: Scalable Software Systems Lecture 4 September 14, 2016 Lecture 4 CS205: Scalable Software Systems September 14, 2016 1 / 16 Quick Recap Things covered so far Problem solving by recursive decomposition

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

Functional Programming Principles in Scala. Martin Odersky

Functional Programming Principles in Scala. Martin Odersky Functional Programming Principles in Scala Martin Odersky Programming Paradigms Paradigm: In science, a paradigm describes distinct concepts or thought patterns in some scientific discipline. Main programming

More information

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

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring

More information

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing

More information

BBM 102 Introduction to Programming II Spring Inheritance

BBM 102 Introduction to Programming II Spring Inheritance BBM 102 Introduction to Programming II Spring 2018 Inheritance 1 Today Inheritance Notion of subclasses and superclasses protected members UML Class Diagrams for inheritance 2 Inheritance A form of software

More information

CS558 Programming Languages Winter 2013 Lecture 8

CS558 Programming Languages Winter 2013 Lecture 8 OBJECT-ORIENTED PROGRAMMING CS558 Programming Languages Winter 2013 Lecture 8 Object-oriented programs are structured in terms of objects: collections of variables ( fields ) and functions ( methods ).

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

Classes and Methods גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון

Classes and Methods גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון Classes and Methods גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון 2 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static, compile time representation of object-oriented

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Object-Oriented

More information

Scala : an LLVM-targeted Scala compiler

Scala : an LLVM-targeted Scala compiler Scala : an LLVM-targeted Scala compiler Da Liu, UNI: dl2997 Contents 1 Background 1 2 Introduction 1 3 Project Design 1 4 Language Prototype Features 2 4.1 Language Features........................................

More information

Classes and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון

Classes and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון Classes and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון 22 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static, compile time representation of object-oriented

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 6a Andrew Tolmach Portland State University 1994-2016 Functional Programming An alternative paradigm to imperative programming First-class functions Emphasis

More information

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen COP4020 Programming Languages Functional Programming Prof. Robert van Engelen Overview What is functional programming? Historical origins of functional programming Functional programming today Concepts

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information

Programming Languages Third Edition. Chapter 7 Basic Semantics

Programming Languages Third Edition. Chapter 7 Basic Semantics Programming Languages Third Edition Chapter 7 Basic Semantics Objectives Understand attributes, binding, and semantic functions Understand declarations, blocks, and scope Learn how to construct a symbol

More information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION Instructors: Crista Lopes Copyright Instructors. Topics Recursion Higher-order functions Continuation-Passing Style Monads (take 1) Identity Monad Maybe

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Lecture content. Course goals. Course Introduction. TDDA69 Data and Program Structure Introduction

Lecture content. Course goals. Course Introduction. TDDA69 Data and Program Structure Introduction Lecture content TDDA69 Data and Program Structure Introduction Cyrille Berger Course Introduction to the different Programming Paradigm The different programming paradigm Why different paradigms? Introduction

More information

Overview. Elements of Programming Languages. Objects. Self-Reference

Overview. Elements of Programming Languages. Objects. Self-Reference Overview Elements of Programming Languages Lecture 11: James Cheney University of Edinburgh November 3, 2015 Last time: programming in the large Programs, packages/namespaces, importing Modules and interfaces

More information

Compiler Construction Lent Term 2015 Lectures 10, 11 (of 16)

Compiler Construction Lent Term 2015 Lectures 10, 11 (of 16) Compiler Construction Lent Term 15 Lectures 10, 11 (of 16) 1. Slang.2 (Lecture 10) 1. In lecture code walk of slang2_derive 2. Assorted topics (Lecture 11) 1. Exceptions 2. Objects 3. Stacks vs. Register

More information

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014 Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class

More information

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java

More information

JavaScript: Sort of a Big Deal,

JavaScript: Sort of a Big Deal, : Sort of a Big Deal, But Sort of Quirky... March 20, 2017 Lisp in C s Clothing (Crockford, 2001) Dynamically Typed: no static type annotations or type checks. C-Like Syntax: curly-braces, for, semicolons,

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Java. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)

Java. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2) Summary: Chapters 1 to 10 Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu

More information

STRUCTURING OF PROGRAM

STRUCTURING OF PROGRAM Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Exercise 6 Multiple Inheritance, Multiple Dispatch and Linearization November 4, 2016

Exercise 6 Multiple Inheritance, Multiple Dispatch and Linearization November 4, 2016 Concepts of Object-Oriented Programming AS 2016 Exercise 6 Multiple Inheritance, Multiple Dispatch and Linearization November 4, 2016 Task 1 Consider the following C++ program: class X X(int p) : fx(p)

More information

Continuations and Continuation-Passing Style

Continuations and Continuation-Passing Style Continuations and Continuation-Passing Style Lecture 4 CS 390 1/16/08 Goal Weʼre interested in understanding how to represent the state of a co-routine Insight into what a thread really means How fundamental

More information

C++ Programming Fundamentals

C++ Programming Fundamentals C++ Programming Fundamentals 269 Elvis C. Foster Lecture 11: Templates One of the contemporary sophistries of C++ programming is defining and manipulating templates. This lecture focuses on this topic.

More information

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Nicolas Bettenburg 1 Universitaet des Saarlandes, D-66041 Saarbruecken, nicbet@studcs.uni-sb.de Abstract. As traditional

More information

Data Abstraction. Hwansoo Han

Data Abstraction. Hwansoo Han Data Abstraction Hwansoo Han Data Abstraction Data abstraction s roots can be found in Simula67 An abstract data type (ADT) is defined In terms of the operations that it supports (i.e., that can be performed

More information

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc. Chapter 1 GETTING STARTED SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: Java platform. Applets and applications. Java programming language: facilities and foundation. Memory management

More information

Java Primer 1: Types, Classes and Operators

Java Primer 1: Types, Classes and Operators Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

Static type safety guarantees for the operators of a relational database querying system. Cédric Lavanchy

Static type safety guarantees for the operators of a relational database querying system. Cédric Lavanchy Static type safety guarantees for the operators of a relational database querying system Cédric Lavanchy June 6, 2008 Contents 1 Previous work 2 2 Goal 3 3 Theory bases 4 3.1 Typing a relation...........................

More information

The SPL Programming Language Reference Manual

The SPL Programming Language Reference Manual The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming

More information

Object-Oriented Design Lecture 16 CS 3500 Fall 2010 (Pucella) Friday, Nov 12, 2010

Object-Oriented Design Lecture 16 CS 3500 Fall 2010 (Pucella) Friday, Nov 12, 2010 Object-Oriented Design Lecture 16 CS 3500 Fall 2010 (Pucella) Friday, Nov 12, 2010 16 Mutation We have been avoiding mutations until now. But they exist in most languages, including Java and Scala. Some

More information

A Short Summary of Javali

A Short Summary of Javali A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Using Scala in CS241

Using Scala in CS241 Using Scala in CS241 Winter 2018 Contents 1 Purpose 1 2 Scala 1 3 Basic Syntax 2 4 Tuples, Arrays, Lists and Vectors in Scala 3 5 Binary output in Scala 5 6 Maps 5 7 Option types 5 8 Objects and Classes

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2017 Lecture 4a Andrew Tolmach Portland State University 1994-2017 Semantics and Erroneous Programs Important part of language specification is distinguishing valid from

More information

Self-review Questions

Self-review Questions 7Class Relationships 106 Chapter 7: Class Relationships Self-review Questions 7.1 How is association between classes implemented? An association between two classes is realized as a link between instance

More information

CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11

CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11 CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11 CS 536 Spring 2015 1 Handling Overloaded Declarations Two approaches are popular: 1. Create a single symbol table

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

Synchronization SPL/2010 SPL/20 1

Synchronization SPL/2010 SPL/20 1 Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Type Systems, Names and Binding CMSC 330 - Spring 2013 1 Topics Covered Thus Far! Programming languages Ruby OCaml! Syntax specification Regular expressions

More information

CSCI-GA Final Exam

CSCI-GA Final Exam CSCI-GA 2110-003 - Final Exam Instructor: Thomas Wies Name: Sample Solution ID: You have 110 minutes time. There are 7 assignments and you can reach 110 points in total. You can solve the exercises directly

More information

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program

More information

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) CSE 413 Languages & Implementation Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1 Goals Representing programs as data Racket structs as a better way to represent

More information

Data Types The ML Type System

Data Types The ML Type System 7 Data Types 7.2.4 The ML Type System The following is an ML version of the tail-recursive Fibonacci function introduced Fibonacci function in ML in Section 6.6.1: EXAMPLE 7.96 1. fun fib (n) = 2. let

More information

Topics Covered Thus Far CMSC 330: Organization of Programming Languages

Topics Covered Thus Far CMSC 330: Organization of Programming Languages Topics Covered Thus Far CMSC 330: Organization of Programming Languages Names & Binding, Type Systems Programming languages Ruby Ocaml Lambda calculus Syntax specification Regular expressions Context free

More information

Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads.

Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads. Executive Summary. It is important for a Java Programmer to understand the power and limitations of concurrent programming in Java using threads. Poor co-ordination that exists in threads on JVM is bottleneck

More information

15CS45 : OBJECT ORIENTED CONCEPTS

15CS45 : OBJECT ORIENTED CONCEPTS 15CS45 : OBJECT ORIENTED CONCEPTS QUESTION BANK: What do you know about Java? What are the supported platforms by Java Programming Language? List any five features of Java? Why is Java Architectural Neutral?

More information

CSE 12 Abstract Syntax Trees

CSE 12 Abstract Syntax Trees CSE 12 Abstract Syntax Trees Compilers and Interpreters Parse Trees and Abstract Syntax Trees (AST's) Creating and Evaluating AST's The Table ADT and Symbol Tables 16 Using Algorithms and Data Structures

More information

Principles of Programming Languages

Principles of Programming Languages Principles of Programming Languages www.cs.bgu.ac.il/~ppl172 Lesson 6 - Defining a Programming Language Bottom Up Collaboration and Management - Elements of Programming Dana Fisman 1 What we accomplished

More information

CSE 142 Su 04 Computer Programming 1 - Java. Objects

CSE 142 Su 04 Computer Programming 1 - Java. Objects Objects Objects have state and behavior. State is maintained in instance variables which live as long as the object does. Behavior is implemented in methods, which can be called by other objects to request

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2017 Lecture 10a Andrew Tolmach Portland State University 1994-2017 Object-oriented Programming Programs are structured in terms of objects: collections of variables

More information

Introduction to OCaml

Introduction to OCaml Fall 2018 Introduction to OCaml Yu Zhang Course web site: http://staff.ustc.edu.cn/~yuzhang/tpl References Learn X in Y Minutes Ocaml Real World OCaml Cornell CS 3110 Spring 2018 Data Structures and Functional

More information

Unit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW

Unit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW Prepared by: Dr. Abdallah Mohamed, AOU-KW 1 1. Introduction 2. Objects and classes 3. Information hiding 4. Constructors 5. Some examples of Java classes 6. Inheritance revisited 7. The class hierarchy

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 3a Andrew Tolmach Portland State University 1994-2016 Formal Semantics Goal: rigorous and unambiguous definition in terms of a wellunderstood formalism (e.g.

More information

Chapter 1: Object-Oriented Programming Using C++

Chapter 1: Object-Oriented Programming Using C++ Chapter 1: Object-Oriented Programming Using C++ Objectives Looking ahead in this chapter, we ll consider: Abstract Data Types Encapsulation Inheritance Pointers Polymorphism Data Structures and Algorithms

More information

NOTE: Answer ANY FOUR of the following 6 sections:

NOTE: Answer ANY FOUR of the following 6 sections: A-PDF MERGER DEMO Philadelphia University Lecturer: Dr. Nadia Y. Yousif Coordinator: Dr. Nadia Y. Yousif Internal Examiner: Dr. Raad Fadhel Examination Paper... Programming Languages Paradigms (750321)

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation

More information

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d) CMSC 330: Organization of Programming Languages Tail Calls A tail call is a function call that is the last thing a function does before it returns let add x y = x + y let f z = add z z (* tail call *)

More information

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline ::

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline :: Module Title Duration : Intro to JAVA SE7 and Programming using JAVA SE7 : 9 days Course Description The Java SE 7 Fundamentals course was designed to enable students with little or no programming experience

More information

Classes and Methods עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון מבוסס על השקפים של אותו קורס שניתן בשנים הקודמות

Classes and Methods עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון מבוסס על השקפים של אותו קורס שניתן בשנים הקודמות Classes and Methods עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון מבוסס על השקפים של אותו קורס שניתן בשנים הקודמות 2 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static,

More information

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited CMSC 330: Organization of Programming Languages Type Systems, Names & Binding Topics Covered Thus Far Programming languages Syntax specification Regular expressions Context free grammars Implementation

More information

// the current object. functioninvocation expression. identifier (expressionlist ) // call of an inner function

// the current object. functioninvocation expression. identifier (expressionlist ) // call of an inner function SFU CMPT 379 Compilers Spring 2015 Assignment 4 Assignment due Thursday, April 9, by 11:59pm. For this assignment, you are to expand your Bunting-3 compiler from assignment 3 to handle Bunting-4. Project

More information

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

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

Generating Continuation Passing Style Code for the Co-op Language

Generating Continuation Passing Style Code for the Co-op Language Generating Continuation Passing Style Code for the Co-op Language Mark Laarakkers University of Twente Faculty: Computer Science Chair: Software engineering Graduation committee: dr.ing. C.M. Bockisch

More information