<Insert Picture Here> Scripting Languages: Options for the JVM

Size: px
Start display at page:

Download "<Insert Picture Here> Scripting Languages: Options for the JVM"

Transcription

1

2 <Insert Picture Here> Scripting Languages: Options for the JVM Simon Ritter Technology Evangelist

3 Languages, Languages Everywhere Clojure Tcl JavaScript v-language CAL Sather Funnel Mini PLAN Lisp Scheme Basic Logo JHCR TermWare Drools Prolog LLP JESS Eiffel Smalltalk C# G Groovy Nice Anvil Hojo Correlate Ada Bex Script Tea PHP Phobos Sleep FScript JudoScript JRuby ObjectScript Jickle Yoix Simkin BeanShell Dawn WebL iscript Jython Pnuts Yassl Forth Piccola SALSA Processing Zigzag Tiger Tiger Icon Pascal Oberon Modula-2 Luck E Rexx JavaFX Script Scala

4 Objective Survey of Dynamic Languages on the JVM Groovy, Ruby, Scala, Clojure

5 What to (Not) Expect EXPECT Discussion on a small subset of the languages Highlight interesting language features Contrast with Java DON'T EXPECT Hello World Coverage of all features Which is a 'better' language Java bashing

6 Why So Many Languages? Domain specific languages All modern languages are Turing complete How you do things varies wildly Different languages approach problems in different ways Freedom of choice

7 Why On The JVM Many languages require runtime support GC, memory management, etc Every problem in computer science can be solved by adding a layer of indirection Butler Lampson VM is the indirection layer Abstraction from hardware Portability, Security, Performance, Reliability

8 <Insert Picture Here> Groovy groovy.codehaus.o rg/

9 Language Features 1 Object oriented programming language Syntax is very similar to Java feels very much like Java Runs Java sources files Compact and concise syntax Optional semi colon and parenthesis Native syntax for list, maps and regex Seamless bi-directional integration with Java Groovy extending Java class implementing Groovy interfaces Reuse Java's infrastructure classes, security, threads, etc Closure, properties and operator overloading support

10 Language Features 2 Easy integration with Java application via JSR-223 One JAR file embeddable/groovy-all-1.x.y.jar Meta Object Protocol (MOP) provides the meta programming capabilities A runtime layer which any application can participate

