46
Functional Programming in Java: Why and How? Dr. Stephen Bloch Math/CS Dept. Adelphi University

Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

  • Upload
    others

  • View
    14

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Functional Programming in Java: Why and How?

Dr. Stephen Bloch Math/CS Dept.

Adelphi University

Page 2: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Outline

•  Functional & imperative programming •  Why functional programming? •  Our experiment in CS1 •  Java 1.8 (coming March 2014)

15 Aug 2013 LI Java Users' Group

Page 3: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Imperative

•  “What output & side effects do I want to cause?”

•  “What do I do, in what order, to cause those effects?”

•  Typical sequence of topics: •  I/O •  assignment •  sequence •  function calls •  conditionals •  loops •  function definitions •  recursion

Functional

•  “What’s the right answer?”

•  “What algebraic expression yields the right answer?”

•  Typical sequence of topics: •  function calls •  function definitions •  conditionals •  recursion •  I/O •  sequence •  assignment •  loops

15 Aug 2013 LI Java Users' Group

Page 4: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

15 Aug 2013

Functional Imperative Mental model Algebraic substitution:

3+4*5 => 3+20 => 23 von Neumann machine: Store into & retrieve from boxes

Writing tests

f(5,3) == rightAnswer

setFoo(5); setBar(3); setOther(-4); doF(); getResult().equals(rightAnswer) && getOther() == -4 // hasn’t changed

Changing tests Can comment out or re-order tests without changing results

Each test affects results of subsequent tests

Debugging What is the value of this variable? What is the value of this variable at this time?

Habits Separate I/O and computation; short, reusable, single-purpose functions

Long methods that mix I/O and computation, doing several different jobs

LI Java Users' Group

Page 5: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Functional & imperative programming

•  Functional closer to math •  Imperative closer to hardware •  Either can be augmented with OO features •  OO helps in organizing big programs •  CS1 students aren't writing big programs,

so OO is largely unmotivated

15 Aug 2013 LI Java Users' Group

Page 6: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Why functional programming?

•  Math concepts & abstraction •  Test-driven development •  Debugging •  Good habits •  Parallelism •  FP is "right" for many problems •  Event-driven GUI programming

15 Aug 2013 LI Java Users' Group

Page 7: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

FP and math

•  Success in algebra predicts success in programming.

•  "Function" is a notoriously difficult concept in algebra (more abstract than arithmetic operations or variables)

•  FP makes it concrete (especially combined with graphics)

15 Aug 2013 LI Java Users' Group

Page 8: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

FP and testing •  Test-driven development helps beginners as

much as professionals, if there's a beginner-friendly API

•  Tests for functional code don't need to worry about preconditions & postconditions, only arguments and return values.

•  Tests for functional code can be inserted, deleted, reordered without changing results

15 Aug 2013 LI Java Users' Group

Page 9: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

FP and debugging •  Imagine a debugger that, on crashing, allowed you

to single-step backwards to find where things went wrong. Impossible, of course…

•  An FP-aware IDE can do that.

•  Debugging is simpler when you don't need to ask "what's the value of this variable at this time"

•  "Assignment leads to mutation. Mutation leads to pointers [and aliasing]. Pointers lead to suffering!" — Anton van Straaten

15 Aug 2013 LI Java Users' Group

Page 10: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

FP and abstraction Write the same expression over and over –> invent constants

Write lots of similar code fragments, differing in a value –> invent variables, and methods with parameters

Write lots of classes with similar methods, differing in values –> invent polymorphism & inheritance

Write lots of methods/classes differing in what other class they refer to –> invent generics

Write lots of methods/classes differing in what other method they refer to –> invent higher-order functions

15 Aug 2013 LI Java Users' Group

Page 11: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

FP and habits of programming

FP-trained programmers tend to produce a lot of short, single-purpose functions that can be combined and re-used in different ways

FP-trained programmers look for opportunities to avoid duplicate code by parameterizing

Good practice even outside FP 15 Aug 2013 LI Java Users' Group

Page 12: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

FP and parallelism

•  The bane of a parallel programmer's life is mutation of shared state, leading to race conditions.

•  Functional code doesn't mutate variables, so it doesn't matter which processor accesses the variable first.

•  Functional code is much easier to parallelize than imperative code.

15 Aug 2013 LI Java Users' Group

Page 13: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

