Introduction Basics Concurrency Conclusion. Clojure. Marcel Klinzing. December 13, M. Klinzing Clojure 1/18

Size: px
Start display at page:

Download "Introduction Basics Concurrency Conclusion. Clojure. Marcel Klinzing. December 13, M. Klinzing Clojure 1/18"

Transcription

1 Clojure Marcel Klinzing December 13, 2012 M. Klinzing Clojure 1/18

2 Overview/History Functional programming language Lisp dialect Compiles to Java Bytecode Implemented in Java Created by Rich Hickey Version released in 2009 Rich Hickey Current Version: M. Klinzing Clojure 2/18

3 Features Program as data First-class functions Dynamically typed Java interoperability Immutable, persistent data Mutable references to data Support for concurrent programming and more... M. Klinzing Clojure 3/18

4 Forms Part of Clojure called Reader reads chunks of the program called forms Reader translates forms into Clojure data structures Clojure compiles data structures and executes them Forms (excerpt): Form Example Boolean true, false List (+ 1 2), (map + [1 2] [3 4]) Number 1, 3.142, 22/7 String hello world Symbol foo, foo-?, java.lang.thread Vector [1 2 3] M. Klinzing Clojure 4/18

5 Variables and Functions Defining a (global) variable: (def identifier value) Defining a function: (defn identifier (parameter-vec body) + ) Calling a function: (identifier param1 param2...) 1 (defn f 2 ([] (println "hello, world!")) 3 ([x] (println x))) 4 5 ; brackets can be omitted if 6 ; there is only one parameter vec and body 7 (defn g [] (println "bar")) 8 9 (f) ; Output: hello, world! 10 (f "foo") ; Output: foo 11 (g) ; Output: bar M. Klinzing Clojure 5/18

6 Destructuring Destructuring used to bind single values in a collection to variables 1 (defn f [ [x y] ] 2 (+ x y)) 3 4 (println (f [1 1])) ; Output: 2 5 (println (f [ ])) ; Output: 9 M. Klinzing Clojure 6/18

7 Java Interoperability Package java.lang imported automatically Create new Object: (new classname & args) Call of variables/methods: (. class-or-instance member-symbol & args) Note that every Clojure function is an Object which implements java.lang.runnable and java.lang.callable 1 (defn delay-print [] 2 (. Thread sleep 100) 3 (println "new Thread")) 4 5 (. (new Thread delay-print) start) 6 (print "start ") 7 ; Output: start new Thread M. Klinzing Clojure 7/18

8 Reference Types Reference types = mutable references to immutable data Reference types and their purpose: Refs: Synchronous, coordinated updates of data Agents: Asynchronous update of a single value Atoms: Synchronous update of a single value Vars: Synchronous update of a thread-local value M. Klinzing Clojure 8/18

9 Software Transactional Memory Software Transactional Memory (STM) is a model/concept to view memory as a database STM used for coordinated updates (refs) Updates of values are done in transactions Properties of STM transactions: Atomic updates Consistent updates Isolated updates M. Klinzing Clojure 9/18

10 STM - Multiversion Control STM uses Multiversion Control (MVCC): Start of a Transaction: Unique ID (called point) is generated Transaction works against private copies of references (associated with the point) Changes to refs will be visible only after the transaction commits/ends If a transaction notices that a ref has been already set/altered by another transaction, the transaction will restart To start a transaction: (dosync & exprs) M. Klinzing Clojure 10/18

11 Refs Creating a ref: (ref initial-value) Dereferencing a ref: (deref ref-inst) or To change the reference: (ref-set new-value) Note: ref-set can only be called in a transaction; otherwise a IllegalStateException is thrown M. Klinzing Clojure 11/18

12 Refs Example 1 (def x (ref 0)) 2 3 (defn increase [] 4 (. Thread sleep 100) 5 (dosync (ref-set x 1)))) 6 7 (defn decrease [] 8 (. Thread sleep 100) 9 (dosync (ref-set x 1)))) (def inc-thread (new Thread increase)) 12 (def dec-thread (new Thread decrease)) (. inc-thread start) (. dec-thread start) 15 (. inc-thread join) (. dec-thread join) 16 ; Output: 0 M. Klinzing Clojure 12/18

13 Agents Creating an agent: (agent initial-value) Dereferencing for agents as for Changing of agents per update function: (send agent-inst update-fn & args) arg1 arg2...) is run later on a thread in a thread pool and the return value is assigned to the agent M. Klinzing Clojure 13/18

14 Agents Example 1 (def ag (agent 0)) 2 3 (defn increase [x] 4 (+ x 1)) 5 6 ag increase)) ; Output: 0 7 (. Thread sleep 100) 8 ; Output: 1 M. Klinzing Clojure 14/18

