Angel \”Java\” Lopez on Blog

January 2, 2015

New Month’s Resolutions: January 2015

A new year begins. Time to review past month’s resolutions:

– Add distributed features to AjErl, Erlang-like interpreter in C# [partial] see repo
– Improve ClojSharp [complete] see repo
– Improve SimpleLisp [complete] see repo
– Code generation with AjGenesis for Node [pending]
– Start Basic Script Language for C# [complete] see repo

Additionally, I was working on:

– Improve ScalaSharp [complete] see repo
– First operations in Chip8 emulator [complete] see repo
– Write Clojure samples (Ring, Compojure) [complete] see repo
– Work on Liqueed project [complete] see repo
– Improve AjScript [complete] see repo

This new month’s resolutions:

– Continue add distributed features to AjErl, Erlang-like interpreter in C#
– Improve ClojSharp
– Improve ScalaSharp
– Improve Chip8 emulator
– Code generation with AjGenesis for Node
– Improve Basic Script Language for C#
– Write JavaScript and Artificial Intelligence posts

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

December 14, 2014

Aktores: Implementing Actor Model In C# (2) A Simple Sample

Filed under: .NET, Akka, Aktores, C Sharp, Open Source Projects — ajlopez @ 8:18 am

Previous Post

Let’s review a simple sample that creates two actors, and sends messages to them. The code is at:

https://github.com/ajlopez/Aktores/tree/master/Samples/PingPong

As usual, this is “work in progress”, and could be change in the future. I’m following TDD (Test-Driven Development) workflow, so some API calls could be change when I add new use cases (as distributed samples).

In this solution, we have an actor:

using Aktores.Core;

public class PingActor : Actor
{
    private int messagecount;

    public int MessageCount { get { return this.messagecount; } }

    public override void Receive(object message)
    {
        messagecount++;
        this.Sender.Tell("ping", this.Self);
    }
}

An actor inherits from abtract class Actor. The method to implement is Receive. This method receives a message (sent by other actor, or by other object in the system). Internally, Aktores sends only one message to our instance, we don’t worry about concurrency. The above actor, when receives a message, increments a counters and sends another message to the original sender. This sender is referenced by this.Sender, DURING the process of THIS message. This property can change in the process of another message.

We have another similar actor:

using Aktores.Core;

public class PongActor : Actor
{
    private int messagecount;

    public int MessageCount { get { return this.messagecount; } }

    public override void Receive(object message)
    {
        messagecount++;
        this.Sender.Tell("pong", this.Self);
    }
}

The main program creates an actor systems, creates two actor instances, one of type Ping and the other of type Pong, and sends to them many message to process:

public static void Main(string[] args)
{
    ActorSystem system = new ActorSystem(2);
    var pingactor = new PingActor();
    var pongactor = new PongActor();
    
    var ping = system.ActorOf(pingactor);
    var pong = system.ActorOf(pongactor);

    for (int k = 0; k < 10; k++)
    {
        ping.Tell("pong", pong);
        pong.Tell("ping", ping);
    }

    // ....
}

There is additional code to show the message counters. The parameter 2 in the constructor of ActorSystem indicates the number of internal threads to use to process message. I should review if such info should be specified here. Two threads are enough becase we have only two actor instances, but we could have more actors.

Stay tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

December 4, 2014

New Month’s Resolutions: December 2014

It’s time to review past month’s resolutions:

– Give a talk about JavaScript and Artificial Intelligence [complete] see repo see talk read Spanish post
– Neural network in JavaScript example [complete] see repo
– Genetic Algorithms in JavaScript example [complete] see repo
– More Code Generation using AjGenesis for NodeJs [pending]
– Basic Script Language for C# [pending]
– Improve SimpleScript for JavaScript [complete] see repo

Also, I was working on:

– Improve SimpleLisp, Lisp to JavaScript compiler [complete] see repo
– Improve RuScript, Ruby interpreter in JavaScript [complete] see repo
– Improve RustScript, Rust-like interpreter in JavaScript [complete] see repo
– Create SimpleDT, simple decision tree in JavaScript [complete] see repo
– Improve ClojSharp, Clojure-like interpreter in C# [complete] see repo
– Backgammon evaluation page [complete] see repo

