Domain Specific Languages

Size: px
Start display at page:

Download "Domain Specific Languages"

Transcription

1 Domain Specific Languages Programming in Scala (MI-PSL) - 13 Ing. Jiří Daněček Department of Software EngineeringFaculty of Information Technology CTU in Prague Evropský sociální fond Praha & EU: Investujeme do vaší budoucnosti

2 Domain-Specific Language A Domain-Specific Language is a programming language that mimics the terms, idioms, and expressions used among experts in the targeted domain. Code written in a DSL reads like structured prose for the domain. Ideally, a domain expert with little experience in programming can read, understand, and validate this code. DSLs are classified: internal (embedded) is an idiomatic way of writing code in a general-purpose programming language. They are parsed just like any other code written in the language. external DSL is a custom language with its own custom grammar and parser. Interest in DSLs has surged recently, driven in part by the Ruby community, because they are very easy to implement in Ruby. Scala provides excellent support for the creation of internal and external DSLs.

3 DSLs benefits Well-crafted DSLs offer several benefits: Encapsulation - A DSL hides implementation details and exposes only those abstractions relevant to the domain. Efficiency - Because implementation details are encapsulated, a DSL optimizes the effort required to write or modify code for application features. Communication - A DSL helps developers understand the domain and domain experts to verify that the implementation meets the requirements. Quality - A DSL minimizes the impedance mismatch between feature requirements, as expressed by domain experts, and the implementing source code, thereby minimizing potential bugs.

4 DSLs drawbacks Good DSLs are harder to design than traditional APIs. The latter tend to follow language idioms for API design, where uniformity is important. Even then, elegant, effective, and easy-to-use APIs are difficult to design. In contrast, each DSL should reflect the unique language idioms of its domain. The DSL designer has much greater latitude, which also means it is much harder to determine the best design choices. Long-term maintenance DSLs can require more maintenance over the long term to factor in domain changes. Also, new developers will require more time to learn how to use and maintain a DSL. However, when a DSL is appropriate for an application e.g., when it would be used frequently to implement and change functionality a welldesigned DSL can be a powerful tool for building flexible and robust applications.