15 Benchmark Benchmark taken from the Computer Language Benchmarks Game ( ) thread-ring program: Create 503 linked pre-emptive threads Thread 503 should be linked to thread 1, forming an unbroken ring Pass a token to thread 1 Pass the token from thread to thread N times Print the name of the last thread (1 to 503) to take the token M. Klinzing Clojure 15/18

16 Benchmarks Results (excerpt) N = 50,000,000 Quad-core 2.4Ghz Intel R Q6600 R ; 4GB RAM; 250GB SATA II disk drive x64 Ubuntu TM M. Klinzing Clojure 16/18

17 Pros: Functional programming (first-class functions, small code,... ) Java interoperability Support for concurrent programming Cons: Speed (since it runs on the JVM) M. Klinzing Clojure 17/18

18 Other Clojure Implementations ClojureScript Compiles Clojure code to JavaScript implemented in Clojure ClojureCLR Native implementation of Clojure on the Common Language Runtime (CLR; virtual machine of Microsoft s.net framework) Implemented in C# (and Clojure itself) M. Klinzing Clojure 18/18

19 References Official site: Book: Stuart Halloway and Aaron Bedra. Programming Clojure. 2nd ed. The Pragmatic Programmers, Tutorial: R. Mark Volkmann. Clojure - Functional Programming for the JVM Benchmark: Pictures: Slide 2: M. Klinzing Clojure

20 Thank you for your attention. M. Klinzing Clojure

21 Backup Slides Multimethods Declaring a multimethod: (defmulti identifier choosing-fn) Considering a function call (identifier arg1 arg2...); (choosing-fn arg1 arg2...) is called and the return value determines the implementation to be called Defining a multimethod: (defmethod identifier choosing-val (parameter-vec body) + ) M. Klinzing Clojure