This new month’s resolutions:

– Add distributed features to AjElr, Erlang-like interpreter in C#
– Improve ClojSharp
– Improve SimpleLisp
– Code generation with AjGenesis for Node
– Start Basic Script Language for C#

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

November 4, 2014

New Month’s Resolutions: November 2014

Filed under: .NET, AjTalk, Aktores, C Sharp, JavaScript, NodeJs, Open Source Projects — ajlopez @ 5:25 pm

Time to review past month’s resolutions:

– Give a talk Aktores intro [complete] see repo see presentation
– Distributed AjErl [pending]
– More Express samples in AjTalkJs [complete] see repo
– Explore neural networks in JavaScript [complete] see repo
– Explore genetic algorithms in JavaScript [partial] see repo
– Explore other artificial intelligence topics in JavaScript [partial]
– More Distributed Aktores [pending]
– Start Distributed Smalltalk in AjTalkJs [complete] see repo

My new month’s resolutions:

– Give a talk about JavaScript and Artificial Intelligence
– Neural network in JavaScript example
– Genetic Algorithms in JavaScript example
– More Code Generation using AjGenesis for NodeJs
– Basic Script Language for C#
– Improve SimpleScript for JavaScript

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

October 7, 2014

New Month’s Resolutions: October 2014

Filed under: .NET, C Sharp, JavaScript, NodeJs, Open Source Projects — ajlopez @ 5:50 pm

Time to write my technical new month’s resolutions. But first, review of past month’s ones:

– Distributed Aktores [complete] see repo
– Distributed AjErl [pending]
– Web support and example for RuScript [partial] see repo
– Complete Mochy [partial] see repo
– Improve RSharp [complete] see repo
– Work with NodeJs on Deep Learning, Internet of Things, Artificial Intelligence [pending]
– Work on Code Generation using AjGenesis for Node [complete] see main repo see Express repo see Sinatra repo see Laravel repo
– Work on Liqueed Project [complete] see repo

Additional, I worked on

– Improve AjScript [complete] see repo
– Refactor BasicScript tests to use SimpleUnit [complete] see repo
– Create SimpleColls, simple collection functions in JavaScript, alone or a la Linq [complete] see repo
– Refactor SimpleStore tests to use SimpleUnit [complete] see repo
– Improve AjTalkJs, Smalltalk in JavaScript, support for super, Express 4 first sample [complete] see repo
– Refactor MProc tests to use SimpleUnit [complete] see repo
– Refactor AjLogoJs tests to use SimpleUnit [complete] see repo
– Refactor SimpleKeeper tests to use SimpleUnit [complete] see repo
– Refactor SimpleTags tests to use SimpleUnit [complete] see repo
– Improve SimpleUnit, publish new version [complete] see repo
– Refactor SimplePipes tests to use SimpleUnit, and publish new version [complete] see repo

My new month’s resolutions:

– Give a talk Aktores intro
– Distributed AjErl
– More Express samples in AjTalkJs
– Explore neural networks in JavaScript
– Explore genetic algorithms in JavaScript
– Explore other artificial intelligence topics in JavaScript
– More Distributed Aktores
– Start Distributed Smalltalk in AjTalkJs

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

September 13, 2014

New Month’s Resolutions: September 2014

Filed under: .NET, C Sharp, JavaScript, NodeJs, Open Source Projects — ajlopez @ 5:34 pm

A bit late, time to review my August’s Resolutions:

– Write jQuery mock to be used in console tests/Node.js [complete] see repo
– Write simple functions in JavaScript for array manipulation [complete] see repo
– Continue with Liqueed project [complete] see repo
– Start with Distributed Aktores [partial] see repo
– Startwith Distributed AjErl [pending]

Additionally, I worked on:

– Give an intro talk about Express [complete] see repo see presentation see samples
– Improve AjScript [complete] see repo
– Improve RuScript, Ruby interpreter in JavaScript [complete] see repo
– Refactor SimplePipes [complete] see repo
– Generate Node.js/Express server code from RAML [complete] see repo
– Create Dynamic Site from JSON to Express [complete] see repo
– Improve RustScript, Rust interpreter in JavaScript [complete] see repo
– Create Mochy, test framework a la Mocha [complete] see repo
– Create RSharp, R language interpreter in C# [complete] see repo
– Refactor (and simplify) SimpleRules, rule engine in JavaScript [complete] see repo
– First samples for SimpleMule [complete] see repo
– Improve output for SimpleUnit [complete] see repo

My new month’s resolutions:

– Distributed Aktores
– Distributed AjErl
– Web support and example for RuScript
– Complete Mochy
– Improve RSharp
– Work with NodeJs on Deep Learning, Internet of Things, Artificial Intelligence
– Work on Code Generation using AjGenesis for Node
– Work on Liqueed Project

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

August 10, 2014

New Month’s Resolutions: August 2014

Filed under: .NET, C Sharp, JavaScript, Open Source Projects — ajlopez @ 5:59 pm

Time to write new resolutions, and to review July 2014 ones:

– Improve AjGenesisNode code generation for Express [complete] see repo
– Improve AjGenesisNode code generation for Sinatra [partial] see repo
– First AjGenesisNode code generation for Laravel [pending]
– Module loading, export review in Mass Language [pending]
– Continue with SharpBus [complete] see repo
– Continue with Dynamic Site [pending]
– Give a talk about Node.js/Express [complete]
– Improve my personal site code [complete] see repo
– Write TDD Post [pending]
– Write C# Posts [complete] see posts
– Distributed use using Aktores [pending]
– Review, refactor and continue RustScript implementation [complete] see repo

Additionally, I worked on:

– Started SimpleList [complete] see repo
– Started SimpleJQuery [complete] see repo
– Improve SimpleMule [complete] see repo
– Started SharpGD, Graph Database in C# [complete] see repo
– Improve SimpleBus [complete] see repo
– Improve SharpGo [complete] see repo
– Improve ExpressSamples [complete] see repo
– Minor improvements in ScaScript [complete] see repo
– Improve ScalaSharp [complete] see repo
– Write Friends sample for JavaScriptSamples [complete] see repo
– Write Angular examples [complete] see repo
– Add remove method to OStore [complete] see repo
– Collaborate with Liqueed project [complete] see repo

New resolutons for August 2014:

– Write jQuery mock to be used in console tests/Node.js
– Write simple functions in JavaScript for array manipulation
– Continue with Liqueed project
– Start with Distributed Aktores
– Startwith Distributed AjErl

Also, I worked for thread count is 3.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com

July 29, 2014

SharpStorm Implementing Storm in C# (1) Initial Project

Filed under: .NET, C Sharp, Open Source Projects, SharpStorm, Storm — ajlopez @ 12:44 pm