11 A Valid Java Program import java.util.*; public class Erase { private List<String> filterlongerthan(list<string> list, int len) { List<String> result = new ArrayList<String>(); for (String n: list) if (n.length() <= len) result.add(n); return (result); public static void main(string... args) { List<String> names = new ArrayList<String>(); names.add( Fred ); names.add( Barney); names.add( Wilma ); names.add( Betty ); System.out.println(names); Erase e = new Erase(); List<String> shortnames = e.filterlongerthan(names, 5); System.out.println(shortNames);

12 A Valid Groovy Program import java.util.*; public class Erase { private List<String> filterlongerthan(list<string> list, int len) { List<String> result = new ArrayList<String>(); for (String n: list) if (n.length() <= len) result.add(n); return (result); public static void main(string... args) { List<String> names = new ArrayList<String>(); names.add( Fred ); names.add( Barney); names.add( Wilma ); names.add( Betty ); System.out.println(names); Erase e = new Erase(); List<String> shortnames = e.filterlongerthan(names, 5); System.out.println(shortNames);

13 Groovy Way Automatically imports java.util.* Native list syntax def names = ["Ted", "Fred", "Jed", "Ned"] println names Creates an ArrayList Closure support def shortnames = names.findall { it.size() <= 3 Operator overloading def diff = names - shortnames print diff

14 Operator Overloading Every operator can be overloaded via corresponding method Eg. plus() for '+', leftshift() for '<<', etc. Special method for switch classification Override is iscase() public class Family { def members = [] def plus(person o) { members += o members def plus(family f) { members += f.members members Person fred = Person wilma = Family flintstones = flintstone += fred + wilma Person barney = Person betty = Family rubble = rubble += barney + betty

15 Category Add temporary methods or behaviour to instances of object code block class StringCalcutation { static def plus(string self, String operand) { try { return (self.tointeger() + operand.tointeger()).tostring() catch (NumberFormatException f) { return (self << operand) println use(stringcalculation) { println Redefine the behaviour of + in code block Example adapted from Groovy in Action by Dierk Konig et al

16 Closure A piece of code that is wrapped in an object Anonymous functions/methods Behaves like data, but can be invoked Takes 2 parameters. Closure has a default value def perform(int times, Closure c = {) { for (i = 0; i < times; i++) c.call(i) perform(3) { x -> println hello: ${x Parameter Code block not executed but passed as a parameter

17 Meta Object Protocol Provides dynamic behaviour to Groovy Intercept method calls, create classes and methods, etc MOP consists of: Formalized behaviour for resolving methods/properties Two major classes: GroovyObject and MetaClass Override methods in MetaClass to redefine behaviour Lots of libraries uses MOP String.metaClass.constructor = { constructor = String.class.getConstructor(String.class) constructor.newinstance((new Date()).toString()) println new String() Sat Nov Replace the default constructor Example adapted from Groovy in Action by Dierk Konig et al

18 <Insert Picture Here> Ruby

19 Language Features Supports multiple programming paradigm Imperative, object oriented, functional and reflective Excellent support for reflective programming / metaprogramming Continuation support Freeze a point in the application and return to it later Supports reuse through inheritance, mixins and open classes Open classes is the ability to modify an existing class including those from the host library Eg. add rot13() method to java.lang.string

20 Objects and Method Calls Everything in Ruby is an object Everything is a method call Message passing masquerading as method calls obj.fred is the same as obj.send(:fred)as Method invocation means sending a message to the object Use respond_to? to inspect if an object supports a particular message Methods can be invoked with our without parenthesis Excellent for readability and DSL x = is equivalent to x = 1.+(2.send(:+, 3)) puts ugly_d.quack if ugly_d.respond_to? :quack

21 Reuse Inheritance (traditional object oriented approach) class KaraokeSong < Song def to_s super + [#{@lyrics] end Inherit from Song This means super.to_s from context

22 Reuse Mixins - Adding a module into a class or object Cannot be intantiated module ClassName def class_name self.class.name end end class Song include ClassName s = Song.new(...).extend(ClassName) Mixin to class or instance

23 Reuse Open classes - adding methods to classes or objects class String def rot13 self.tr( A-Ma-mN-Zn-z, N-Zn-zA-Ma-m ) end end

24 Metaprogramming with Ruby Technique by which a program can manipulate another program or itself as their data Ruby relies on metaprogramming heavily Eg. in declaring properties Introspect into a a class, object or the running environment Eg. ObjectSpace.each_object(String) { x puts x Allows you to trap interesting behaviour and override or enhance them Similiar to AOP Eg. creating a method, instantiating an object, invoking a missing method, querying if a member is defined, etc. Eg. emulate ExpandoMetaClass in Groovy by trapping undefined method names

25 Continuations Abstract representation of the rest of the code to be executed if (i > 10) puts i > 10 else puts i < 10 end The continuation of if (i > 10) is puts i > 10 iff i > 10 puts i < 10 iff i < 10 Uses of continuations Coroutines, escape and reenter loops/recursion, debugger, need to backtrack Eg. Able to return to the point of exception after handling the exception

26 callcc callcc to construct a continuation object in Ruby Encapsulates the state of the application up to callcc Use the continuation object to jump to just after the callcc result = 1 i = 1 callcc { $cont_obj Ruby passes a continuation result *= i object to block i += 1 $cont_obj.call if (i <= 10) Returns to the statement just after the callcc

27 Example - Coroutine def ping puts "PING 1" save_and_resume($ping_cont, nil) pong puts "PING 2" save_and_resume($ping_cont, $pong_cont) puts "PING 3" save_and_resume($ping_cont, $pong_cont) end def pong puts "PONG 1" save_and_resume($pong_cont, $ping_cont) puts "PONG 2" save_and_resume($pong_cont, $ping_cont) puts "PONG 3" save_and_resume($pong_cont, $ping_cont) end ping PING 1 PONG 1 PING 2 PONG 2 PING 3 PONG 3 Example adapted from Call with Current Continuation Patterns by Darrell Ferguson, Dwight Deugo

28 <Insert Picture Here> Scala

29 Language Features 1 A hybrid of object and functional Supports mutable and immutable (functional) structures Defaults to immutable for collections Objects, singletons and traits Singleton is a language concept Very similar to interfaces but with fully implemented methods Cannot be instantiated, can only be mixed into a class or object Pseudo operator overloading Operators are all method calls

30 Language Features 2 Statically typed unique in the world of script language Can infer types from code during declaration Easily implement new types and corresponding operations Supports user define implicit type conversion Statically typed higher order functions More rigorous in what you can pass to a method Supports many high level concurrency abstraction Monitors, atomic variables, semaphores, workers, channels, etc Erlang style actors

31 Statically Typed Must provide type in method definition Elsewhere Scala can infer type from the context var map = Map[Int, String](1 -> Cat, 2 -> Dog ) Method return type, variable declaration Including closure / functions types var myfunc: ((Int, Int) => Complex) = null def sumoffactors(number: Int): Int = { var sum = 0 Method declaration for (i <- 1 to number) if ((sum % i) == 0) Inferring from context sum += i sum

32 Singletons Refer to as companion objects in Scala Use extensively in Scala class libraries Defined in the same file as the class Can access private constructors object Employee { def apply(name: String, id: String) = Curried function new Employee(name, id) def apply(name: String, id: String, salary: Double) (verify: (String, String, Double)=> Option[Employee]) :Option[Employee] = { Singleton if (verify(name, id, salary)) Some(new Employee(name, id, salary)) else None Option indicates we may not be getting any result Closure's signature

33 Traits Similar to interfaces with partial implementations trait Greetings { def sayhello(name: String) = Hello + name Mixed in to classes or selectively to object instances Mixin to class class Employee(override val name: String, val id: String) extends Person(name) with Greetings { Mixin to instance Only applicable if there are no abstract methods val fred = new Employee( Fred, 007 ) with Greetings

34 Selective Mixin Can enforce mixing traits only into certain classes By extending from a class Late binding with super object Resolution of super proceeds from right to left Eg class A extends B with TraitA with TraitB TraitB TraitA A assuming B is a class Excellent for implementing decorator or chain-of-command pattern

35 Example Selective Mixin 1 class Person(val name: String) { def calculatesalary(base: Double) = base class Employee(...) extends Person(...) { def mysalary() = calculatesalary(salary)... trait SpotBonus extends Person { Can only be mixin to classes that extends from Person override def calculatesalary(base: Double) = super.calculatesalary(base + (base * 0.05)) trait ThirteenMonth extends Person { override def calculatesalary(base: Double) = super.calculatesalary(base + base)

36 Operators on Types All method calls, no notion of operators Operator precedence is based on ordering of symbols Eg. all letters,, ^, &, < >, =!,:, + -, * % /, all other special characters Unary operators, prefixed with unary_ class Employee(override name: String... //As before def +(_salary: Double) = this.salary + _salary def -:(_salary: Double) = this.salary - _salary def unary_>>!(): Employee =... //promotion def unary_<<!(): Employee =... //demotion fred.salary = fred //Method call fred.+(1000) fred >>! //promote fred 100 -: fred Instance to follow method

37 Implicit Type Conversion Most language have build in implicit conversion Eg. byte + int byte is converted to int Scala allows you to define implicit conversion Use implicit keyword on method var yesterday = 1 days ago class DateHelper(num: Int) { def days(when: String) = { var date = Calendar.getInstance() when match { case ago => date.add(calendar.day_of_month, -num)... date.gettime() Converter that takes 1 and return???.days( ago ) def implicit convertint2datehelper(num: Int) = new DateHelper(num) * Adapted from Programming Scala by Venkat Subramaniam

38 Concurrency Lots of abstraction to support concurrency and asynchrony Signals, monitors, atomic objects, semaphores, workers, mail boxes, actors etc Actor based model A computation entity that inherently concurrent Communicate by send it messages Can change its state or spawn new actors based on messages Two ways of using actors actor method Extend Actor class Communications! to send a message receive case to select message based on type

39 <Insert Picture Here> Clojure

40 Language Features 1 Functional language Verb (functions) is the central theme, not noun (objects) No side effects only depends on its arguments Most Java method do not qualify as functions Give the same argument, will return the same result EVERYTIME Functions are stateless f(x) = f(y) if x is equals y Higher order functions f(x) g(y) where x and y can be functions Closure is very natural Lambda Parameter Body (defn make-greeter [greetings] (fn [name] (format %s, %s greetings name))) ((make-greeter Bonjour ) Jean ) Bonjour, Jean

41 Language Features 2 All data is immutable no data is ever changed * (def foo '(a b c)) (a b c) Reassigned (concat foo '(x y z)) (a b c x y z) foo (a b c) (def foo (concat foo '(x y z))) (a b c x y z) Everything is a sequence with abstractions List (a b c) Vector [a b c] Set #{a b c Map {:x a, :y b, :z c *except for refs

42 Language Features - 3 Homoiconic the data structure is the language No language syntax just have to know how to write parenthesis Evaluation rules first element is the function name Everything else are parameters

43 Calculate 10! Java public int fac(final int f) { int tot = 1; for (int i = 1; i < f; i++ tot *= i return (tot); Clojure (defn fac [f] (if (zero? f) 1 (* f (fac (dec f))))) Function defintion

44 Concurrency Supports 4 concurrency model Agents actors but pass functions instead of messages Atoms like java.util.concurrent.atomic References database like transaction semantics a.k.a Software Transaction Memory (STM) Vars thread local Agents Atoms References Vars Shared X X X Isolated Synchronous X X Asynchronous Coordinated Autonomous X X X X X

45 Sharing Data via Managed References Thread A foo Thread B bar Data Most programming languages eg. Java, C, etc. Thread A Thread B Data Deference to access immutable data

46 Agents Use to manage independent states Send functions to modify the state of the agent Functions are executed asynchronously Only one function is evaluated at a time Some notion of ordering (def foo (agent 0 is immutable (send foo inc)... after some 1

47 References and STM References (ref) provide database like transaction Software transactional memory All or nothing Data are not visible until you commit All changes happens at constant time You see all the changes at once No inconsistent data during transaction Thanks to Clojure's immutable data All references must occur in a transaction Create references with ref Use either alter or commute to change the ref dosync execute expressions in a transaction alter and commute will only run in dosync

48 Handling Conflicts with alter (dosync (alter foo assoc...)) (assoc...) (assoc...) time foo altered by another transaction Transaction is retried At the start of the transaction Get an in transaction copy of foo's value Value will never be inconsistent data is immutable At the end of the transaction foo is check if it has changed during the transaction If it has, transaction is retried Body of transaction must be side effect free Otherwise transaction commits new value visible to all

49 Handling Conflicts with commute (dosync (commute foo assoc...)) (assoc...) (assoc...) time foo altered by another transaction Function is retried Same semantics as alter Except at the end of the transaction If foo is altered, the function is retried Function must be commutative and without side effects Eg. deposit is a commutative operation You can invoke deposit in any order, the final state of the account will still be consistent Withdrawal is not commutative

50 Conclusions Java Virtual Machine can support many languages Many different syntaxs Many different constructs Procedural, declarative or functional Static or dynamic typing Freedom of choice for developers Consistent security, stability and portability JDK7 will improve support for dynamic languages InvokeDynamic bytecode

51 The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle.

52

TOWARDS A UNIVERSAL VIRTUAL MACHINE

TOWARDS A UNIVERSAL VIRTUAL MACHINE TOWARDS A UNIVERSAL VIRTUAL MACHINE Alex Buckley Specification Lead, Java Language and VM Sun Microsystems John Rose Lead Engineer, Multi-Language Virtual Machine Sun Microsystems 1 Overview The Java Virtual

More information

VM Optimizations for Language Designers

VM Optimizations for Language Designers John Pampuch! Director, VM Technology Client Software Group VM Optimizations for Language Designers Exact File Name 9/24/08 Page 1 There once was a time... Java 2 / 32 Exact File Name 9/24/08 Page 2 Oh

More information

Bytecodes Meet Combinators

Bytecodes Meet Combinators ! Bytecodes Meet Combinators John Rose Architect, Da Vinci Machine Project Sun Microsystems VMIL 2009: 3rd Workshop on Virtual Machines and Intermediate Languages (OOPSLA, Orlando, Florida October 25,

More information

Java SE: The Road Ahead

Java SE: The Road Ahead Java SE: The Road Ahead Brian Goetz Java Language Architect Copyright 2010 Oracle and/or its affiliates. All rights reserved. 1.0 1996 1.0 1.1 1996 1997 1.0 1.2 1.1 1996 1997 1998 1.0 1.2 1.1 1.3 1996

More information

Evolving the Java platform. Ola Bini JRuby Core Developer ThoughtWorks Studios

Evolving the Java platform. Ola Bini JRuby Core Developer ThoughtWorks Studios Evolving the Java platform Ola Bini JRuby Core Developer ThoughtWorks Studios About me Ola Bini From Stockholm, Sweden JRuby Core Developer ThoughtWorks Studios Member of the JSR292 expert group Programming

More information

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

Introduction Basics Concurrency Conclusion. Clojure. Marcel Klinzing. December 13, M. Klinzing Clojure 1/18 Clojure Marcel Klinzing December 13, 2012 M. Klinzing Clojure 1/18 Overview/History Functional programming language Lisp dialect Compiles to Java Bytecode Implemented in Java Created by Rich Hickey Version

More information

Using Scala for building DSL s

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

More information

Scala : 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

Groovy Primer Chris Dail Groovy Primer (March 2010)

Groovy Primer Chris Dail  Groovy Primer (March 2010) Groovy Primer Chris Dail http://chrisdail.com Twitter: @chrisdail What is Groovy? An agile dynamic language for the Java Platform Both dynamically and statically typed Functional programming influence

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 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

Jussi Riihelä / Jussi Riihelä

Jussi Riihelä / Jussi Riihelä 28.4.2006 Jussi Riihelä jussi.riihela@nokia.com 1 2006-04-28 / Jussi Riihelä Content Basic facts and motivation Groovy features IDE support and runtime dependencies Criticism 2 2006-04-28 / Jussi Riihelä

More information

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie

More information

Introduction to Programming Using Java (98-388)

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

More information

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

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

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

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

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

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

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

More information

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

New Programming Paradigms

New Programming Paradigms New Programming Paradigms Lecturer: Pánovics János (google the name for further details) Requirements: For signature: classroom work and a 15-minute presentation Exam: written exam (mainly concepts and

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

1 Shyam sir JAVA Notes

1 Shyam sir JAVA Notes 1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write

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

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

CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Dan Grossman Winter 2013

CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Dan Grossman Winter 2013 CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP Dan Grossman Winter 2013 Ruby logistics Next two sections use the Ruby language http://www.ruby-lang.org/ Installation / basic usage

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

A guide to learning the popular JVM programming language, Groovy 2.x, and its ecosystem

A guide to learning the popular JVM programming language, Groovy 2.x, and its ecosystem Learning Groovy A guide to learning the popular JVM programming language, Groovy 2.x, and its ecosystem Adam L. Davis This book is for sale at http://leanpub.com/learninggroovy This version was published

More information

Ruby logistics. CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Ruby: Not our focus. Ruby: Our focus. A note on the homework

Ruby logistics. CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Ruby: Not our focus. Ruby: Our focus. A note on the homework Ruby logistics CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP Dan Grossman Autumn 2018 Next two sections use the Ruby language http://www.ruby-lang.org/ Installation / basic usage

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

Computer Components. Software{ User Programs. Operating System. Hardware

Computer Components. Software{ User Programs. Operating System. Hardware Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point

More information

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

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

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

More information

Who am I? Harlan Iverson. Programming enthusiast. Seeker of truth. Imperfect. I'll be wrong about some things. Please correct me if you can.

Who am I? Harlan Iverson. Programming enthusiast. Seeker of truth. Imperfect. I'll be wrong about some things. Please correct me if you can. Who am I? Harlan Iverson. Programming enthusiast. Seeker of truth. Imperfect. I'll be wrong about some things. Please correct me if you can. P.S... I hate boring presentations. Please, engage and stay

More information

Final-Term Papers Solved MCQS with Reference

Final-Term Papers Solved MCQS with Reference Solved MCQ(S) From FinalTerm Papers BY Arslan Jan 14, 2018 V-U For Updated Files Visit Our Site : Www.VirtualUstaad.blogspot.com Updated. Final-Term Papers Solved MCQS with Reference 1. The syntax of PHP

More information

C++ Important Questions with Answers

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

More information

Produced by. Agile Software Development. Eamonn de Leastar

Produced by. Agile Software Development. Eamonn de Leastar Agile Software Development Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie Xtend Programming

More information

Computer Components. Software{ User Programs. Operating System. Hardware

Computer Components. Software{ User Programs. Operating System. Hardware Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point

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

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

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

More information

Sri Vidya College of Engineering & Technology

Sri Vidya College of Engineering & Technology UNIT I INTRODUCTION TO OOP AND FUNDAMENTALS OF JAVA 1. Define OOP. Part A Object-Oriented Programming (OOP) is a methodology or paradigm to design a program using classes and objects. It simplifies the

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

Introduce C# as Object Oriented programming language. Explain, tokens,

Introduce C# as Object Oriented programming language. Explain, tokens, Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation

More information

Atelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Atelier Java - J1. Marwan Burelle.  EPITA Première Année Cycle Ingénieur. marwan.burelle@lse.epita.fr http://wiki-prog.kh405.net Plan 1 2 Plan 3 4 Plan 1 2 3 4 A Bit of History JAVA was created in 1991 by James Gosling of SUN. The first public implementation (v1.0) in 1995.

More information

Class, Variable, Constructor, Object, Method Questions

Class, Variable, Constructor, Object, Method Questions Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx

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

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

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

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and

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

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

Universe Type System for Eiffel. Annetta Schaad

Universe Type System for Eiffel. Annetta Schaad Universe Type System for Eiffel Annetta Schaad Semester Project Report Software Component Technology Group Department of Computer Science ETH Zurich http://sct.inf.ethz.ch/ SS 2006 Supervised by: Dipl.-Ing.

More information

Xtend Programming Language

Xtend Programming Language Xtend Programming Language Produced by: Eamonn de Leastar (edeleastar@wit.ie) Department of Computing and Mathematics http://www.wit.ie/ Agenda Subtitle Excellent Xtend User Guide (Version 2.6) API Docs

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

invokedynamic under the hood

invokedynamic under the hood Nadeesh T V ORACLE India Pvt Ltd 26 Aug 2016 Outline 1 JVM Languages 2 PreInvokedynamic 3 Invokedynamic 4 MethodHandle 5 Summary JVM Languages Languages which can run on Java Virtual Machine (JVM) Should

More information

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES CS-3304 Introduction In Text: Chapter 1 & 2 COURSE DESCRIPTION 2 What will you learn? Survey of programming paradigms, including representative languages Language definition and description methods Overview

More information

2 rd class Department of Programming. OOP with Java Programming

2 rd class Department of Programming. OOP with Java Programming 1. Structured Programming and Object-Oriented Programming During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach

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

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

Anatomy of a Compiler. Overview of Semantic Analysis. The Compiler So Far. Why a Separate Semantic Analysis?

Anatomy of a Compiler. Overview of Semantic Analysis. The Compiler So Far. Why a Separate Semantic Analysis? Anatomy of a Compiler Program (character stream) Lexical Analyzer (Scanner) Syntax Analyzer (Parser) Semantic Analysis Parse Tree Intermediate Code Generator Intermediate Code Optimizer Code Generator

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

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 role of semantic analysis in a compiler

The role of semantic analysis in a compiler Semantic Analysis Outline The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

Java, Dynamic Languages and DSL. Lee Chuk Munn Staff Engineer Sun Microsystems

Java, Dynamic Languages and DSL. Lee Chuk Munn Staff Engineer Sun Microsystems Java, Dynamic Languages and DSL Lee Chuk Munn Staff Engineer Sun Microsystems 1 Objective How to Script Enable Your Application Agenda Scripting and Java JSR-223 Overview Groovy Language Scripting Groovy

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

Produced by. Agile Software Development. Eamonn de Leastar

Produced by. Agile Software Development. Eamonn de Leastar Agile Software Development Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie Xtend Programming

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

Thanks! Review. Course Goals. General Themes in this Course. There are many programming languages. Teaching Assistants. John Mitchell.

Thanks! Review. Course Goals. General Themes in this Course. There are many programming languages. Teaching Assistants. John Mitchell. 1 CS 242 Thanks! Review John Mitchell Final Exam Wednesday Dec 8 8:30 11:30 AM Gates B01, B03 Teaching Assistants Mike Cammarano TJ Giuli Hendra Tjahayadi Graders Andrew Adams Kenny Lau Vishal Patel and

More information

Lecture 6 Introduction to Objects and Classes

Lecture 6 Introduction to Objects and Classes Lecture 6 Introduction to Objects and Classes Outline Basic concepts Recap Computer programs Programming languages Programming paradigms Object oriented paradigm-objects and classes in Java Constructors

More information

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Familiarize yourself with all of Kotlin s features with this in-depth guide Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Copyright 2017 Packt Publishing First

More information

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

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

More information

Ruby: Introduction, Basics

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

More information

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Things to Review Review the Class Slides: Key Things to Take Away Do you understand

More information

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,

More information

The Java Programming Language

The Java Programming Language The Java Programming Language Slide by John Mitchell (http://www.stanford.edu/class/cs242/slides/) Outline Language Overview History and design goals Classes and Inheritance Object features Encapsulation

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

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

More information

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

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

More information

20 Most Important Java Programming Interview Questions. Powered by

20 Most Important Java Programming Interview Questions. Powered by 20 Most Important Java Programming Interview Questions Powered by 1. What's the difference between an interface and an abstract class? An abstract class is a class that is only partially implemented by

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

COP4020 Programming Assignment 1 - Spring 2011

COP4020 Programming Assignment 1 - Spring 2011 COP4020 Programming Assignment 1 - Spring 2011 In this programming assignment we design and implement a small imperative programming language Micro-PL. To execute Mirco-PL code we translate the code to

More information

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given MUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala faisalgrw123@gmail.com MEGA File Solved MCQ s For Final TERM EXAMS CS508- Modern Programming Languages Question No: 1 ( Marks: 1 ) -

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

Call with Current Continuation Patterns

Call with Current Continuation Patterns Call with Current Continuation Patterns Darrell Ferguson Dwight Deugo August 24, 2001 Abstract This paper outlines the recurring use of continuations. A brief overview of continuations is given. This is

More information

NOTE: Answer ANY FOUR of the following 6 sections:

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

More information

Basic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2

Basic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2 Basic Concepts Computer Science Computer - Science - Programming history Algorithms Pseudo code 2013 Andrew Case 2 Basic Concepts Computer Science Computer a machine for performing calculations Science

More information

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

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

More information

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

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

More information

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

Expressions and Assignment

Expressions and Assignment Expressions and Assignment COS 301: Programming Languages Outline Other assignment mechanisms Introduction Expressions: fundamental means of specifying computations Imperative languages: usually RHS of

More information

Scala. Fernando Medeiros Tomás Paim

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

More information

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

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

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

More information

<Insert Picture Here> Implementing lambda expressions in Java

<Insert Picture Here> Implementing lambda expressions in Java Implementing lambda expressions in Java Brian Goetz Java Language Architect Adding lambda expressions to Java In adding lambda expressions to Java, the obvious question is: what is

More information

<Insert Picture Here> Adventures in JSR-292 or How To Be A Duck Without Really Trying

<Insert Picture Here> Adventures in JSR-292 or How To Be A Duck Without Really Trying Adventures in JSR-292 or How To Be A Duck Without Really Trying Jim Laskey Multi-language Lead Java Language and Tools Group The following is intended to outline our general product

More information

Programmiersprachen (Programming Languages)

Programmiersprachen (Programming Languages) 2016-05-13 Preface Programmiersprachen (Programming Languages) coordinates: lecturer: web: usable for: requirements: No. 185.208, VU, 3 ECTS Franz Puntigam http://www.complang.tuwien.ac.at/franz/ps.html

More information

...something useful to do with the JVM.

...something useful to do with the JVM. Scala Finally... ...something useful to do with the JVM. Image source: http://www.tripadvisor.com/locationphotos-g187789-lazio.html Young Developed in 2003 by Martin Odersky at EPFL Martin also brought

More information

Com S 541. Programming Languages I

Com S 541. Programming Languages I Programming Languages I Lecturer: TA: Markus Lumpe Department of Computer Science 113 Atanasoff Hall http://www.cs.iastate.edu/~lumpe/coms541.html TR 12:40-2, W 5 Pramod Bhanu Rama Rao Office hours: TR

More information

CSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN

CSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN What languages do you know? CSC 326H1F, Programming Languages The usual suspects: C, C++, Java fine languages nearly the same Perhaps you've also learned some others? assembler Basic, Visual Basic, Turing,

More information