"naturally functional" problems

•  In 2006, I gave my CS1 students the "power-set" and "permutations" problems – Almost everyone got them working using a

functional data structure – Nobody got them working using Java's built-in

Collection classes, whose API's depend on mutation

•  Wall Street analysts have decided FP is the natural way to analyze large financial data sets

15 Aug 2013 LI Java Users' Group

Page 14: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

FP and event-driven programming

We often need to manipulate handlers at run-time (install, uninstall, modify, create on the fly…) An event handler is a function; it would be nice to be able to manipulate functions at run-time.

Model/view separation: source of lots of GUI bugs, difficult concept for GUI students. Our functional API enforces model/view separation 15 Aug 2013 LI Java Users' Group

Page 15: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

FP and event-driven programming

"No matter what language you work in, programming in a functional style provides benefits. You should do it whenever it is convenient, and you should think hard about the decision when it isn't convenient." — John Carmack

15 Aug 2013 LI Java Users' Group

Page 16: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

"Functional languages"

•  FP traditionally means Lisp, Scheme, Haskell …

•  More recently, Clojure, Scala, F# •  Can be done in almost any language

(although some make it easier) •  Overlap between Java & Scheme design

teams (hence automatic garbage collection, immutable Strings, anonymous inner classes, etc.)

•  Java 1.8 will make FP easier 15 Aug 2013 LI Java Users' Group

Page 17: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Our experiment in CS1

•  Background •  What we did •  Example: functional graphics •  Example: testing in Tester •  Example: animation in JavaLib •  Results

15 Aug 2013 LI Java Users' Group

Page 18: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Our experiment: background •  I teach "programming for non-majors",

functionally, with lots of graphics & animation, in Schemelike student language

•  My textbook: Picturing Programs •  5/2012: Agreement to try this in CS1 Spring

2013, team-taught by Bloch & Stemkoski •  10/2012: Agreement changed to require Java •  12/2012: frantically porting libraries to Java •  1/2013: class started

15 Aug 2013 LI Java Users' Group

Page 19: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Our experiment: topics •  Week 1: functional graphics •  Week 2: test-driven development •  Week 3: model/view separation & event-

driven GUI programing •  Week 5: conditionals •  Week 6: user-defined data classes •  Week 7: polymorphism & inheritance •  Week 8: lists & recursion •  Weeks 9-11: recursion on Strings, naturals,

input •  Week 12: loops 15 Aug 2013 LI Java Users' Group

Page 20: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Example: functional graphics SampleImages.family.show();

SampleImages.bloch.yReflected().show();

SampleImages.bloch.beside(SampleImages.bloch.xReflected()).show();

15 Aug 2013 LI Java Users' Group

Page 21: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Example: functional graphics Student work at http://picturingprograms.org/gallery

(Truth In Linking Disclaimer: those pictures were actually built by CS0 students in Scheme, but they could have been built by CS1 students in Java — the graphics library is almost the same.)

15 Aug 2013 LI Java Users' Group

Page 22: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Example: functional graphics static WorldImage counterChange

(WorldImage pic1, WorldImage pic2) { WorldImage row1 = pic1.beside(pic2); WorldImage row2 = pic2.beside(pic1); return row1.above(row2); }

15 Aug 2013 LI Java Users' Group

Page 23: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Example: test-driven development

class Posn {

int x, y; Posn (int x, int y) { this.x = x; this.y = y; } int getX() { return this.x; } int getY() { return this.y; } Posn flip () {return new Posn(this.y, this.x); }

}

Question: How do we test this?

15 Aug 2013 LI Java Users' Group