In the last two years I was exploring the ideas of Storm (see https://storm.incubator.apache.org/), implementing a local topology Node.js. It’s time to practice more C # and TDD (Test-Driven Development), with:

https://github.com/ajlopez/SharpStorm

Current status of the project:

The idea is to implement Bolt, Spout and a TopologyBilder. See

https://storm.incubator.apache.org/about/simple-api.html

There are just three abstractions in Storm: spouts, bolts, and topologies. A spout is a source of streams in a computation. Typically a spout reads from a queueing broker such as Kestrel, RabbitMQ, or Kafka, but a spout can also generate its own stream or read from somewhere like the Twitter streaming API. Spout implementations already exist for most queueing systems.

A bolt processes any number of input streams and produces any number of new output streams. Most of the logic of a computation goes into bolts, such as functions, filters, streaming joins, streaming aggregations, talking to databases, and so on.

A topology is a network of spouts and bolts, with each edge in the network representing a bolt subscribing to the output stream of some other spout or bolt. A topology is an arbitrarily complex multi-stage stream computation. Topologies run indefinitely when deployed.

In the project are now defined interfaces, to have bolts and spouts, and topology builder to build a topology. For now, I want a local implementation (without distributed processing). Then, I hope to implement ACK algorithm that has original Storm, which lets you know when an incoming message was completely processed (including processes messages that occurred in the middle of the process).

Upcoming topics: discuss ISpout, iBOLT, and topology implementation.

Stay tuned

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

July 28, 2014

SharpDoop Implementing Map Reduce in C# (1) The Project

Filed under: .NET, C Sharp, MapReduce, Open Source Projects, SharpDoop — ajlopez @ 4:51 pm

I was experimenting with map-reduce in Node.js / JavaScript. But it is also something interesting to implement the algorithm in C #, to practice TDD (Test-Driven Development) and to learn more about what it takes to implement the algorithm. The project that I started is:

https://github.com/ajlopez/SharpDoop

The current status:

It has a class library project and the test project. I came to think of something not yet distributed. All I want for now is to specify the map/reduce algorithm map, and run it in the same process.

See that there is then a MapReduceJob. The base class that is responsible for running a map (lambda function) and reduce (takes a key,  a list of values for that key, and output the result). With C #, these two operations can be expressed as lambdas or delegate methods inside a more complex object. For now, I pose the simple cases in the tests, and all them are running.

I also put together a MapProcessJob, which is a variant of map / reduce to discuss. Instead of processing all keys first, then roll them into the reduce phase, try to do everything together. In some use cases it may be more efficient, but is an issue to discuss in more detail.

Upcoming topics: more in-depth review and implementation ideas, such as map / process.

Stay tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

July 27, 2014

AjTalk Implementing Smalltalk In C# (4) The Project

Filed under: .NET, AjTalk, C Sharp, Programming Languages, Smalltalk — ajlopez @ 5:48 pm

Previous Post

Year and a half since I didn’t write about this project in C #, but I was working on it, and the parallel implementation I have in JavaScript (in fact, I introduced some concepts of both the Smalltalks 2013 conference, Rosario, Argentina).

The project is at:

https://github.com/ajlopez/AjTalk

Current structure:

The projects are:

AjTalk: class library, with a compiler to bytecodes implementation. There is a compiler to JavaScript too. There is an interpreter of those bytecodes.

AjTalk.Compiler: a console project that uses the compiler to JavaScript.

AjTalk.Console: a simple REPL (Read Eval Print Loop)

AjTalk.Gui: a work-in-progress example using windows

AjTalk.Tests: the test I wrote, followin TDD (Test-Driven Development) flow.

I guess now I don’t need the compiler to JavaScript, because I have a native JavaScript implementation at:

https://github.com/ajlopez/AjTalkJs

It can compile to bytecodes or to JavaScript. The project is written in JavaScript.

The window implementation is very primitive. I plan to replace it for direct AjTalk program using .NET types and object.

One point that I find very interesting (in both projects, C # and JavaScript) is to have a modular implementation: instead of loading an image yet defined, my plan is to define modules to load, as happens in the Node.js environment . The modules would be published in the NPM (Node Package Manager’s), and each could indicate which modules need in your program instead of lifting all Smalltalk.

Another topic in this C # project I have implemented that can run more than one AjTalk machine at the same time. And I can even make a machine “help” to the other. For example, if the machine does not have to compile methods to new methods, machine B can go to his aid. Thus, A machine (and his image, I’m already recording binary image) can be kept small.

Another feature that I have implemented: the ability to send a message to an object, without waiting for a response, a “fire and forget”. And that the target object can attend ONE OF those messages as models of actors.

I have to review the implementation of remote objects (now based on the old Remoting. NET). But I think it is an important feature to maintain and explore.

Well, you see, many issues remain for other posts, such as implementation details Smalltalk concepts such as Object, Class, ClassDescription, Behavior, MetaClass, etc..

Nos leemos!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

Older Posts »

The Shocking Blue Green Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 69 other followers