The Art of Avoiding Work

Slides:



Advertisements
Similar presentations
Integrating Haskell to.NET André Santos / Monique Monteiro Rotor Workshop Sep MSR.
Advertisements

Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
pa 1 Porting BETA to ROTOR ROTOR Projects Presentation Day, June by Peter Andersen.
Introduction to Compilation of Functional Languages Wanhe Zhang Computing and Software Department McMaster University 16 th, March, 2004.
COM vs. CORBA.
CERN LCG Overview & Scaling challenges David Smith For LCG Deployment Group CERN HEPiX 2003, Vancouver.
The Assembly Language Level
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lab#1 (14/3/1431h) Introduction To java programming cs425
The Type System1. 2.NET Type System The type system is the part of the CLR that defines all the types that programmers can use, and allows developers.
ITEC200 – Week03 Inheritance and Class Hierarchies.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Programming Language Theory Leif Grönqvist The national Graduate School of Language Technology (GSLT) MSI.
C++ fundamentals.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
Programming Languages and Paradigms Object-Oriented Programming.
Introduction to .Net Framework
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
0 PROGRAMMING IN HASKELL An Introduction Based on lecture notes by Graham Hutton The book “Learn You a Haskell for Great Good” (and a few other sources)
CIS NET Applications1 Chapter 2 –.NET Component- Oriented Programming Essentials.
Arpit Jain Mtech1. Outline Introduction Dalvik VM Java VM Examples Comparisons Experimental Evaluation.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
BIT 1003 – Presentation 7. Contents GENERATIONS OF LANGUAGES COMPILERS AND INTERPRETERS VIRTUAL MACHINES OBJECT-ORIENTED PROGRAMMING SCRIPTING LANGUAGES.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Why Java? A brief introduction to Java and its features Prepared by Mithat Konar.
CSC 310 – Imperative Programming Languages, Spring, 2009 Virtual Machines and Threaded Intermediate Code (instead of PR Chapter 5 on Target Machine Architecture)
Ranga Rodrigo. The purpose of software engineering is to find ways of building quality software.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
 2006 Pearson Education, Inc. All rights reserved Operator Overloading; String and Array Objects.
Lecture 8 February 29, Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
Object Oriented Software Development
Virtual Machines, Interpretation Techniques, and Just-In-Time Compilers Kostis Sagonas
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Object-Oriented Programming Chapter Chapter
Test Stubs... getting the world under control. TDD of State Pattern To implement GammaTown requirements I CS, AUHenrik Bærbak Christensen2.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 9 Inheritance and.
ISBN Object-Oriented Programming Chapter Chapter
Object Oriented Software Development 4. C# data types, objects and references.
First Order Haskell Neil Mitchell York University λ.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
We need a new, common Virtual Execution Environment Herman Venter Research in Software Engineering Group Microsoft Research, Redmond.
ISBN Chapter 12 Support for Object-Oriented Programming.
Introduction To Software Development Environment.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Computer System Structures
Object Oriented Programming in
Before You Begin Nahla Abuel-ola /WIT.
Component Based Software Engineering
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Overview Introduction General Register Organization Stack Organization
Introduction Enosis Learning.
Multi-Dispatch in the Java™ Virtual Machine
Introduction Enosis Learning.
More Object-Oriented Programming
Combining Compile-Time and Run-Time Components
Course Overview PART I: overview material PART II: inside a compiler
A Level Computer Science Topic 5: Computer Architecture and Assembly
The Lua Chunk Vault, an enhancement to epics base
CSc 453 Interpreters & Interpretation
Refactoring.
C++ Object Oriented 1.
Presentation transcript:

The Art of Avoiding Work Haskell.NET The Art of Avoiding Work Oliver Hunt & Nigel Perry University of Canterbury, New Zealand

Summary Introduction Background Prior Art Challenges & Solutions Results The Future Questions