22 Backup Slides Metadata Metadata = Data about data that doesn t change its logical values Write ^metadata-map before symbols to attach metadata Example: 1 (def x 1) 2 (defn ^{:doc "Returns its first argument"} f [x y] x) 3 4 (println (meta # x)) 5 ; Output: {:ns #<Namespace user>, :name x, :line 1, 6 ; : file D:\Clojure\metadata. clj } 7 (println (meta # f)) 8 ;Output: {: arglists ([x y ]), :ns #<Namespace user>, :name f, 9 ; :doc Returns its first argument, : line 3, : file...} 10 (println (doc f)) 11 ; Output: 12 ; user/f 13 ; ([x y]) 14 ; Returns its first argument M. Klinzing Clojure

Seminar on Languages for Scientific Computing Aachen, 6 Feb Navid Abbaszadeh.

Seminar on Languages for Scientific Computing Aachen, 6 Feb Navid Abbaszadeh. Scientific Computing Aachen, 6 Feb 2014 navid.abbaszadeh@rwth-aachen.de Overview Trends Introduction Paradigms, Data Structures, Syntax Compilation & Execution Concurrency Model Reference Types Performance

More information

Reference types in Clojure. April 2, 2014

Reference types in Clojure. April 2, 2014 Reference types in Clojure April 2, 2014 Clojure atoms, vars, refs, agents Software transactional memory 2 / 15 From The Joy of Clojure book Time The relative moments when events occur State A snapshot

More information

Clojure Lisp for the Real #clojure

Clojure Lisp for the Real #clojure Clojure Lisp for the Real World @stuartsierra #clojure 1 Bullet Points Values Code is data Generic data access Concurrency 2 Stuart Sierra Relevance, Inc. Clojure/core Clojure contributor 3 Values 4 Values

More information

Clojure Lisp for the Real clojure.com

Clojure Lisp for the Real clojure.com Clojure Lisp for the Real World @stuartsierra clojure.com Stuart Sierra Relevance, Inc. Clojure/core Clojure contributor Values Values 3 Values 3 + 2 = 5 Values let x = 3 Values let x = 3 let x = 5 Values

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

Persistent Data Structures and Managed References

Persistent Data Structures and Managed References Persistent Data Structures and Managed References Clojure s approach to Identity and State Rich Hickey Agenda Functions and processes Identity, State, and Values Persistent Data Structures Clojure s Managed

More information

Clojure is. A dynamic, LISP-based. programming language. running on the JVM

Clojure is. A dynamic, LISP-based. programming language. running on the JVM (first '(Clojure.)) Clojure is A dynamic, LISP-based programming language running on the JVM Origin 2007, Rich Hickey.. 1958, John McCarthy Features Functional Homoiconic Immutability (persistent data

More information

.consulting.solutions.partnership. Clojure by Example. A practical introduction to Clojure on the JVM

.consulting.solutions.partnership. Clojure by Example. A practical introduction to Clojure on the JVM .consulting.solutions.partnership Clojure by Example A practical introduction to Clojure on the JVM Clojure By Example 1 Functional Progamming Concepts 3 2 Clojure Basics 4 3 Clojure Examples 5 4 References

More information

The Curious Clojureist

The Curious Clojureist The Curious Clojureist NEAL FORD director / software architect meme wrangler ThoughtWorks nford@thoughtworks.com 2002 Summit Boulevard, Atlanta, GA 30319 nealford.com thoughtworks.com memeagora.blogspot.com

More information

Stuart

Stuart Clojure Time Stuart Halloway stu@clojure.com @stuarthalloway Copyright 2007-2010 Relevance, Inc. This presentation is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United

More information

Clojure. A Dynamic Programming Language for the JVM. Rich Hickey

Clojure. A Dynamic Programming Language for the JVM. Rich Hickey Clojure A Dynamic Programming Language for the JVM Rich Hickey Clojure Fundamentals 3 years in development, released 10/2007 A new Lisp, not Common Lisp or Scheme Functional emphasis on immutability Supporting

More information

Identity, State and Values

Identity, State and Values Identity, State and Values Clojure s approach to concurrency Rich Hickey Agenda Functions and processes Identity, State, and Values Persistent Data Structures Clojure s Managed References Q&A Functions

More information

Tackling Concurrency With STM. Mark Volkmann 10/22/09

Tackling Concurrency With STM. Mark Volkmann 10/22/09 Tackling Concurrency With Mark Volkmann mark@ociweb.com 10/22/09 Two Flavors of Concurrency Divide and conquer divide data into subsets and process it by running the same code on each subset concurrently

More information

Tackling Concurrency With STM

Tackling Concurrency With STM Tackling Concurrency With Mark Volkmann mark@ociweb.com 10/22/09 Two Flavors of Concurrency Divide and conquer divide data into subsets and process it by running the same code on each subset concurrently

More information

This tutorial is designed for all those software professionals who are keen on learning the basics of Clojure and how to put it into practice.

This tutorial is designed for all those software professionals who are keen on learning the basics of Clojure and how to put it into practice. About the Tutorial Clojure is a high level, dynamic functional programming language. It is designed, based on the LISP programming language, and has compilers that makes it possible to be run on both Java

More information

ClojureScript. as a compilation target to JS. Michiel Vijay FP AMS October 16th 2014

ClojureScript. as a compilation target to JS. Michiel Vijay FP AMS October 16th 2014 ClojureScript as a compilation target to JS Michiel Borkent @borkdude Vijay Kiran @vijaykiran FP AMS October 16th 2014 This work is licensed under a Creative Commons Attribution 4.0 International License.

More information

Multi-core Parallelization in Clojure - a Case Study

Multi-core Parallelization in Clojure - a Case Study Multi-core Parallelization in Clojure - a Case Study Johann M. Kraus and Hans A. Kestler AG Bioinformatics and Systems Biology Institute of Neural Information Processing University of Ulm 29.06.2009 Outline

More information

Clojure Concurrency Constructs. CSCI 5828: Foundations of Software Engineering Lecture 12 10/02/2014

Clojure Concurrency Constructs. CSCI 5828: Foundations of Software Engineering Lecture 12 10/02/2014 Clojure Concurrency Constructs CSCI 5828: Foundations of Software Engineering Lecture 12 10/02/2014 1 Goals Cover the material presented in Chapters 3 & 4 of our concurrency textbook! Books examples from

More information

Interfacing Clojure with Pogamut 3 platform

Interfacing Clojure with Pogamut 3 platform Interfacing Clojure with Pogamut 3 platform Marcel Gołuński i, Piotr Wąsiewicz ii Institute of Electronic Systems, Warsaw University of Technology ABSTRACT In this paper we present an interface between

More information

What if Type Systems were more like Linters?

What if Type Systems were more like Linters? Typed Clojure An optional type system for Clojure What if Type Systems were more like Linters? Ambrose Bonnaire-Sergeant Me A Practical Optional Type System for Clojure (2012) Typed Clojure Indiegogo Campaign

More information

Clojure. A Dynamic Programming Language for the JVM. (and CLR) Rich Hickey

Clojure. A Dynamic Programming Language for the JVM. (and CLR) Rich Hickey Clojure A Dynamic Programming Language for the JVM (and CLR) Rich Hickey Agenda Fundamentals Rationale Feature Tour Integration with the JVM Q&A Clojure Fundamentals Dynamic a new Lisp, not Common Lisp

More information

Clojure: Enemy of the State

Clojure: Enemy of the State Clojure: Enemy of the State * * Not actually an enemy of the state, or state in general. :) Alex Miller @puredanger Roadmap Values vs objects Collections Sequences Generic data interfaces Identity and

More information

Programming Clojure, Third Edition

Programming Clojure, Third Edition Extracted from: Programming Clojure, Third Edition This PDF file contains pages extracted from Programming Clojure, Third Edition, published by the Pragmatic Bookshelf. For more information or to purchase

More information

Clojure. A (not-so-pure) functional approach to concurrency. Paolo Baldan Linguaggi per il Global Computing AA 2016/2017

Clojure. A (not-so-pure) functional approach to concurrency. Paolo Baldan Linguaggi per il Global Computing AA 2016/2017 Clojure A (not-so-pure) functional approach to concurrency Paolo Baldan Linguaggi per il Global Computing AA 2016/2017 In the words of the inventor Functional programming (rooted in Lisp, from 60s old

More information

Macro #clojureconj

Macro #clojureconj Macro Club @stuartsierra #clojureconj 500 sq ft I ( ) If it seems simple, you're probably doing it wrong. You can pry EMACS from my cold, dead fingers. The First Rule of Macro Club You do not

More information

June 27, 2014 EuroClojure 2014 Krakow, Poland. Components. Just Enough

June 27, 2014 EuroClojure 2014 Krakow, Poland. Components. Just Enough June 27, 2014 EuroClojure 2014 Krakow, Poland Components Just Enough Structure @stuartsierra Presentation Business Logic DB SMS Email Presentation Thread Pool Business Logic Queues Public API Private API

More information

Data Structures in Functional Languages

Data Structures in Functional Languages Data Structures in Functional Languages Performance Better than log Binary trees provide lg n performance B-trees provide log t n performance Can the performance be better than that? High branching factor

More information

clojure & cfml sitting in a tree sean corfield world singles

clojure & cfml sitting in a tree sean corfield world singles clojure & cfml sitting in a tree sean corfield world singles 1 how to go faster (with (parentheses)) sean corfield world singles 2 world singles 3 world singles founded in 2001 internet dating platform

More information

Clojure. The Revenge of Data. by Vjeran Marcinko Kapsch CarrierCom

Clojure. The Revenge of Data. by Vjeran Marcinko Kapsch CarrierCom Clojure The Revenge of Data by Vjeran Marcinko Kapsch CarrierCom Data Processing is what we do Most programs receive, transform, search, and send data Data is raw, immutable information In its essence,

More information

Executable Formal Specifications with Clojure. Matti Nieminen

Executable Formal Specifications with Clojure. Matti Nieminen Executable Formal Specifications with Clojure Matti Nieminen University of Tampere School of Information Sciences Computer Science M.Sc. Thesis Supervisor: Jyrki Nummenmaa June 2015 University of Tampere

More information

Lazytest Better Living Through Protocols. Stuart Sierra. Clojure NYC April 15, 2010

Lazytest Better Living Through Protocols. Stuart Sierra. Clojure NYC April 15, 2010 Lazytest Better Living Through Protocols Stuart Sierra Clojure NYC April 15, 2010 @stuartsierra #clojure clojure.core: tests as metadata (defn add ([x y] (+ x y)) {:test (fn [] (assert (= 7 (add 3 4))))})

More information

CS 2340 Objects and Design - Scala

CS 2340 Objects and Design - Scala CS 2340 Objects and Design - Scala Objects and Operators Christopher Simpkins chris.simpkins@gatech.edu Chris Simpkins (Georgia Tech) CS 2340 Objects and Design - Scala Objects and Operators 1 / 13 Classes

More information

Clojure Distilled. Immutable

Clojure Distilled. Immutable Clojure Distilled The difficulty in learning Clojure does not stem from its syntax, which happens to be extremely simple, but from having to learn new methods for solving problems. As such, we'll focus

More information

Week 2: The Clojure Language. Background Basic structure A few of the most useful facilities. A modernized Lisp. An insider's opinion

Week 2: The Clojure Language. Background Basic structure A few of the most useful facilities. A modernized Lisp. An insider's opinion Week 2: The Clojure Language Background Basic structure A few of the most useful facilities A modernized Lisp Review of Lisp's origins and development Why did Lisp need to be modernized? Relationship to

More information

Programming Clojure. Extracted from: Second Edition. The Pragmatic Bookshelf

Programming Clojure. Extracted from: Second Edition. The Pragmatic Bookshelf Extracted from: Programming Clojure Second Edition This PDF file contains pages extracted from Programming Clojure, published by the Pragmatic Bookshelf. For more information or to purchase a paperback

More information

Clojure & Incanter for Java Programmers

Clojure & Incanter for Java Programmers Clojure & Incanter for Java Programmers Ben Evans (@kittylyst) One half of (@java7developer) Slide Design by http://www.kerrykenneally.com 1 Who is this guy anyway? 2 Who is this guy anyway? 3 Demo Details

More information

A Practical Optional Type System for Clojure. Ambrose Bonnaire-Sergeant

A Practical Optional Type System for Clojure. Ambrose Bonnaire-Sergeant A Practical Optional Type System for Clojure Ambrose Bonnaire-Sergeant Statically typed vs. Dynamically typed Traditional distinction Dynamically typed Statically typed eg. Java, C, Haskell eg. Javascript,

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

Problems with Concurrency. February 19, 2014

Problems with Concurrency. February 19, 2014 with Concurrency February 19, 2014 s with concurrency interleavings race conditions dead GUI source of s non-determinism deterministic execution model 2 / 30 General ideas Shared variable Access interleavings

More information

Introduction to Clojure Concurrency (and data structures)

Introduction to Clojure Concurrency (and data structures) Introduction to Clojure Concurrency (and data structures) Karl Krukow, Engineer at Trifork & CTO LessPainful @karlkrukow Goto Amsterdam, May 2012 Introduction to Clojure Concurrency (and data structures)

More information

BUILDING DECLARATIVE GUIS WITH CLOJURE, JAVAFX AND FN-FX DR. NILS BLUM-OESTE

BUILDING DECLARATIVE GUIS WITH CLOJURE, JAVAFX AND FN-FX DR. NILS BLUM-OESTE BUILDING DECLARATIVE GUIS WITH CLOJURE, JAVAFX AND FN-FX DR. NILS BLUM-OESTE 08.02.2017 INTRODUCTION AND WHY? Reasons to build a desktop app with JavaFX WHY DO I NEED A SOLUTION FOR DESKTOP GUIS? Working

More information

Michiel DomCode, May 26th 2015

Michiel DomCode, May 26th 2015 ClojureScript ReactJS Michiel Borkent @borkdude DomCode, May 26th 2015 Michiel Borkent (@borkdude) Clojure(Script) developer at Clojure since 2009 Former lecturer, taught Clojure Agenda Part 1: ClojureScript

More information

Declarative concurrency. March 3, 2014

Declarative concurrency. March 3, 2014 March 3, 2014 (DP) what is declarativeness lists, trees iterative comutation recursive computation (DC) DP and DC in Haskell and other languages 2 / 32 Some quotes What is declarativeness? ness is important

More information

Common LISP Tutorial 1 (Basic)

Common LISP Tutorial 1 (Basic) Common LISP Tutorial 1 (Basic) CLISP Download https://sourceforge.net/projects/clisp/ IPPL Course Materials (UST sir only) Download https://silp.iiita.ac.in/wordpress/?page_id=494 Introduction Lisp (1958)

More information

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8 Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How

More information

STARCOUNTER. Technical Overview

STARCOUNTER. Technical Overview STARCOUNTER Technical Overview Summary 3 Introduction 4 Scope 5 Audience 5 Prerequisite Knowledge 5 Virtual Machine Database Management System 6 Weaver 7 Shared Memory 8 Atomicity 8 Consistency 9 Isolation

More information

Advanced concurrent programming in Java Shared objects

Advanced concurrent programming in Java Shared objects Advanced concurrent programming in Java Shared objects Mehmet Ali Arslan 21.10.13 Visibility To see(m) or not to see(m)... 2 There is more to synchronization than just atomicity or critical sessions. Memory

More information

Reagent. a ClojureScript interface to React. React Amsterdam Meetup 12 Feb. 2015

Reagent. a ClojureScript interface to React. React Amsterdam Meetup 12 Feb. 2015 Reagent a ClojureScript interface to React React Amsterdam Meetup 12 Feb. 2015 Michiel Borkent Twitter: @borkdude Email: michielborkent@gmail.com Clojure(Script) developer at Clojure since 2009 Former

More information

Ruby: Introduction, Basics

Ruby: Introduction, Basics Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 3 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie

More information

SAMPLE CHAPTER IN ACTION SECOND EDITION. Amit Rathore Francis Avila MANNING

SAMPLE CHAPTER IN ACTION SECOND EDITION. Amit Rathore Francis Avila MANNING SAMPLE CHAPTER IN ACTION SECOND EDITION Amit Rathore Francis Avila MANNING Clojure in Action Second Edition by Amit Rathore Francis Avila Chapter 1 Copyright 2016 Manning Publications brief contents 1

More information

Use of Clojure in Undergraduate CS Curriculum

Use of Clojure in Undergraduate CS Curriculum Use of Clojure in Undergraduate CS Curriculum Elena Machkasova University of Minnesota, Morris Boston Clojure meetup, November 8, 2012. 1 / 29 Outline UMM CS program 1 UMM CS program About UMM CS Clojure

More information

1.3.4 case and case* macro since 1.2. Listing Conditional Branching, Fast Switch. Listing Contract

1.3.4 case and case* macro since 1.2. Listing Conditional Branching, Fast Switch. Listing Contract 1.3.4 case and case* macro since 1.2 Listing 3. 14. Conditional Branching, Fast Switch (case [expression & clauses]) case is a conditional statement which accepts a list of testing conditions to determine

More information

Clojure for OOP folks Stefan innoq

Clojure for OOP folks Stefan innoq Clojure for OOP folks Stefan Tilkov @stilkov innoq 1 Motivation 2 Syntax Idioms 3 OOP Thinking model domains with classes & interfaces encapsulate data in objects prefer specific over generic solutions

More information

Towards Lean 4: Sebastian Ullrich 1, Leonardo de Moura 2.

Towards Lean 4: Sebastian Ullrich 1, Leonardo de Moura 2. Towards Lean 4: Sebastian Ullrich 1, Leonardo de Moura 2 1 Karlsruhe Institute of Technology, Germany 2 Microsoft Research, USA 1 2018/12/12 Ullrich, de Moura - Towards Lean 4: KIT The Research An University

More information

Map3D V58 - Multi-Processor Version

Map3D V58 - Multi-Processor Version Map3D V58 - Multi-Processor Version Announcing the multi-processor version of Map3D. How fast would you like to go? 2x, 4x, 6x? - it's now up to you. In order to achieve these performance gains it is necessary

More information

Functional programming is a productive

Functional programming is a productive Editor: Steve Vinoski vinoski@ieee.org The Functional Web ClojureScript: Functional Programming for JavaScript Platforms Mark McGranaghan Heroku Functional programming is a productive approach to writing

More information

Drinking from the Clojure fire hose

Drinking from the Clojure fire hose Drinking from the Clojure fire hose This chapter covers Scalars: the base data types Putting things together: collections Making things happen: functions Vars are not variables Locals, loops, and blocks

More information

Simple Java Programs. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Simple Java Programs. OOC 4 th Sem, B Div Prof. Mouna M. Naravani Simple Java Programs OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani /* */ A First Simple Program This is a simple Java program. Call this file "Example.java". class Example { } // Your program begins

More information

John McCarthy IBM 704

John McCarthy IBM 704 How this course works SI 334: Principles of Programming Languages Lecture 2: Lisp Instructor: an arowy Lots of new languages Not enough class time to cover all features (e.g., Java over the course of 34-36:

More information

Alan Bateman Java Platform Group, Oracle November Copyright 2018, Oracle and/or its affiliates. All rights reserved.!1

Alan Bateman Java Platform Group, Oracle November Copyright 2018, Oracle and/or its affiliates. All rights reserved.!1 Alan Bateman Java Platform Group, Oracle November 2018 Copyright 2018, Oracle and/or its affiliates. All rights reserved.!1 Project Loom Continuations Fibers Tail-calls Copyright 2018, Oracle and/or its

More information

A Survey of Concurrency Constructs. Ted Leung Sun

A Survey of Concurrency Constructs. Ted Leung Sun A Survey of Concurrency Constructs Ted Leung Sun Microsystems ted.leung@sun.com @twleung 16 threads 128 threads Today s model Threads Program counter Own stack Shared Memory Locks Some of the problems

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

Programming Languages

Programming Languages TECHNISCHE UNIVERSITÄT MÜNCHEN FAKULTÄT FÜR INFORMATIK Programming Languages Dispatching Method Calls Dr. Axel Simon and Dr. Michael Petter Winter term 2012 Dispatching - Outline Dispatching 1 Example

More information

Functional Programming and the Web

Functional Programming and the Web June 13, 2011 About Me Undergraduate: University of Illinois at Champaign-Urbana PhD: Penn State University Retrofitting Programs for Complete Security Mediation Static analysis, type-based compiler Racker:

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

Parallelism. Master 1 International. Andrea G. B. Tettamanzi. Université de Nice Sophia Antipolis Département Informatique

Parallelism. Master 1 International. Andrea G. B. Tettamanzi. Université de Nice Sophia Antipolis Département Informatique Parallelism Master 1 International Andrea G. B. Tettamanzi Université de Nice Sophia Antipolis Département Informatique andrea.tettamanzi@unice.fr Andrea G. B. Tettamanzi, 2014 1 Lecture 5, Part a Languages

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

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Haskell Programming

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Haskell Programming About the Tutorial Haskell is a widely used purely functional language. Functional programming is based on mathematical functions. Besides Haskell, some of the other popular languages that follow Functional

More information

Class definition. complete definition. public public class abstract no instance can be created final class cannot be extended

Class definition. complete definition. public public class abstract no instance can be created final class cannot be extended JAVA Classes Class definition complete definition [public] [abstract] [final] class Name [extends Parent] [impelements ListOfInterfaces] {... // class body public public class abstract no instance can

More information

Akka: Simpler Concurrency, Scalability & Fault-tolerance through Actors. Jonas Bonér Viktor Klang

Akka: Simpler Concurrency, Scalability & Fault-tolerance through Actors. Jonas Bonér Viktor Klang Akka: Simpler Concurrency, Scalability & Fault-tolerance through Actors Jonas Bonér Viktor Klang We believe that... Writing correct concurrent applications is too hard Scaling out applications is too hard

More information

Java Programming. Manuel Oriol, March 22nd, 2007

Java Programming. Manuel Oriol, March 22nd, 2007 Java Programming Manuel Oriol, March 22nd, 2007 Goal Teach Java to proficient programmers 2 Roadmap Java Basics Eclipse Java GUI Threads and synchronization Class loading and reflection Java Virtual Machines

More information

Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit

Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit Threads Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multitasking Thread-based multitasking Multitasking

More information

POETRY OF PROGRAMMING CODE READING EXERCISES IN CLOJURE V

POETRY OF PROGRAMMING CODE READING EXERCISES IN CLOJURE V POETRY OF PROGRAMMING CODE READING EXERCISES IN CLOJURE V2018.6.6 Contents 1. Introduction 1 1.1. Why do we need to read code? 1 1.2. Instructions 2 1.3. Recommended method 2 2. Function composition first

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Spring 2018 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory

More information

<Insert Picture Here> Get on the Grid. JVM Language Summit Getting Started Guide. Cameron Purdy, VP of Development, Oracle

<Insert Picture Here> Get on the Grid. JVM Language Summit Getting Started Guide. Cameron Purdy, VP of Development, Oracle Get on the Grid JVM Language Summit Getting Started Guide Cameron Purdy, VP of Development, Oracle The following is intended to outline our general product direction. It is intended

More information

Modeling Process. Rich Hickey

Modeling Process. Rich Hickey Modeling Process Rich Hickey Which are more fundamental? Messages, classes, encapsulation, inheritance, dispatch... Time, value, identity, state, persistence, transience, place, perception, visibility,

More information

COMP31212: Concurrency A Review of Java Concurrency. Giles Reger

COMP31212: Concurrency A Review of Java Concurrency. Giles Reger COMP31212: Concurrency A Review of Java Concurrency Giles Reger Outline What are Java Threads? In Java, concurrency is achieved by Threads A Java Thread object is just an object on the heap, like any other

More information

Virtual Machine Design

Virtual Machine Design Virtual Machine Design Lecture 4: Multithreading and Synchronization Antero Taivalsaari September 2003 Session #2026: J2MEPlatform, Connected Limited Device Configuration (CLDC) Lecture Goals Give an overview

More information

Efficient Composition Styles

Efficient Composition Styles Efficient Composition Styles Franz Achermann, Nathanael Schärli Software Composition Group University of Berne www.iam.unibe.ch/~ scg Software Composition Group Slide 1 of 15 Overview Introduction What

More information

OBJECT ORIENTED PROGRAMMING TYm. Allotted : 3 Hours Full Marks: 70

OBJECT ORIENTED PROGRAMMING TYm. Allotted : 3 Hours Full Marks: 70 I,.. CI/. T.cH/C8E/ODD SEM/SEM-5/CS-504D/2016-17... AiIIIII "-AmI u...iir e~ IlAULAKA ABUL KALAM AZAD UNIVERSITY TECHNOLOGY,~TBENGAL Paper Code: CS-504D OF OBJECT ORIENTED PROGRAMMING TYm. Allotted : 3

More information

Transactifying Apache s Cache Module

Transactifying Apache s Cache Module H. Eran O. Lutzky Z. Guz I. Keidar Department of Electrical Engineering Technion Israel Institute of Technology SYSTOR 2009 The Israeli Experimental Systems Conference Outline 1 Why legacy applications

More information

Programming Safe Agents in Blueprint. Alex Muscar University of Craiova

Programming Safe Agents in Blueprint. Alex Muscar University of Craiova Programming Safe Agents in Blueprint Alex Muscar University of Craiova Programmers are craftsmen, and, as such, they are only as productive as theirs tools allow them to be Introduction Agent Oriented

More information

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question) CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers

More information

Functional Objects. Christopher Simpkins CS 3693, Fall Chris Simpkins (Georgia Tech) CS 3693 Scala / 1

Functional Objects. Christopher Simpkins CS 3693, Fall Chris Simpkins (Georgia Tech) CS 3693 Scala / 1 Functional Objects Christopher Simpkins csimpkin@spsu.edu CS 3693, Fall 2011 Chris Simpkins (Georgia Tech) CS 3693 Scala 2011-08-29 1 / 1 Functional Objects Functional objects have immutable state. Immutable

More information

Midterm Exam CS 251, Intermediate Programming March 6, 2015

Midterm Exam CS 251, Intermediate Programming March 6, 2015 Midterm Exam CS 251, Intermediate Programming March 6, 2015 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

Robot Programming with Lisp

Robot Programming with Lisp 4. Functional Programming: Higher-order Functions, Map/Reduce, Lexical Scope Institute for Artificial University of Bremen 9 of November, 2017 Functional Programming Pure functional programming concepts

More information

What the optimizer does to your code

What the optimizer does to your code 1 / 12 Miguel Garcia http://lamp.epfl.ch/~magarcia LAMP, EPFL 2012-04-18 2 / 12 Outline Things the optimizer is good at Example Pros and Cons Early inlining Parallelizing an optimization phase Further

More information

Applied Unified Ownership. Capabilities for Sharing Across Threads

Applied Unified Ownership. Capabilities for Sharing Across Threads Applied Unified Ownership or Capabilities for Sharing Across Threads Elias Castegren Tobias Wrigstad DRF transfer parallel programming AppliedUnified Ownership memory management placement in pools (previous

More information

Compiler construction 2009

Compiler construction 2009 Compiler construction 2009 Lecture 2 Code generation 1: Generating Jasmin code JVM and Java bytecode Jasmin Naive code generation The Java Virtual Machine Data types Primitive types, including integer

More information

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and Classes CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

Next Gen Networking Infrastructure With Rust

Next Gen Networking Infrastructure With Rust Next Gen Networking Infrastructure With Rust Hi, I m @carllerche You may remember me from Most newer databases are written in a language that includes a runtime C / C++ Memory management we ll do it live

More information

Manchester University Transactions for Scala

Manchester University Transactions for Scala Manchester University Transactions for Scala Salman Khan salman.khan@cs.man.ac.uk MMNet 2011 Transactional Memory Alternative to locks for handling concurrency Locks Prevent all other threads from accessing

More information

Dialects of ML. CMSC 330: Organization of Programming Languages. Dialects of ML (cont.) Features of ML. Functional Languages. Features of ML (cont.

Dialects of ML. CMSC 330: Organization of Programming Languages. Dialects of ML (cont.) Features of ML. Functional Languages. Features of ML (cont. CMSC 330: Organization of Programming Languages OCaml 1 Functional Programming Dialects of ML ML (Meta Language) Univ. of Edinburgh,1973 Part of a theorem proving system LCF The Logic of Computable Functions

More information

CST242 Concurrency Page 1

CST242 Concurrency Page 1 CST242 Concurrency Page 1 1 2 3 4 5 6 7 9 Concurrency CST242 Concurrent Processing (Page 1) Only computers with multiple processors can truly execute multiple instructions concurrently On single-processor

More information

Functional programming

Functional programming Functional programming Functional programming In functional programming, functions are the core building blocks In pure functional programming, functions are like mathematical functions Mathematical functions

More information

CompSci 125 Lecture 02

CompSci 125 Lecture 02 Assignments CompSci 125 Lecture 02 Java and Java Programming with Eclipse! Homework:! http://coen.boisestate.edu/jconrad/compsci-125-homework! hw1 due Jan 28 (MW), 29 (TuTh)! Programming:! http://coen.boisestate.edu/jconrad/cs125-programming-assignments!

More information

Quote of the Day. CS Functional Programming. Introductory Notes on Lisp/Clojure. Another Quote. What is Clojure? 1-4

Quote of the Day. CS Functional Programming. Introductory Notes on Lisp/Clojure. Another Quote. What is Clojure? 1-4 Quote of the Day CS 326 - Functional Programming Introductory Notes on Lisp/Clojure Dr. Stephen P. Carl By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more

More information

The Actor Model. Towards Better Concurrency. By: Dror Bereznitsky

The Actor Model. Towards Better Concurrency. By: Dror Bereznitsky The Actor Model Towards Better Concurrency By: Dror Bereznitsky 1 Warning: Code Examples 2 Agenda Agenda The end of Moore law? Shared state concurrency Message passing concurrency Actors on the JVM More

More information