5 Payroll Application Example Payroll application computes an employee s paycheck every pay period (two weeks). The paycheck will include the employee s: salary: package payroll case class Paycheck( gross: Money, net: Money, deductions: Money) { def plusgross (m: Money) = Paycheck(gross + m, net + m, deductions) def p The Employee type uses a Name type: package payroll case class Name(first: String, last: String) case class Employee(name: Name, annualgrosssalary: Money)

6 Clasic Solution import payroll.api._ import payroll.api.deductionscalculator._ import payroll._ import payroll.type2money._ val buck = Employee(Name("Buck", "Trends"), Money(80000)) val jane = Employee(Name("Jane", "Doe"), Money(90000)) List(buck, jane).foreach { employee => val biweeklygross = employee.annualgrosssalary / 26. val deductions = federalincometax( employee, biweeklygross) + stateincometax(employee, biweeklygross) + insurancepremiums(employee, biweeklygross) + retirementfundcontributions(employee, biweeklygross) val check = Paycheck(biweeklyGross, biweeklygross - deductions, deductions) format("%s %s: %s\n", employee.name.first, employee.name.last, check)

7 Drawbacks of Clasic Solution Clasic solution is: noisy - for example, it mentions employee and biweeklygross incessantly. A DSL will help us minimize that noise and focus on what s really going on. imperative. It says divide this, add that, and so forth. We ll see that our DSLs look similar, but they are more declarative, hiding the work from the user.

8 Class Money package payroll import java.math.{bigdecimal => JBigDecimal, MathContext => JMathContext, RoundingMode => JRoundingMode class Money(val amount: BigDecimal) { def + (m: Money) = Money(amount.bigDecimal.add(m.amount.bigDecimal))... def > (m: Money) = amount > m.amount override def equals (o: Any) = o match { case m: Money => amount equals m.amount case _ => false override def hashcode = amount.hashcode * 31 // Hack: Must explicitly call the correct conversion: double2double override def tostring = String.format("$%.2f", double2double(amount.doublevalue))

9 Class DeductionsCal cu lator Deductions by DeductionsCal cu lator: package payroll.api import payroll.type2money._ object DeductionsCalculator { def federalincometax(empl: Employee, gross: Money) = gross *.25 def stateincometax(empl: Employee, gross: Money) = gross *.05 def insurancepremiums(empl: Employee, gross: Money) = Money(500) def retirementfundcontributions(empl: Employee, gross: Money) = gross *.10

10 Solution in DSL import payroll._ import payroll.dsl._ import payroll.dsl.rules_ val payrollcalculator = rules { employee => employee salary_for 2.weeks minus_deductions_for { gross => federalincometax is (25. percent_of gross) stateincometax is (5. percent_of gross) insurancepremiums are (500. in gross.currency) retirementfundcontributions are ( 10. percent_of gross) val buck = Employee(Name("Buck", "Trends"), Money(80000)) val jane = Employee(Name("Jane", "Doe"), Money(90000)) List(buck, jane).foreach { employee => val check = payrollcalculator(employee) format("%s %s: %s\n", employee.name.first, employee.name.last, check)

11 Infix Operator Notation User-Defined Types Implicit Conversions Apply Methods Scala support for DSL

12 Infix Operator Notation The infix notation:consider this line in the definition of payrollcalculator: employee salary_for 2.weeks minus_deductions_for { gross => This infix notation is equivalent to the following lessreadable form: employee.salary_for(2.weeks).minus_deductions_for { gross => Note: without the period in 2.weeks would be parsed as imployee.salary_for(2).weeks... Each method salary_for, minus_deductions_for returns this so you can continue calling methods on the same instance. Note that returning this allows those method calls to occur in any order.

13 Implicit Conversions Duration is one of the ad hoc types to implement helper methods. It use an implicit conversion to a Duration instance that wraps an Int specifying an amount: package payroll.dsl case class Duration(val amount: Int) { the number of work days in "amount" weeks. */ def weeks = amount * 5 the number of work days in "amount" years. */ def years = amount * 260 The weeks method multiples that amount by 5 to return the corresponding amount of work days. Hence, we designed the payroll calculator to work with days as the unit of time. This decision is completely hidden behind the DSL. Should we later add support for work hours, it would be easy to refactor the design to use hours instead. Duration is one of the ad hoc types that we designed to encapsulate the implicit context, to implement helper methods

14 Payroll Rules DSL Implementation The rules object encapsulates the process of building the rules for payroll calculation. Its apply method takes a function literal: Employee => Paycheck: package payroll.dsl import payroll._ object rules { def apply(rules: Employee => Paycheck) = new PayrollBuilderRules(rules) implicit def int2duration(i: Int) = Duration(i) implicit def employee2grosspaybuilder(e: Employee) = new GrossPayBuilder(e) implicit def grosspaybuilder2deductionsbuilder (b: GrossPayBuilder) = new DeductionsBuilder(b) implicit def double2deductionsbuilderdeductionhelper (d: Double) = new DeductionsBuilderDeductionHelper(d) import rules._...

15 Class PayrollBuilderRules The PayrollBuilderRules evaluates the function literal for the whole rule set, wrapped in a try/catch block: class PayrollException(message: String, cause: Throwable) extends RuntimeException(message, cause) protected[dsl] class PayrollBuilderRules (rules: Employee => Paycheck) { def apply(employee: Employee) = { try { rules(employee) catch { case th: Throwable => new PayrollException( "Failed to process payroll for employee: " + employee, th)...

16 Class GrossPayBuilder GrossPayBuilder initializes the gross and appends new values to it whenever salary_for is called. Finally, salary_for returns this to support chaining: import payroll.type2money._ protected[dsl] class GrossPayBuilder (val employee: Employee) { var gross: Money = 0 def salary_for(days: Int) = { gross += dailygrosssalary(employee.annualgrosssalary) * days this // Assume 260 working days def weeklygrosssalary(annual: Money) = annual / 52.0 def dailygrosssalary(annual: Money) = annual /

17 Class DeductionsBuilder protected[dsl] class DeductionsBuilder( gpb: GrossPayBuilder) { val employee = gpb.employee var paycheck: Paycheck = new Paycheck(gpb.gross, gpb.gross, 0) def currency = this def minus_deductions_for( deductionrules: DeductionsBuilder => Unit) = { deductionrules(this) paycheck def adddeductions(amount: Money) = paycheck = paycheck plusdeductions amount def adddeductionspercentageofgross( percentage: Double) = { val amount = paycheck.gross * (percentage/100.) adddeductions(amount) DeductionsBuilder saves the employee from the passed-in

18 Remaining two methods are used to calculate individual deductions: class DeductionCalculator { def is(builder: DeductionsBuilder) = apply(builder) def are(builder: DeductionsBuilder) = apply(builder) def apply(builder: DeductionsBuilder) = { The synonym methods is and are delegate to apply, they are effectively bubble words that the user could omit. That is, the following two DSL lines are equivalent: federalincometax is (25. percent_of gross) federalincometax(25. percent_of gross) The apply method takes DeductionsBuilder and does nothing with it! In fact, by the time apply is called, the deduction has already been calculated and factored into the paycheck.

19 DeductionsBuilderDeductionHelper federalincometax, etc. are singleton objects. The presence of expressions like federalincometax is are effectively syntactic sugar: object federalincometax extends DeductionCalculator object stateincometax extends DeductionCalculator object insurancepremiums extends DeductionCalculator object retirementfundcontributions extends DeductionCalculator protected[dsl] class DeductionsBuilderDeductionHelper( val factor: Double) { def in (builder: DeductionsBuilder) = { builder adddeductions Money(factor) builder def percent_of (builder: DeductionsBuilder) = { builder adddeductionspercentageofgross factor builder

20 Implicit Conversions (25. percent_of gross) is equivalent to the following steps: 1. rules.double2deductionsbuilderdeductionhelper(25.) 2. percent_of(deductionsbuilder) 3. gross.adddeductionspercentageofgross(factor)

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

Index. Comma-separated values (CSV), 30 Conditional expression, 16 Continuous integration (CI), 34 35, 41 Conway s Law, 75 CurrencyPair class,

Index. Comma-separated values (CSV), 30 Conditional expression, 16 Continuous integration (CI), 34 35, 41 Conway s Law, 75 CurrencyPair class, A AbstractBitmap, 199 Abstract syntax tree (AST) pattern, 116 heterogeneous, 119 homogenous, 116 119 irregular heterogeneous, 119 normalized heterogeneous, 118 Account type, 165 Android Studio, 140 142,

More information

Servers I. Ing. Jiří Kašpar prof. Ing. Pavel Tvrdík CSc.

Servers I. Ing. Jiří Kašpar prof. Ing. Pavel Tvrdík CSc. Jiří Kašpar, Pavel Tvrdík (ČVUT FIT) Servers I. MI-POA, 2011, Lecture 5 1/17 Servers I. Ing. Jiří Kašpar prof. Ing. Pavel Tvrdík CSc. Department of Computer Systems Faculty of Information Technology Czech

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

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

Pay Stub and Direct Deposit Self-Service

Pay Stub and Direct Deposit Self-Service Pay Stub and Direct Deposit Self-Service Our Self Service site allows you to view pay stubs and create and update Direct Deposit information on your employee record directly. The Self Service site is accessible

More information

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Summary 1. Predictive Parsing 2. Large Step Operational Semantics (Natural) 3. Small Step Operational Semantics

More information

What is a compiler? Xiaokang Qiu Purdue University. August 21, 2017 ECE 573

What is a compiler? Xiaokang Qiu Purdue University. August 21, 2017 ECE 573 What is a compiler? Xiaokang Qiu Purdue University ECE 573 August 21, 2017 What is a compiler? What is a compiler? Traditionally: Program that analyzes and translates from a high level language (e.g.,

More information

First Programming Language in CS Education The Arguments for Scala

First Programming Language in CS Education The Arguments for Scala First Programming Language in CS Education The Arguments for Scala WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that is under contract with CRC Press.

More information

Optimizing Higher-Order Functions in Scala

Optimizing Higher-Order Functions in Scala Optimizing Higher-Order Functions in Scala Iulian Dragos EPFL Outline A quick tour of Scala Generalities Extension through libraries Closure translation in Scala Cost Optimizations in the Scala compiler

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

17 From Delegation to Inheritance

17 From Delegation to Inheritance Object-Oriented Design Lecture 17 CS 3500 Spring 2011 (Pucella) Friday, Mar 18, 2011 17 From Delegation to Inheritance Last time, we saw how to reuse code from the implementation of Point in CPoint via

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

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 4. LISP: PROMĚNNÉ, DALŠÍ VLASTNOSTI FUNKCÍ, BLOKY, MAPOVACÍ FUNKCIONÁLY, ITERAČNÍ CYKLY,

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 4. LISP: PROMĚNNÉ, DALŠÍ VLASTNOSTI FUNKCÍ, BLOKY, MAPOVACÍ FUNKCIONÁLY, ITERAČNÍ CYKLY, FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 4. LISP: PROMĚNNÉ, DALŠÍ VLASTNOSTI FUNKCÍ, BLOKY, MAPOVACÍ FUNKCIONÁLY, ITERAČNÍ CYKLY, 2011 Jan Janoušek MI-FLP Evropský sociální fond Praha & EU: Investujeme do vaší

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II 1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 4(b): Subclasses and Superclasses OOP OOP - Inheritance Inheritance represents the is a relationship between data types (e.g. student/person)

More information

CHAPTER 7 OBJECTS AND CLASSES

CHAPTER 7 OBJECTS AND CLASSES CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and

More information

CHAPTER 7 OBJECTS AND CLASSES

CHAPTER 7 OBJECTS AND CLASSES CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and

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

DESIGN PATTERN - INTERVIEW QUESTIONS

DESIGN PATTERN - INTERVIEW QUESTIONS DESIGN PATTERN - INTERVIEW QUESTIONS http://www.tutorialspoint.com/design_pattern/design_pattern_interview_questions.htm Copyright tutorialspoint.com Dear readers, these Design Pattern Interview Questions

More information

Servers II. Ing. Jiří Kašpar prof. Ing. Pavel Tvrdík CSc.

Servers II. Ing. Jiří Kašpar prof. Ing. Pavel Tvrdík CSc. Jiří Kašpar, Pavel Tvrdík (ČVUT FIT) Servers II. MI-POA, 2011, Lecture 6 1/20 Servers II. Ing. Jiří Kašpar prof. Ing. Pavel Tvrdík CSc. Department of Computer Systems Faculty of Information Technology

More information

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University Idioms and Design Patterns Martin Skogevall IDE, Mälardalen University 2005-04-07 Acronyms Object Oriented Analysis and Design (OOAD) Object Oriented Programming (OOD Software Design Patterns (SDP) Gang

More information

COMPILER CONSTRUCTION LAB 2 THE SYMBOL TABLE. Tutorial 2 LABS. PHASES OF A COMPILER Source Program. Lab 2 Symbol table

COMPILER CONSTRUCTION LAB 2 THE SYMBOL TABLE. Tutorial 2 LABS. PHASES OF A COMPILER Source Program. Lab 2 Symbol table COMPILER CONSTRUCTION Lab 2 Symbol table LABS Lab 3 LR parsing and abstract syntax tree construction using ''bison' Lab 4 Semantic analysis (type checking) PHASES OF A COMPILER Source Program Lab 2 Symtab

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

CO Java SE 8: Fundamentals

CO Java SE 8: Fundamentals CO-83527 Java SE 8: Fundamentals Summary Duration 5 Days Audience Application Developer, Developer, Project Manager, Systems Administrator, Technical Administrator, Technical Consultant and Web Administrator

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2018 Lecture 7b Andrew Tolmach Portland State University 1994-2018 Dynamic Type Checking Static type checking offers the great advantage of catching errors early And

More information

Practically Functional. Daniel Spiewak

Practically Functional. Daniel Spiewak Practically Functional Daniel Spiewak whoami Author of Scala for Java Refugees and other articles on Scala and FP Former editor Javalobby / EclipseZone Engaged in academic research involving Scala DSLs

More information

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 2. ÚVOD DO LISPU: ATOMY, SEZNAMY, FUNKCE,

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 2. ÚVOD DO LISPU: ATOMY, SEZNAMY, FUNKCE, FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 2. ÚVOD DO LISPU: ATOMY, SEZNAMY, FUNKCE, 2011 Jan Janoušek MI-FLP Evropský sociální fond Praha & EU: Investujeme do vaší budoucnosti L I S P - Introduction L I S P

More information

Company Setup Paycheck Attributes Tab

Company Setup Paycheck Attributes Tab Reference Sheet Company Setup Paycheck Attributes Tab Paycheck attributes allow you to create predefined check types within a company that are used during payroll entry. A paycheck attribute is a property

More information

EXAM Microsoft MTA Software Development Fundamentals. Buy Full Product.

EXAM Microsoft MTA Software Development Fundamentals. Buy Full Product. Microsoft EXAM - 98-361 Microsoft MTA Software Development Fundamentals Buy Full Product http://www.examskey.com/98-361.html Examskey Microsoft 98-361 exam demo product is here for you to test the quality

More information

Functions and Objects. Week 7: Symbolic Computation

Functions and Objects. Week 7: Symbolic Computation Week 7: Symbolic Computation In the previous weeks, we've seen the essential elements of modern functional programming: Functions (rst class) Types (parametric) Pattern Matching Lists This week, we'll

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 6 : Abstraction Lecture Contents 2 Abstract classes Abstract methods Case study: Polymorphic processing Sealed methods & classes

More information

What Every Xtext User Wished to Know Industry Experience of Implementing 80+ DSLs

What Every Xtext User Wished to Know Industry Experience of Implementing 80+ DSLs What Every Xtext User Wished to Know Industry Experience of Implementing 80+ DSLs EclipseCon Europe 2016 2016-10-26 Roman Mitin Avaloq Evolution AG Allmendstrasse 140 8027 Zurich Switzerland T +41 58 316

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

Domain-Specific. Languages. Martin Fowler. AAddison-Wesley. Sydney Tokyo. With Rebecca Parsons

Domain-Specific. Languages. Martin Fowler. AAddison-Wesley. Sydney Tokyo. With Rebecca Parsons Domain-Specific Languages Martin Fowler With Rebecca Parsons AAddison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid Sydney Tokyo Singapore

More information

Chapter 7 Control I Expressions and Statements

Chapter 7 Control I Expressions and Statements Chapter 7 Control I Expressions and Statements Expressions Conditional Statements and Guards Loops and Variation on WHILE The GOTO Controversy Exception Handling Values and Effects Important Concepts in

More information

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming t ::= x x. t t t Call-by-value big-step Operational Semantics terms variable v ::= values abstraction x.

More information

11. Security Techniques on Smart Cards

11. Security Techniques on Smart Cards 11. Security Techniques on Smart Cards Dr.-Ing. Martin Novotný Katedra číslicového návrhu Fakulta informačních technologií České vysoké učení technické v Praze c Martin Novotný, 2011 MI-BHW Bezpečnost

More information

HW Trends and Architectures

HW Trends and Architectures Pavel Tvrdík, Jiří Kašpar (ČVUT FIT) HW Trends and Architectures MI-POA, 2011, Lecture 1 1/29 HW Trends and Architectures prof. Ing. Pavel Tvrdík CSc. Ing. Jiří Kašpar Department of Computer Systems Faculty

More information

building dsl s in static & dynamic languages

building dsl s in static & dynamic languages ThoughtWorks building dsl s in static & dynamic languages NEAL FORD thoughtworker / meme wrangler ThoughtWorks 14 Wall St, Suite 2019, New York, NY 10005 nford@thoughtworks.com www.nealford.com www.thoughtworks.com

More information

DESIGN, EVOLUTION AND USE

DESIGN, EVOLUTION AND USE DESIGN, EVOLUTION AND USE of KernelF voelter@acm.org www.voelter.de @markusvoelter Markus Völter Check out the paper! http://voelter.de/data /pub/kernelf-icmt.pdf EXAMPLE 1 Healthcare 1 Context Mobile

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

In Java there are three types of data values:

In Java there are three types of data values: In Java there are three types of data values: primitive data values (int, double, boolean, etc.) arrays (actually a special type of object) objects An object might represent a string of characters, a planet,

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Type Inference Some statically typed languages, like ML (and to a lesser extent Scala), offer alternative

More information

Office 2016 Excel Basics 09 Video/Class Project #21 Excel Basics 9: Number Formatting and the ROUND Function

Office 2016 Excel Basics 09 Video/Class Project #21 Excel Basics 9: Number Formatting and the ROUND Function Office 2016 Excel Basics 09 Video/Class Project #21 Excel Basics 9: Number Formatting and the ROUND Function Goal in video # 9: Learn more about Number Formatting. Learn when and how to use the ROUND function

More information

Domain Specific Languages - a user view and an implementation view. does expressiveness imply a compromise on the underlying domain model?

Domain Specific Languages - a user view and an implementation view. does expressiveness imply a compromise on the underlying domain model? Domain Specific Languages - a user view and an implementation view does expressiveness imply a compromise on the underlying domain model? Debasish Ghosh @debasishg on twitter Code @ http://github.com/debasishg

More information

Symbol Tables Symbol Table: In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is

More information

Network Intrusion Goals and Methods

Network Intrusion Goals and Methods Network Intrusion Goals and Methods Mgr. Rudolf B. Blažek, Ph.D. Department of Computer Systems Faculty of Information Technologies Czech Technical University in Prague Rudolf Blažek 2010-2011 Network

More information

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns EPL 603 TOPICS IN SOFTWARE ENGINEERING Lab 6: Design Patterns Links to Design Pattern Material 1 http://www.oodesign.com/ http://www.vincehuston.org/dp/patterns_quiz.html Types of Design Patterns 2 Creational

More information

5 The Control Structure Diagram (CSD)

5 The Control Structure Diagram (CSD) 5 The Control Structure Diagram (CSD) The Control Structure Diagram (CSD) is an algorithmic level diagram intended to improve the comprehensibility of source code by clearly depicting control constructs,

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

administrivia today UML start design patterns Tuesday, September 28, 2010

administrivia today UML start design patterns Tuesday, September 28, 2010 administrivia Assignment 2? promise to get past assignment 1 back soon exam on monday review slides are posted your responsibility to review covers through last week today UML start design patterns 1 Unified

More information

Static Semantics. Lecture 15. (Notes by P. N. Hilfinger and R. Bodik) 2/29/08 Prof. Hilfinger, CS164 Lecture 15 1

Static Semantics. Lecture 15. (Notes by P. N. Hilfinger and R. Bodik) 2/29/08 Prof. Hilfinger, CS164 Lecture 15 1 Static Semantics Lecture 15 (Notes by P. N. Hilfinger and R. Bodik) 2/29/08 Prof. Hilfinger, CS164 Lecture 15 1 Current Status Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing

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

Final thoughts on functions F E B 2 5 T H

Final thoughts on functions F E B 2 5 T H Final thoughts on functions F E B 2 5 T H Ordering functions in your code Will the following code work? Here the function is defined after the main program that is calling it. print foo() def foo(): return

More information

What is a compiler? var a var b mov 3 a mov 4 r1 cmpi a r1 jge l_e mov 2 b jmp l_d l_e: mov 3 b l_d: ;done

What is a compiler? var a var b mov 3 a mov 4 r1 cmpi a r1 jge l_e mov 2 b jmp l_d l_e: mov 3 b l_d: ;done What is a compiler? What is a compiler? Traditionally: Program that analyzes and translates from a high level language (e.g., C++) to low-level assembly language that can be executed by hardware int a,

More information

OCaml Data CMSC 330: Organization of Programming Languages. User Defined Types. Variation: Shapes in Java

OCaml Data CMSC 330: Organization of Programming Languages. User Defined Types. Variation: Shapes in Java OCaml Data : Organization of Programming Languages OCaml 4 Data Types & Modules So far, we ve seen the following kinds of data Basic types (int, float, char, string) Lists Ø One kind of data structure

More information

Syntax-Directed Translation. Lecture 14

Syntax-Directed Translation. Lecture 14 Syntax-Directed Translation Lecture 14 (adapted from slides by R. Bodik) 9/27/2006 Prof. Hilfinger, Lecture 14 1 Motivation: parser as a translator syntax-directed translation stream of tokens parser ASTs,

More information

MI-BPS (Wireless Networks) FIT - CTU

MI-BPS (Wireless Networks) FIT - CTU Evropský sociální fond Praha & EU: Investujeme do vaší budoucnosti MI-BPS (Wireless Networks) FIT - CTU Alex Moucha Lecture 8 - Piconets, Scatternets, Bluetooth, Zigbee 1 Piconet an ad-hoc network linking

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED

More information

Software design and Implementation 1/6. Software Design and Implementation. Sample Final Exam

Software design and Implementation 1/6. Software Design and Implementation. Sample Final Exam Software design and Implementation 1/6 Software Design and Implementation Sample Final Exam 18.11.2004 Conditions: Closed book Duration: 120 min Name: Student ID: 1. /20 2. /20 3. /20 4. /20 5. /20 Total

More information

Lecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance?

Lecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance? CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 5: Inheritance & Polymorphism Lecture Contents 2 What is Inheritance? Super-class & sub class Protected members Creating subclasses

More information

Software Design COSC 4353/6353 D R. R A J S I N G H

Software Design COSC 4353/6353 D R. R A J S I N G H Software Design COSC 4353/6353 D R. R A J S I N G H Design Patterns What are design patterns? Why design patterns? Example DP Types Toolkit, Framework, and Design Pattern A toolkit is a library of reusable

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 4(b): Inheritance & Polymorphism Lecture Contents What is Inheritance? Super-class & sub class The object class Using extends keyword

More information

Scala. Takes you to the Next Level. Mødegruppe for F#nktionelle Københavnere Nov 21, 2013 Speaker: Joakim Ahnfelt-Rønne

Scala. Takes you to the Next Level. Mødegruppe for F#nktionelle Københavnere Nov 21, 2013 Speaker: Joakim Ahnfelt-Rønne Scala Takes you to the Next Level Mødegruppe for F#nktionelle Københavnere Nov 21, 2013 Speaker: Joakim Ahnfelt-Rønne Who's talking? My name is Joakim Ahnfelt-Rønne I am the co-organizer of this group,

More information

Implementation of JVM-based languages support in IntelliJ IDEA

Implementation of JVM-based languages support in IntelliJ IDEA Implementation of JVM-based languages support in IntelliJ IDEA Ilya Sergey Dept. of Software Engineering Saint-Petersburg State University JetBrains Inc. ilya.sergey@jetbrains.com Abstract. This paper

More information

CS Exam #1-100 points Spring 2011

CS Exam #1-100 points Spring 2011 CS 4700 - Exam #1-100 points Spring 2011 Fill in the blanks (1 point each) 1. syntactic sugar is a term coined for additions to the syntax of a computer language that do not affect its expressiveness but

More information

Asynchronous Functions in C#

Asynchronous Functions in C# Asynchronous Functions in C# Asynchronous operations are methods and other function members that may have most of their execution take place after they return. In.NET the recommended pattern for asynchronous

More information

Parallel Connected Components

Parallel Connected Components Parallel Connected Components prof. Ing. Pavel Tvrdík CSc. Katedra počítačových systémů Fakulta informačních technologií České vysoké učení technické v Praze c Pavel Tvrdík, 00 Pokročilé paralelní algoritmy

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 5: Inheritance & Polymorphism Lecture Contents 2 What is Inheritance? Super-class & sub class Protected members Creating subclasses

More information

Principles of OO Design

Principles of OO Design Principles of OO Design Ing. Libor Buš PhD. Department of Software Engineering Faculty of Information Technology Czech Technical University in Prague MI-DPO WS 2010/11, Lecture 1 Evropský sociální fond

More information

Object-oriented programming

Object-oriented programming Object-oriented programming HelloWorld The following code print Hello World on the console object HelloWorld { def main(args: Array[String]): Unit = { println("hello World") 2 1 object The keyword object

More information

Upcoming Features in C# Mads Torgersen, MSFT

Upcoming Features in C# Mads Torgersen, MSFT Upcoming Features in C# Mads Torgersen, MSFT This document describes language features currently planned for C# 6, the next version of C#. All of these are implemented and available in VS 2015 Preview.

More information

4. Semantic Processing and Attributed Grammars

4. Semantic Processing and Attributed Grammars 4. Semantic Processing and Attributed Grammars 1 Semantic Processing The parser checks only the syntactic correctness of a program Tasks of semantic processing Checking context conditions - Declaration

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 4&5: Inheritance Lecture Contents What is Inheritance? Super-class & sub class The object class Using extends keyword @override keyword

More information

Linearizability Testing Manual

Linearizability Testing Manual Linearizability Testing Manual Gavin Lowe April 8, 2016 This manual describes how to use the linearizability testing framework, described in [Low16]. The framework is available from http://www.cs.ox. ac.uk/people/gavin.lowe/linearizabiltytesting/.

More information

MARCH 15, 2017 EASTCONN EMPLOYEE SELF-SERVICE (ESS) SYSTEM USER GUIDE FOR NON-SUPERVISORY ROLES INCLUDES TIMESHEET ENTRY EASTCONN HUMAN RESOURCES

MARCH 15, 2017 EASTCONN EMPLOYEE SELF-SERVICE (ESS) SYSTEM USER GUIDE FOR NON-SUPERVISORY ROLES INCLUDES TIMESHEET ENTRY EASTCONN HUMAN RESOURCES MARCH 15, 2017 EASTCONN EMPLOYEE SELF-SERVICE (ESS) SYSTEM USER GUIDE FOR NON-SUPERVISORY ROLES INCLUDES TIMESHEET ENTRY EASTCONN HUMAN RESOURCES Table of Contents About ESS and How to Login... 1 ESS Dashboard

More information

A programming language requires two major definitions A simple one pass compiler

A programming language requires two major definitions A simple one pass compiler A programming language requires two major definitions A simple one pass compiler [Syntax: what the language looks like A context-free grammar written in BNF (Backus-Naur Form) usually suffices. [Semantics:

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

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

Exam in TDDB84: Design Patterns,

Exam in TDDB84: Design Patterns, Exam in TDDB84: Design Patterns, 2014-10-24 14-18 Information Observe the following, or risk subtraction of points: 1) Write only the answer to one task on one sheet. Use only the front side of the sheets

More information

Imperative Programming 2: Inheritance 1

Imperative Programming 2: Inheritance 1 Imperative Programming 2: Inheritance 1 Hongseok Yang University of Oxford Motivation Scala programs consist of classes, traits and singleton objects. Inheritance is a fundamental building block for relating

More information

09/02/2013 TYPE CHECKING AND CASTING. Lecture 5 CS2110 Spring 2013

09/02/2013 TYPE CHECKING AND CASTING. Lecture 5 CS2110 Spring 2013 1 TYPE CHECKING AND CASTING Lecture 5 CS2110 Spring 2013 1 Type Checking 2 Java compiler checks to see if your code is legal Today: Explore how this works What is Java doing? Why What will Java do if it

More information

Linked Data. Department of Software Enginnering Faculty of Information Technology Czech Technical University in Prague Ivo Lašek, 2011

Linked Data. Department of Software Enginnering Faculty of Information Technology Czech Technical University in Prague Ivo Lašek, 2011 Linked Data Department of Software Enginnering Faculty of Information Technology Czech Technical University in Prague Ivo Lašek, 2011 Semantic Web, MI-SWE, 11/2011, Lecture 9 Evropský sociální fond Praha

More information

Spreadsheet Case 2. Clarkson Cosmetics

Spreadsheet Case 2. Clarkson Cosmetics 27 Spreadsheet Case 2 Clarkson Cosmetics Problem: Management skills: PC skills: File: Evaluate the effectiveness of an e-commerce company s Web site and advertising sites Analyzing Organizing Formulas

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Lecture 8: Deterministic Bottom-Up Parsing

Lecture 8: Deterministic Bottom-Up Parsing Lecture 8: Deterministic Bottom-Up Parsing (From slides by G. Necula & R. Bodik) Last modified: Fri Feb 12 13:02:57 2010 CS164: Lecture #8 1 Avoiding nondeterministic choice: LR We ve been looking at general

More information

Semantic Analysis. Lecture 9. February 7, 2018

Semantic Analysis. Lecture 9. February 7, 2018 Semantic Analysis Lecture 9 February 7, 2018 Midterm 1 Compiler Stages 12 / 14 COOL Programming 10 / 12 Regular Languages 26 / 30 Context-free Languages 17 / 21 Parsing 20 / 23 Extra Credit 4 / 6 Average

More information

DSL for the Uninitiated

DSL for the Uninitiated doi:10.1145/1965724.1965740 Article development led by queue.acm.org Domain-specific languages bridge the semantic gap in programming. by Debasish Ghosh DSL for the Uninitiated One of the main reasons

More information

Lecture 5: Writing a program

Lecture 5: Writing a program ΗΥ-150 Προγραμματισμός CS-150 Programming Lecture 5: Writing a program G. Papagiannakis Abstract This lecture and the next describe the process of designing a program through the example of a simple desk

More information

Spreadsheet Management Software Cases. Evaluate the effectiveness of an e-commerce company s Web site and advertising sites

Spreadsheet Management Software Cases. Evaluate the effectiveness of an e-commerce company s Web site and advertising sites 31 Spreadsheet Case 2 Athena Beauty Products Problem: Management skills: Excel skills: File: Evaluate the effectiveness of an e-commerce company s Web site and advertising sites Analyzing Organizing Formulas

More information

HOW WE MOVED FROM JAVA TO SCALA

HOW WE MOVED FROM JAVA TO SCALA HOW WE MOVED FROM JAVA TO SCALA Graham Tackley guardian.co.uk @tackers mostly HOW WE MOVED FROM ^ JAVA TO SCALA Graham Tackley guardian.co.uk @tackers History Java shop since 2006 guardian.co.uk: java

More information

CS162 Week 1. Kyle Dewey. Friday, January 10, 14

CS162 Week 1. Kyle Dewey. Friday, January 10, 14 CS162 Week 1 Kyle Dewey Overview Basic Introduction CS Accounts Scala survival guide Office Hour Choose an hour from within: Tuesday/Thursday 11 AM - 1 PM Friday 11 AM - 4 PM Also available by appointment

More information

DOT NET Syllabus (6 Months)

DOT NET Syllabus (6 Months) DOT NET Syllabus (6 Months) THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate Language (IL) Just- In- Time Compilation and CLS Disassembling.Net Application to IL

More information

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1 CSCI 6234 Object Oriented Design: Frameworks and Design Patterns George Blankenship Frameworks and Design George Blankenship 1 Background A class is a mechanisms for encapsulation, it embodies a certain

More information

Clustering. Pattern Recognition IX. Michal Haindl. Clustering. Outline

Clustering. Pattern Recognition IX. Michal Haindl. Clustering. Outline Clustering cluster - set of patterns whose inter-pattern distances are smaller than inter-pattern distances for patterns not in the same cluster a homogeneity and uniformity criterion no connectivity little

More information

CPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia

CPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia CPL 2016, week 10 Clojure functional core Oleg Batrashev Institute of Computer Science, Tartu, Estonia April 11, 2016 Overview Today Clojure language core Next weeks Immutable data structures Clojure simple

More information

PARTNER PORTAL TOOLKIT

PARTNER PORTAL TOOLKIT Revised 7/26/2018 PARTNER PORTAL TOOLKIT Financial Advisors WWW.PAYLOCITY.COM TABLE OF CONTENTS Partner Portal Toolkit... 3 User Accounts... 4 Partner Portal... 5 Select Company or Set... 6 Recent Hires...

More information

Design Patterns. An introduction

Design Patterns. An introduction Design Patterns An introduction Introduction Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. Your design should be specific to the problem at

More information

Lecture 7: Deterministic Bottom-Up Parsing

Lecture 7: Deterministic Bottom-Up Parsing Lecture 7: Deterministic Bottom-Up Parsing (From slides by G. Necula & R. Bodik) Last modified: Tue Sep 20 12:50:42 2011 CS164: Lecture #7 1 Avoiding nondeterministic choice: LR We ve been looking at general

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba Laboratory Session: Exercises on classes Analogy to help you understand classes and their contents. Suppose you want to drive a car and make it go faster by pressing down

More information