Слайд 1What Is JSON-FP
Ben Lue @ COIMOTION
Слайд 2What Is JSON-FP
Programs are expressed as a JSON object in a
functional programming style.
Слайд 3Ok. That sounds like something serious, but what does that really
Слайд 4Introducing JSON-FP
JSON-FP uses a JSON object to describe a computer program.
If
you send a JSON object to JSON-FP to run, you could get a very different object in return.
Слайд 5Let’s Start With Something Simple
var expr = {add: 1} ;
jsonfp.apply(1, expr);
Слайд 6var expr = {add: 1} ;
jsonfp.apply(1, expr);
That’s the same as saying
1 + 1
1 → {add: 1} === (1 + 1)
Now you know a JSON-FP expression is as simple as:
{op: option}
Ex: {add: 1}
Слайд 7JSON-FP allows you to replace ‘option’ with another JSON-FP expression.
That makes
things…
interesting.
Слайд 8Changing
{add: 1}
to
{add: {‘
than 10, add 1 to it.’
Слайд 9Another Example
_.map(list, function(page) {
return _.pick(page, ‘title’);
});
The above code uses
underscore/lodash to remove all but the ‘title’ property from a list of pages.
Слайд 10If Done By JSON-FP…
_.map(list, function(page) {
return _.pick(page, ‘title’);
});
vs
{map: {pick:
‘title’}}
Слайд 11So you may notice the JSON-FP expression can be very concise
and it can help developers to focus on the problem they want to solve.
Слайд 13Properties/features of JSON-FP:
Map/Reduce in the distributed environments.
Functional programming
Homoiconic / metaprogramming
Слайд 14Map/reduce, functional programming and homoiconic…
Those are too heavy stuff for
this introduction. We’ll cover them in the coming slides.
But we can talk a little about map/reduce…
Слайд 15If your application has to query data repositories in a heterogeneous
environment, hadoop/spark is NOT a good fit.
Try JSON-FP, life will be much easier.
Слайд 17Well, JSON-FP is less than a month old. Interesting applications are
coming…
For now, you can check out newsql (https://github.com/benlue/newsql) which uses JSON-FP to query objects.
Our next generation API services uses JSON-FP, too.
Слайд 18That’s it for now.
For more JSON-FP examples, check out:
https://github.com/benlue/jsonfp-examples
The JSON-FP is
open sourced at github:
https://github.com/benlue/jsonfp