User:Devon McCormick/FunctionalJ

From J Wiki
Jump to: navigation, search

Introduction

NYFPMeetup-TalkAnnouncement.png

J: A Dynamic, Functional Language

J is a radically innovative, dynamic, functional, interpreted, interactive, array-based, multi-platform, open-source, mind-blowing notation that also happens to be implemented as a powerful, productivity-enhancing programming language.

NYFPMeetupAppJ01.jpg

The Entire J Language

The entire language fits on one page.

J7Vocab1Pg.png

What is notation and why should we care?

NYFPMeetupAppJ04-onlyWhatIsNotation.jpg

Chunking – another reason notation is important

By grouping concepts and subsuming them into “chunks”, we overcome the limitations of short-term memory. A notation is often an effective way to do this. Another technique for accomplishing this is the development of a specialized vocabulary.

An example of a technical term which encapsulates a lot of meaning into a short phrase is “Hello, World” example. Keep an eye out for this example in the following expositions in which we demonstrate various features of J. We’ll start by learning some specialized J terms.

J Terms: noun, verb, monadic, dyadic, boxed

NYFPMeetupAppJ05.jpg

…Cognitive Tidbit

NYFPMeetupAppJ06.jpg

Resuming… (Definition of "Boxed")

NYFPMeetupAppJ07.jpg

Arrays

NYFPMeetupAppJ08.jpg

NYFPMeetupAppJ09.jpg

NYFPMeetupAppJ10.jpg

Precedence – Order of Operations

NYFPMeetupAppJ11.jpg

J Terms: adverb, conjunction

Calling them higher-order functions just isn't good enough - we need to be able to talk about them precisely.

NYFPMeetupAppJ12.jpg

…Cognitive Tidbit : Great Big Numbers

Someone else appreciating the power of notation.

NYFPMeetupAppJ13.jpg

NYFPMeetupAppJ14-noRepeat.jpg

Resuming… (Definition of "Conjunction")

NYFPMeetupAppJ15.jpg

NYFPMeetupAppJ16.jpg

J Terms: hook, fork

NYFPMeetupAppJ17.jpg

NYFPMeetupAppJ18.jpg

J Term: rank

NYFPMeetupAppJ19.jpg

(the last two) J Terms: explicit, tacit

NYFPMeetupAppJ20.jpg

Converting Between Explicit and Tacit: a Crutch "13 : "

NYFPMeetupAppJ21.jpg

Summary of J Terms

NYFPMeetupAppJ22.jpg

Example of a User-defined Adverb: a Newton Solver

NYFPMeetupAppJ23.jpg

NYFPMeetupAppJ24.jpg

Functional Programming: Procedural Contrasted with Array-based

Paul Hudak, one of the early promoters of functional programming in general and Haskell in particular, wrote a paper titled "Conception, Evolution, and Application of Functional Programming Languages" (ACM Computing Surveys, Vol. 21, No. 3, September 1989) in which he mentions APL as one of the early functional languages. However, he says little about it other than giving it as an example of a functional language that doesn't rely on lambda expressions.

He also notes how it differs from other functional programming languages like Backus's FP because "...FP's fundamental data structure is the sequence, whereas APL's is the array." However, he seems unaware of how significant this is which is understandable given the traditional blind spot of Computer Science toward the importance and utility of array notation.

Since one example is worth a hundred abstract definitions, we'll look at how a procedural - or sequence-based - implementation of an algorithm might differ from an array-based one by implementing the same simulation in the two different fashions.

Procedural Simulation of "Red or Black" Game

NYFPMeetupAppJ25-RorB.jpg

NYFPMeetupAppJ26-RorB.jpg

Array-based Simulation of "Red or Black" Game

NYFPMeetupAppJ27-RorB.jpg

NYFPMeetupAppJ28-RorB-end.jpg

J’s Numeric Tower

Though J has only three types - numeric, character, and boxed - there are numerous different kinds of numbers. The character type also supports Unicode as well as single-byte characters. The "tower" here builds from a base of the simplest to the (arguably) most complex numeric sub-types supported by J.

