Monday, December 19, 2011

What wrong with data today ?

In modern computing, after the Web 2.0 era, all data in the Internet is growing beyond the limit of imagination's some computer scientist in 60 years ago.
Some limit of  von Neumann's model, the classical database, or even Turing theory, that make our time, the computing can not go further the current mind.
I still thinking what is the better model of computation, how we can store the semantics of data, how we think and treat the data (just bit 1 or 0) as the soul inside. 
Like us, the human being, can have both  sense, soul and mind with matter, body.
I think we think the data can have a sense , a context (time, place, and some attributes) that make our data become a true entity, that exists in the World.


Functor, a simple function object that have both its data and the computation, make our computing more abstract way.

Saturday, December 17, 2011

Functor in Practice


The graph of functors in categories {money, knowledge,happiness}
Imagine when all these things going to computing, 

Active Functor Introduction

In http://en.wikipedia.org/wiki/Functor
http://ncatlab.org/nlab/show/experimental+alternative+definition+of+functor
We can have a definition "functor"  in Mathematics
In category theory, a branch of mathematics, a functor is a special type of mapping between categories. Functors can be thought of as homomorphisms between categories, ormorphisms when in the category of small categories.


Definition

Let C and D be categories. A functor F from C to D is a mapping that[3]
  • associates to each object X \in C an object F(X) \in D,
  • associates to each morphism f:X\rightarrow Y \in C a morphism F(f):F(X) \rightarrow F(Y) \in D such that the following two conditions hold:
    • F(\mathrm{id}_{X}) = \mathrm{id}_{F(X)}\,\! for every object X \in C
    • F(g \circ f) = F(g) \circ F(f) for all morphisms f:X \rightarrow Y\,\! and g:Y\rightarrow Z.\,\!
That is, functors must preserve identity morphisms and composition of morphisms.

Functor in Computer Science 

function object, also called a functorfunctional, or functionoid,[1] is a computer programming construct allowing an object to be invoked or called as though it were an ordinaryfunction, usually with the same syntax.

Description

A typical use of a function object is in writing callback functions. A callback in procedural languages, such as C, may be performed by using function pointers. However it can be difficult or awkward to pass a state into or out of the callback function. This restriction also inhibits more dynamic behavior of the function. A function object solves those problems since the function is really a façade for a full object, thus it carries its own state.
Many modern languages (and some older) e.g. C++LispPerlPHPPythonRuby, and many others, support first-class function objects and may even make significant use of them.Functional programming languages additionally support closures, i.e. first-class functions which can 'close over' variables in their surrounding environment at creation time. During compilation, a transformation known as lambda lifting converts the closures into function objects.

In Java http://userpages.umbc.edu/~tarr/dp/lectures/Command-2pp.pdf

List<String> list = Arrays.asList("10", "1", "20", "11", "21", "12"); 
Comparator<String> numStringComparator = new Comparator<String>() {
    public int compare(String o1, String o2) {
        return Integer.valueOf(o1).compareTo(Integer.valueOf(o2));
    }
}; 
Collections.sort(list, numStringComparator);


In JavaScript:
E.g: First-class functor
var A = function(){ this.message = "hello"; };
var B = function(f) {  this.sayHi = function(){ console.log(f.message); }; }
var a = new A();
var b = new B(a);
b.sayHi();

Functor return functor with closure:

function Accumulator(start) {
  var current = start;
  return function (x) {
    current += x;
    return current;
  };
}
var a = Accumulator(4);
var x = a(5); //x has value 9
x = a(2);     //x has value 11

In Programming, we can think a functor is a function that can be manipulated as an object, or an object representing a single, generic function. Functors support and encourage a number of powerful programming techniques including:
  • programming in a functional style
  • higher order functions
  • internal iterators
  • reuse and specialization through composition rather than inheritance and overloading
  • generic "callback" or "extension point" APIs
  • generic "filters" or predicate APIs
  • many "behavioral" design patterns, such as Visitor, Strategy, Chain of Responsibility, etc.

What is an Active Functor?
It's the abstraction of how a computer program can create, pass, call and receive a functor (the definition and model to create instances) in real-time


It's, functor can be think as a simple agent can receive data, processing and return a value.
The "Active" mean a functor can be pulled/pushed to executing environment, like a web browser, Virtual Machine, ...

Currently, I will implement and introduce this power abstraction in web browser, and with popular tools like browser, JavaScript, Java VM. This can be implemented and put it into practice.

We know, Android, Java Virtual Machine, web browser, and the Cloud Computing, they already for us. 
It's time to think we can make a true "Intelligent Social Cloud Computing".
A functor can be created by everyone in web browser, can travel from PC to Smartphone, or can be stored in the cloud storage.

Before going to the more higher level like http://activeinfograph.blogspot.com/ , that a program with anonymous functor running.
I think this could a functor framework can be easily implemented. And then with the AI and Machine Learning techniques, an active agent can  go into practice.



http://brownsharpie.courtneygibbons.org/?cat=51