Introduction: What? Implementation of Haskell 98 on Rotor/.NET Haskell is one of the worlds most popular functional programming languages. How to compile Haskell for .NET is still a research problem Can it be done “reasonably”? Would IL changes provide “worthwhile” benefit:cost? Reasonably = at appropriate performance/loss of functionality – interpretation would work for all of Glasgow Haskell but wouldn’t be reasonable. Worthwhile = is the cost of IL changes warranted, or do you just take a hit – B:C. IL changes of course require Rotor.

Introduction: Haskell Well known Used in industry and academia Non-strict Glasgow Haskell Compiler (GHC) Provides intermediate-level output to support new backends Extends Haskell 98 – providing future avenues of research

Introduction: Why? Different language families are suited to different tasks This adds a non-strict functional language to the languages available on .NET To test the extent to which .NET can run many languages. Primarily used by object oriented imperative languages.

Prior Art: Bridges The functional language runs natively on the real machine A software bridge is provided to the VM Examples: Lambada (Haskell for JVM) Hugs.Net (Haskell for .NET)

Prior Art: New Languages Designed to work on the VMs Reduced features Mixed compile/interpretive approaches More OO-like type systems Examples: Pizza (JVM) Strict Introduced parametric polymorphism to JVM Mondrian (.NET) OO-like type system Used a mixed compiled/interpretive approach Targeted at scripting applications

Haskell 98 on .NET: Challenges Non-strict evaluation Functions as values Partial evaluation/“currying” Type switches

Challenge: Non-strict Evaluation Mondrian: “External” non-strictness Client must know Manual evaluation Interpretive-like JIT Objects: “Internal” non-strictness Non-strictness hidden from client Automatic evaluation Doesn’t support disjoint union types well Disjoint union types central to Haskell 98… JIT Objects was an earlier project that produced “non-strict C#” – actually a non-strict framework for any language to use but demonstrated using C#

Haskell.NET: Non-strict Evaluation Use “Internal” non-strictness Best for interworking Primitive types Follow JIT Objects Optimise to use single class, rather than type/subtype combination Auto conversion to/from values & boxed values Function types Use hidden nested subtype

Non-strict Evaluation (cont) Disjoint union types Type: abstract class Alternatives: sub-classes Discrimination: use tag fields Resolution: “asX” methods rather than casting Non-strictness Hidden sub-class Internal: evaluation hidden by tag/asX Issues: Casting only works for evaluated values Not totally transparent But disjoint unions not “standard” OO

Non-strict types data List a = Cons a (List a) : Nil

Challenge: Functions as values .NET provides delegates, which are “OO function pointers” Unfortunately: Relatively inefficient given the high usage in Haskell Difficult to combine with non-strictness Replace using a parametric function type Provide conversions to/from delegates for inter-language working Extends to support partial application Might extend to support higher-rank types (Glasgow extension)

Challenge: Partial Evaluation Calling a function omitting arguments, to create a new function, e.g. Inc x = x+ Calling (inc 3) returns a function that adds 3 to its argument We extend our previous function type Instance fields used to store pre-supplied arguments

Challenge: Type Switches Very slow in .NET Must use a series of type checks/casts These checks take account of subtypes Addressed by the addition of an explicit tag enumerand to each type. I.e: Effectively duplicate the hidden VM tag Do exact, as opposed to subtype, matching

Status Compiler functional Performance? But incomplete… Large %age of Haskell 98 language Smaller %age of Haskell 98 libraries Largely engineering, not research, left Performance? Primes Sieve (first 1000 primes) GHC Native: 0.9s GHC .NET: 1.5s

Future Work: Glasgow Haskell Higher Rank Types Passing generic functions as values Partly supported now: Wrap inside interface Higher Kind Types E.g. allow M<X> where both M & X are variable How to do reasonably efficiently in .NET? Fallback is reflection/runtime code generation… Currently by-passed (e.g. hardwire Monad to IO)

Future Work: IL Changes? Compared to “native” implementation: More classes – adds VM load Some extra indirections – a runtime cost Virtual dispatch for tag checking Etc. Investigate if IL changes would: Provide Haskell a good benefit:cost Benefit other languages

Demo It really does work…

Q & (maybe) A