complex               2j32 186j413 3798j94357 627j3 1440j6
floating point       2.3218 641.3379 89.4357 62731.44060134
extended integer    232186413379894357 627314406013472791111
rational           23r218641 3r37 989r4357 627r314 40r601 3r4
integer           2321 86 4133798 94357 6273 1440 601 34 72 79
boolean          0 1 0 1 0 0 0 1 1 1 1 1 0 1 0 1 1 1 0 0 1 1 1 0

There are a few other numeric notations within J not shown here, including notations for numbers based on pi and on radians.

J Resources

Join the J Forums (mailing lists) –

  • programming - the main forum, covering J programming from beginner to expert, and announcements
  • beta - current beta (bugs, problems, suggestions)
  • chat - all other discussions on computer languages and J - messages welcomed from both J and non-J programmers
  • general - installation, support, website and other infrastructure topics
  • source - J engine source

The J Meetup - http://www.meetup.com/J-Dynamic-Functional-Programming, also http://www.jsoftware.com/jwiki/NYCJUG

J Software - http://www.jsoftware.com/

J Wiki - http://www.jsoftware.com/jwiki/FrontPage

Notation as a Tool of Thought - http://www.jsoftware.com/papers/tot.htm

The Joy of Functional Calculation - http://archive.vector.org.uk/art10500630

Bowling scores in J and other languages - http://xprogramming.com/articles/dbcbowlingvector/

Criticisms of J for beginners - http://www.jsoftware.com/jwiki/JforBeginnersCriticisms

Functional programming example - Simplex method - http://www.jsoftware.com/jwiki/Stories/RichardBrown

Fractals, Visualization and J by Cliff Reiter - available on Lulu.com

Cliff's animated Sierpinski pyramid - http://webbox.lafayette.edu/~reiterc/misc_frac/swaa.html

Cliff's gallery of fractals - http://webbox.lafayette.edu/~reiterc/gallery_wfrac.html

Complete gallery - http://webbox.lafayette.edu/~reiterc/gallery.html

Vector magazine of the British APL Association - https://sites.google.com/site/baavector/home

J in a Day - http://www.jsoftware.com/jwiki/IanClark/JinaDay

Oleg's J page - http://olegykj.sourceforge.net/

Books on J - http://www.jsoftware.com/jwiki/Books

This presentation - http://www.jsoftware.com/jwiki/DevonMcCormick/FunctionalJ

Attachments

Here's the handout for the talk.

File:JFunctionalMeetupIntro.pdf

Here's an example I added at the end of the talk - it contrasts an example of functional programming in a more conventional, procedural style against an array-based version which looks and performs considerably better.

File:The Red or Black Game Simulated Functionally by both procedure and array.pdf

Here are the slides from my PowerPoint presentation...

NYFPMeetup-TalkAnnouncement.png

NYFPMeetupAppJ01.jpg

NYFPMeetupAppJ02.jpg

NYFPMeetupAppJ03.jpg

NYFPMeetupAppJ04.jpg

NYFPMeetupAppJ05.jpg

NYFPMeetupAppJ06.jpg

NYFPMeetupAppJ07.jpg

NYFPMeetupAppJ08.jpg

NYFPMeetupAppJ09.jpg

NYFPMeetupAppJ10.jpg

NYFPMeetupAppJ11.jpg

NYFPMeetupAppJ12.jpg

NYFPMeetupAppJ13.jpg

NYFPMeetupAppJ14.jpg

NYFPMeetupAppJ15.jpg

NYFPMeetupAppJ16.jpg

NYFPMeetupAppJ17.jpg

NYFPMeetupAppJ18.jpg

NYFPMeetupAppJ19.jpg

NYFPMeetupAppJ20.jpg

NYFPMeetupAppJ21.jpg

NYFPMeetupAppJ22.jpg

NYFPMeetupAppJ23.jpg

NYFPMeetupAppJ24.jpg

NYFPMeetupAppJ25-RorB.jpg

NYFPMeetupAppJ26-RorB.jpg

NYFPMeetupAppJ27-RorB.jpg

NYFPMeetupAppJ28-RorB.jpg

NYFPMeetupAppJ29.jpg