Page 24: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Example: testing in JUnit public void testStuff () { Posn example = new Posn(3, 5); assertEquals (example.getX(), 3); assertEquals (example.flip(), new Posn(5, 3)); // fails! assertEquals (example.getY(), 5); // doesn't even try! }

15 Aug 2013 LI Java Users' Group

Page 25: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Example: testing in Tester public void testStuff (Tester t)

{ Posn example = new Posn(3, 5); t.checkExpect (example.getX(), 3); t.checkExpect (example.flip(), new Posn(5, 3)); // passes! t.checkExpect (example.getY(), 5); // runs regardless of previous test results }

15 Aug 2013 LI Java Users' Group

Page 26: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Model/View Separation •  Predominant approach to GUI programming •  "Model code" updates model in response to events; does

no graphics •  "View code" looks at current model & updates display to

match •  When model code updates display directly, get display

glitches (something changes on screen, but changes back at next redraw)

•  When view code modifies model, get timing dependencies (model depends on kind of display & number of refreshes)

15 Aug 2013 LI Java Users' Group

Page 27: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Our GUI API

15 Aug 2013 LI Java Users' Group

Model View

String Posn

gotKeyEvent

gotMouseClicked

gotTick makeImage

Page 28: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Our GUI API •  Students explicitly identify the type of the Model •  Students write a Model -> Image method makeImage •  Students may write a Model -> Model method gotTick •  Students may write a Model String -> Model method

gotKeyEvent •  Students may write Model Posn -> Model methods

gotMouseClicked, gotMousePressed, gotMouseDragged, etc.

•  No drawing primitives —> model code cannot affect display!

•  Only way to change "current model" is to return it —> view code cannot modify model!

15 Aug 2013 LI Java Users' Group

Page 29: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Code example public class Spinner extends Animation<Integer> {

WorldImage background = AImage.makeFromURL("http://blah.blah/blah.jpg");

public Spinner(Integer initial) { super(initial); }

public WorldImage makeImage (Integer current) { return background.overlayCentered (SampleImages.fish.rotatedInPlace(current)); } public Integer gotTick(Integer current) { return current + 5; // rotate 5 degrees per clock tick } public static void run() { new Spinner(0).bigBang(0.05); /* tick every 0.05

second */ } }

15 Aug 2013 LI Java Users' Group

Page 30: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Results of the Experiment •  Drop, withdraw, & failure rates similar to recent

semesters •  Enthusiasm high; 12/32 students expressed interest in

CS2 (which we're not offering this fall due to insufficient faculty!)

•  Assessment test (written by another professor) –  students did well on questions about writing methods, poorly on

questions about mutation & ArrayLists. –  large variance on question involving recursion/iteration –  no control group yet, so we don't know how this compared with

"traditional" imperative CS1 course •  Final exam (written by Bloch & Stemkoski)

–  students did well on questions about process for writing methods –  large variance on question involving recursion/iteration 15 Aug 2013 LI Java Users' Group

Page 31: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Results of the Experiment •  Having no textbook wasn't as problematic as we

expected (who knows whether students would have read it anyway?)

•  Last-minute development of libraries mostly worked, with one update release in mid-semester

•  Colleague worried about using generics in CS1; in fact, it wasn't an issue at all

•  Student code 2-3 times longer and more complex than it would have been in Scheme, but they don't know that

15 Aug 2013 LI Java Users' Group

Page 32: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Java 1.8

•  Functional interfaces •  Lambda notation •  Methods as values •  Higher-order functions •  other stuff I'm not interested in today

15 Aug 2013 LI Java Users' Group

Page 33: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Java 1.8 A "functional interface" is any interface that declares exactly one abstract method.

Existing examples: Appendable, Comparable, Iterable, Runnable, ActionListener, Observer, Painter, …

Idea: if there's only one method, you don't really need to specify its name.

15 Aug 2013 LI Java Users' Group

Page 34: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Installing a Swing event handler In current Java:

myButton.addActionListener ( new ActionListener() { void actionPerformed (ActionEvent e) { /* do something with e */ }});

In Java 1.8:

myButton.addActionListener ( e -> /* do something with e */ ); 15 Aug 2013 LI Java Users' Group

Page 35: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

New utility functional interfaces Function<Domain,Range> Predicate<Domain> // equivalent to Function<Domain,Boolean> Consumer<Domain> Supplier<Range> BinaryOperator<T>

So why are these useful?

15 Aug 2013 LI Java Users' Group

Page 36: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Counting In Java before 1.5:

int count = 0; for (int which = 0; which < strings.length; ++which)

{ if (strings.get(which).startsWith("F")) ++count; }

// Looping over "all the things in a collection" is really common. // Let's automate it.

15 Aug 2013 LI Java Users' Group

Page 37: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Counting In Java 1.5-1.7:

int count = 0; for (String s: strings) {

if (s.startsWith("F")) ++count; }

// Counting how many things in a collection have a particular // property is really common. Let's automate it.

15 Aug 2013 LI Java Users' Group

Page 38: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Counting In Java 1.8:

int count = strings.stream().count(s -> s.startsWith("F"));

which is short for

int count = strings.stream().count(new Predicate<String> () {

boolean test(String s) { return s.startsWith("F"); }});

// count is a higher-order function 15 Aug 2013 LI Java Users' Group

Page 39: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Counting If you wanted to count how many of the strings were empty, you could write

int count = strings.stream().count(s -> s.isEmpty());

or just refer to isEmpty by name:

int count = strings.stream().count(String::isEmpty)

15 Aug 2013 LI Java Users' Group

Page 40: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Filtering Similarly,

Stream<Employee> highPaid = employees.stream().filter(e -> e.getSalary() > 100000);

// filter is also a higher-order function

15 Aug 2013 LI Java Users' Group

Page 41: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

What's this "stream" thing? The built-in methods count, filter, findFirst, foreach, map, max, min, reduce, sorted, etc. work on a new type: Stream.

strings.stream() converts an existing Collection<String> to a Stream<String>.

Streams can be sequential or parallel, and can be infinitely long; most of the operations on them are lazy, and don't insist on the previous step in the computation being finished before they get started.

Why is this useful? 15 Aug 2013 LI Java Users' Group

Page 42: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Lazy evaluation Example of "lazy evaluation":

Stream<Integer> primes = Stream.generate(myPrimeGenerator); int answer = primes.map(p -> p*p*p).findFirst(n -> n > 1000000);

finds the first prime-cube larger than 1000000.

Yes, there are infinitely many primes, so it would take infinitely long to cube them all, but we don't need to cube them all; we only need to cube them until we find a cube larger than 100000.

15 Aug 2013 LI Java Users' Group

Page 43: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Operations on functions Suppose you want to sort a list of Person objects by last name, resolving ties by first name, and resolving further ties by SSN. Several solutions at present: •  write your own sort that at each step looks at last name,

then first name, then SSN •  write a Comparator that looks at last name, then first

name, then SSN; call Collections.sort(people, new LFSComparator())

•  write several Comparators that look at last name, first name, and SSN respectively; call Collections.sort(people, new SSNComparator()); Collections.sort(people, new FirstNameComparator()); Collections.sort(people, new LastNameComparator());

15 Aug 2013 LI Java Users' Group

Page 44: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

Functions producing functions In Java 1.8, you can say people.sort (Comparator.comparing(Person::getLastName)

.thenComparing(Person::getFirstName) .thenComparing(Person::getSSN))

which really expresses directly what we're trying to do, without lots of extra syntax.

Note that Comparator.comparing takes in a function and builds a Comparator that uses the "natural order" on the result of that function. Comparator.thenComparing operates on a Comparator, takes in a function, and builds a Comparator that uses the "natural order" on the function's result to resolve ties in the existing Comparator. 15 Aug 2013 LI Java Users' Group

Page 45: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

That's all, folks! •  Functional programming is a powerful way to look at problem-

solving, with pedagogical and practical advantages over imperative programming

•  For problems that lend themselves to FP, a functional solution is frequently much shorter, simpler, and clearer than an imperative solution — as well as easier to test, debug, and parallelize.

•  FP is traditionally done in "functional languages", but it can be done in Java too

•  FP in Java will become much easier in a few months with the release of Java 1.8

15 Aug 2013 LI Java Users' Group

Page 46: Functional Programming in Java - Goliardsgoliards.us/adelphi/papers/FJIEWAH.pdf · 2014-01-09 · "Functional languages" • FP traditionally means Lisp, Scheme, Haskell … • More

For further reading •  My textbook, Picturing Programs: http://picturingprograms.org

•  Carmack, J. "In-depth: Functional Programming in C++", http://gamasutra.com/view/news/169296/ Indepth_Functional_programming_in_C.php

•  Tester library by Viera Proulx, http://www.ccs.neu.edu/javalib/Tester/ (inspired by DrRacket's check-expect form)

•  Graphics & animation library: original version by Viera Proulx, http://www.ccs.neu.edu/javalib/World/ (inspired by DrRacket's 2htdp/image and 2htdp/universe libraries)

•  Graphics & animation library: my expanded version, https://github.com/sbloch/JavaLibWorld

•  On Java 1.8: http://www.techempower.com/blog/2013/03/26/everything-about-java-8/

15 Aug 2013 LI Java Users' Group