Angel \”Java\” Lopez on Blog

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

July 26, 2014

AjKeyvs Implementing Key-Value Store in C# (1) The Project

Filed under: .NET, AjKeyvs, C Sharp, No, NoSQL, Open Source Projects, Test-Driven Development — ajlopez @ 6:40 pm

I want to implement a key-value store (as Redis) in C#, play with data structures, and practice TDD (Test-Driven Development). I started:

https://github.com/ajlopez/AjKeyvs

The current structure:

There is a class library project, AjKeyvs, that contains the collections in an in-memory repository. The interesting part of this projects is to implement arrays and sets that can be sparse, having different keys. Example, having a key 1 (one) and a key 1000000 (one million) does not imply to have an array with one million positions. At the same, I want to have a good access and update time. In other use cases, I will have string keys, like “user”, “user:1”, “user:1:email”, etc. There are use cases that need the use of sets, with union, intersection, difference, etc… For integer keys, I jave a set where a could turn a bit on or off, for the presence or absense of an element. More implementation details in upcoming post.

The library can be used in-process, but I added a server and a client program. The server listen commands sent by the clientes. All collections reside in memory. Persistence is something orthogonal to the implemented use cases. I should decide if add the persistence into the command processing, or is something to be implemented outside the project.

As usual, I followed TDD workflow.

Next topics: data structures, collections, commands, concurrency, etc.

Stay tuned!

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

July 24, 2014

DylanSharp Implementing Dylan in C# (1) The Project

Filed under: .NET, C Sharp, DylanSharp, Functional Programming, Open Source Projects — ajlopez @ 4:30 pm

A few months ago I started to implement an interpreter of Dylan language, to practice TDD in C #, and learn some functional programming. I read:

http://opendylan.org/

Dylan is a multi-paradigm functional and object-oriented programming language. It is dynamic while providing a programming model designed to support efficient machine code generation, including fine-grained control over dynamic and static behaviors.

The interesting thing about Dylan is that it incorporates types and objects. For now I do not intend to generate machine code, but, following "baby steps" to implement the main concepts of language as an interpreter. I would like to add access to the libraries. NET, which I find interesting to extend the reach of language. You can learn more of the language in:

http://opendylan.org/documentation/intro-dylan/index.html

The project I am writing in C # is:

https://github.com/ajlopez/DylanSharp

Its current structure:

It consists of a class library, and a draft tests. So far there are some simple expressions implemented a Parser a Lexer and implemented as a concept of class C # language: List, which lists as implemented in Lisp. As in other projects, I Context to maintain the values ​​of variables, and recall by name. Notably, in Dylan variables have type, but I’m not controlling the types, just evaluating any expressions. I’ll have to decide at some point to control the types at the time of compiling / processing program. According:

http://opendylan.org/documentation/intro-dylan/expressions-variables.html#type-declarations

Type mismatch errors should be caught at compile time.

But the time will come. Advancing TDD, I am confident that if necessary I can make a “surgical” refactor / redesign, without a lot of pain. I could do this in the next iteration or later. I did something similar during the coding of ScalaSharp.

Next steps: continue implemented expressions, definitions of classes, modules, commands, anonymous functions. And control the types.

Stay tuned!

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

July 22, 2014

ClojSharp Implementing Clojure In C# (1) The Project

Since the past decade I’m interested on Clojure. It’s a return to Lisp, but in modern times.. Clojure is implemented on the Java virtual machine, but is also implemented on. NET (AFAIK, using Dynamic Language Runtime). The version of Java compiles to Java bytecodes. There is also a version of JavaScript, called ClojureScript. The community is very active, and has brought an air of renewal within Java. It has features like immutability of his work-oriented structures in multithreading, avoiding concurrency problems. It supports Software Transactional Memory, but has been less used by what I see. Web frameworks have emerged, and has a project and dependencies manager called Leiningen. Some links in my Clojure posts.

To deliberate practice TDD (Test-Driven Development) and C#, I was building an interpreter (not a compiler to bytecodes, yet). The project:

https://github.com/ajlopez/ClojSharp

Current status:

It has a class library project, and a test project. There is also a REPL (Read Eval Print Loop) simple console application.

In Lisp, an expressions is composed by a verb and arguments, written in a list enclosed by parenthesis. For example, a list that at evaluation returns the sum of 1, 2 and 3:

(+ 1 2 3)

Here, the plus + sign is a symbol that in Lisp/Clojure refers to a form. A form receives arguments, operates on them, and returns a result. A typical form receives its arguments as evaluated expressions: the expressions are evaluated BEFORE the evaluation of the form:

(+ 1 (- 3 4) 3)

In the above example, the first argument to plus is a constant 1, and the second argument is an expression that is evaluated to –1 before the evaluation of the outer list.

But there are forms that not need evaluated arguments. They receive the arguments without evaluation. They are called special forms. I have implemented:

And I have implemented some (non special) forms as primitives in C#. Most of them could be implemented in Lisp itself, but being so basic that I preferred to implement them directly in C#, using TDD as usual:

Next topics: the Machine implementation, Context, how to use Parser and Lexer, more about expression evaluation, macros, tail recursion, etc.

Stay tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

July 21, 2014

Aktores Implementing Akka Actor Model in C# (1) The Project

Filed under: .NET, Akka, Aktores, C Sharp, Open Source Projects — ajlopez @ 4:11 pm

It’s time to write about the project:

https://github.com/ajlopez/Aktores

Estoy implementando los primeros pasos hacia un modelo de actores, con pasaje de mensajes, tomando ideas de Akka. Ya había trabajado algo en Node.js, y en C# directo, teniendo actores que se mandan mensajes entre sí, pero esta vez quiero seguir el camino de Akka, paso a paso, como por ejemplo, tener nombres de actores, en un árbol, sistema de actores distribuidos, y la supervisión de agentes.

El estado del proyecto a hoy

I’m implementing the first steps towards an actor model, message passing, taking ideas from Akka. I had worked something in Node.js, and C#, having actors sending messages to each other, but this time I want to follow the path of Akka, step by step, for example, have names of actors, in a tree, distributed system of actors, and monitoring agents.

The status of the project today:

The current actor implementation:

First, an Actor is an abstract class, to be implemented in each use case. The rest of the system would not talk to an actor directly, but through a ActorRef. For example, to send a message, there is a method Tell in ActorRef. Internally, no process sends messages to the actor directly, but each actor has a Mailbox. And the mailbox is used by ActorRef to send a message to the final Actor. The Actor object is a passive object: it not manage the Mailbox directly, but there are threads that will take pending tasks, get message from Actor mailbox, and send it to the Actor. The system internally ensures that the actor receives and processes messages one by one. The actor does not have to worry about competition from multiple threads. Notably, the Actor has no direct reference to the Mailbox. More details in upcoming posts.

Stay tuned!

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

July 20, 2014

AjErl Implementing Erlang in C# (1) The Project

Filed under: .NET, AjErl, C Sharp, Erlang, Functional Programming, Open Source Projects — ajlopez @ 10:49 am

Some time ago, to practice TDD and C # and explore ideas Erlang, I started an Erlang-like interpreter in C#:

https://github.com/ajlopez/AjErl

The solution structure:

It has the core class library, draft tests, project and I am putting together a REPL (Read Eval Print Loop) as console program. The interesting thing is that Erlang internally has lightweight processes, implemented in the virtual machine itself, which can communicate with each other by sending and receiving immutable messages. I do not intend to implement a virtual machine of this type, but have processes in threads. They will never be as fast as Erlang, but it’s a first "baby step" to explore, before trying to improve implementation.

Messages can be sent to a queue per process (thread here), and I have implemented the acceptance of messages, and turn his rejection process, as in native Erlang.

But today I wanted to briefly discuss how to implement transforms input text into Erlang expressions and forms:

:

The Lexer returns tokens, and these tokens have a value and a type. It can already recognize an atom (a name that begins in lower case), a variable, delimiters, operators, integers and real numbers, strings. The Lexer is consumed by a Parser, which has two public methods: one that parses expressions, used from the REPL, and another that parses what Erlang is called a form, would like a function definition in a module of Erlang. There are also ways to declare the name of the module, or other forms exported with name and number of arguments. In these modules will not accept expressions, only statements such form.

If you look at the history of commits, you will see that not everything went ahead, but grew slowly, as small raised me to implement use cases.

Upcoming topics: discuss the implementation of expressions, forms, processes and threads with mailbox for messages, and the REPL. And keep working on the implementation of messages and distributed processes.

Nos leemos!

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

July 19, 2014

SharpGo Implementing Go in C# (1) The Project

Filed under: .NET, C Sharp, Go, Google, Open Source Projects, Programming Languages, SharpGo — ajlopez @ 5:06 pm

There is another project of mine to practice TDD (Test-Driven Development) and C#, at:

https://github.com/ajlopez/SharpGo

It is an interpreter (not a compiler) of Go programming language, written in C#. It has a class library project, and a test project. Go is a typed language, so I cannot follow the path of build an expression tree, and evaluate it, as in RubySharp, PythonSharp and Mass. Instead, the interpreter should have many phases, as in ScalaSharp, to detect type inconsistencies, and use the declaration of unknown types at the parse process.

The AST is implemented:

The AST (Abstract Syntax Tree) nodes are in two groups:

- Command Nodes, where they should generate commands to be executed.

- Expression Nodes, that generates expressions to be evaluated. They have an associated type.

The commands declare variables with types. By now, I have all in place to start:

- Declare the types of some declarations of variables and functions
- Control that types are the right ones, ie, an integer variable should not be assigned to an string expression
- Start to emit commands and expression

As in other projects, I want to add access to native .NET types, libraries and objects. I should research how many features of Go I could implement in this approarch. An example: the implementation of Go structures, and their original semantic in C#. I could implement channels (years ago, I implemented channels in C# and AjSharp).

Stay tuned!

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 66 other followers