Angel \”Java\” Lopez on Blog

July 17, 2014

ScalaSharp Simple Scala In C# (1) The Idea

Filed under: .NET, C Sharp, Open Source Projects, Programming Languages, Scala, ScalaSharp — ajlopez @ 6:32 pm

I wrote something in this blog, but it’s time to introduce it to society. Last year a few months ago, I started the project:

A simple interpreter for a simplified Scala, C #. I do not intend to implement all Scala as a compiler for CLR. NET. My intention is to explore an alternative implementation of interpreter, adopting only some “light” features of Scala.

Without being a Scala programmer (or amateur or professional) my impression is that Scala as a language and library, is something like "too much", a bit overwhelming. People adopts Scala because it is more flexible, less need "boilerplate" etc.. But it seems like Scala went too far. Having programmed in Java and C#, I think the latter, adding a few things (delegates years, lambdas, extension methods, "generics" in the VM, and recently, in asynchronous input/output, async, await), has managed to stay healthy, without major complications. See how easy it has been to implement LINQ with evaluation "lazy" and others.

Instead, Scala seems to me like it’s too many things, all together. From what I saw, type inference is a feature that is not so necessary in the real projects. And yet I can not accept that the list of operators in Scala occupies more than one web page. But hey, that’s the current state of things. People Scala is working on a new implementation, called Dotty. But if you are just doing after years of language definition, I have to declare: "too little, too late."

That does not preclude recognizing that Scala has great triumphs, non-trivial applications like Play Framework and Akka. Akka is a very interesting project. I think we don’t need so many new language features (just the ones I mentioned for C #). We need more libraries that solve some issues (such as the implementation of an asynchronous HTTP message distribution server or distributed processing among actors).

To experiment with a simplified Scala, and to deliberately practice TDD (Test-Driven Development) in C #, I started the project ScalaSharp.

It is a challenge for me, because it is not a simple interpreter. I want to implement an AST (Abstract Syntax Tree) that detects inconsistencies between types. In my previous experiences, as RubySharp, PythonSharp, and Mass language, it was only necessary to assemble a tree expressions / commands and evaluate it. Now I’ll have to check that the types are correct. For example, one variable that is typed, and that their assignments, the expression to be evaluated and assigned for the type of the variable. You can see some of the work in progress:

where there is a node tree with types, versus commands and expressions to be executed and evalauted:

Upcoming topics: implementation details, control types in the AST transformation commands / expressions. The good thing to do with TDD is that it allows me to go implemented the solution as I define use cases.

Stay tuned!

Angel “Java” Lopez

July 16, 2014

RubySharp, implementing Ruby in C# (3)

Filed under: .NET, C Sharp, Open Source Projects, Programming Languages, Ruby, RubySharp — ajlopez @ 4:43 pm

Previous Post

In RubySharp, we can define new functions (methods of the current object), and invoke them. There are some built-in functions in C#:

Every function should implement the interface:

public interface IFunction
    object Apply(DynamicObject self, Context context, IList<object> values);

On apply, each function receives the object (self), the context for variables (locals, arguments, closure….), and a list of already evaluated arguments.

An example, the implemention of puts:

public class PutsFunction : IFunction
    private TextWriter writer;

    public PutsFunction(TextWriter writer)
        this.writer = writer;

    public object Apply(DynamicObject self, Context context, IList<object> values)
        foreach (var value in values)

        return null;

It receives the object to which it is a method, the context, and a list of arguments. Each of the arguments was evaluated. The implementation simply sends the arguments to a TextWriter, one argument per line. The TextWriter is provided when the function object is created (in the Machine object, that represents the current running environment). This injected facilites the test of the function, example:

public void PutsTwoIntegers()
    StringWriter writer = new StringWriter();
    PutsFunction function = new PutsFunction(writer);

    Assert.IsNull(function.Apply(null, null, new object[] { 123, 456 }));

    Assert.AreEqual("123\r\n456\r\n", writer.ToString());

The above code was born using the TDD workflow.

Let’s see another built-in function, require:

public class RequireFunction : IFunction
    private Machine machine;

    public RequireFunction(Machine machine)
        this.machine = machine;

    public object Apply(DynamicObject self, Context context, IList<object> values)
        string filename = (string)values[0];
        return this.machine.RequireFile(filename);

This time, the job of loading a file is delegated to the Machin object, injected in the constructor.

And finally, let’s review the code of a defined function (defined in RubySharp):

public class DefinedFunction : IFunction
    private IExpression body;
    private IList<string> parameters;
    private Context context;

    public DefinedFunction(IExpression body, IList<string> parameters, Context context)
        this.body = body;
        this.context = context;
        this.parameters = parameters;

    public object Apply(DynamicObject self, Context context, IList<object> values)
        Context newcontext = new Context(self, this.context);

        int k = 0;
        int cv = values.Count;

        foreach (var parameter in this.parameters) 
            newcontext.SetLocalValue(parameter, values[k]);

        return this.body.Evaluate(newcontext);

In this case, a new contexts is built, containing the new arguments to the defined function, but with the original closure, injected in the constructor. The context provided in the Apply is not used.

Next topics: some command implementations, the Machine object, the REPL, etc…

Stay tuned!

Angel “Java” Lopez

July 15, 2014

Meteor: Links And Resources (2)

Filed under: Links, Meteor, NodeJs, Web Development — ajlopez @ 1:54 pm

Previous Post


Meteor – YouTube

An Introduction to Meteor | Stephen Walther



javascript – Questions Meteor about changing view and putting array in collection – Stack Overflow

Run Meteor Apps Anywhere with Demeteorizer

Hosting a Meteor App on Nodejitsu | Proper

Setting Up Tests w/ Meteor | Proper

Simple Routing in Meteor | Proper


javascript – How do I create multi-page applications with Meteor? – Stack Overflow

Advanced Routing in Meteor: Navigation State w/ Handlebars Helpers and Route Functions | Proper

meteor – How to install atmosphere packages without meteorite? – Stack Overflow

python – How do I access Meteor’s mongodb from another client, while meteor is running? – Stack Overflow

My Links

Stay tuned!

Angel “Java” Lopez

July 14, 2014

Node.Js: Links, News And Resources (23)

Filed under: JavaScript, Links, NodeJs — ajlopez @ 7:27 pm

Previous Post
Next Post

More links from my collection. More updated links at

V8 javascript VM and Node.js memory management options | O sNAp

meetup-api is an API library written in JavaScript for Node.js

Synchronizing HTML5 Slides with Nodejs – Bocoup

Kinect in Node

Chrome Apps Office Hours: NodeJS in Chrome packaged apps – YouTube

Express.js by Dan Zajdband – Comunidad Nodejs Argentina – YouTube

Empezando con node.js « Working Software

Smith is an RPC agent system for Node.JS used in vfs

SenchaCon 2010: Server-side JavaScript with Node, Connect & Express on Vimeo

RFC-6455 WebSocket implementation for Node.js

message-oriented socket library for node.js heavily inspired by zeromq


Android framework for node.js applications

Creating a REST API using Node.js, Express, and MongoDB

.:ceiboo:. – software development

This is the client for Engine, the implementation of transport-based cross-browser/cross-device bi-directional communication layer for Socket.IO.

Run HTTP over UDP with Node.js for P2P and Peer Web

A generic static site generator built using flatiron, plates, and marked

Node based static site generators – Boris Mann

PageDown – pagedown – A JavaScript Markdown converter and editor – Google Project Hosting

Micro Templates Are Dead… forget about – scaling node.js applications one callback at a time.

My Links

Stay tuned!

Angel “Java” Lopez

July 13, 2014

SharpBus in C# (1) First Steps

Filed under: .NET, C Sharp, Open Source Projects, SharpBus, Test-Driven Development — ajlopez @ 11:54 am

Last month I started to write SharpBus, a simple message processor inspired by ideas from Mule Java project. See:

As usual, I’m using TDD (Test-Driven Development), implementing small use cases and API consumption, in the simplest possible way. In fact, the project is a personal exercise of TDD. I hope that some may be useful beyond that. For now, it is an example that I want to share my workflow.

You can see the progress in:

The main ideas to implement are:

- There are Messages containing Payloads and Properties (dictionary of name / value)

- There Flows that process messages

- A Flow is composed of several elements

The elements can be chained in the flow, and can be:

- A Transformer, taking a payload or complete message, and returns a transformed version

- A Processor, taking a payload or complete message, operate on them, maybe accessing the business domain, but without transformation

- Input, a payload/message producer

- Output, a payload/message consumer, at the end od the Flow process

- A Rourter, given a payload/message, it decides with Branch to follow in the Flow. Each Branch is identified by a name.

There will also be items that can issue new posts than the current, and can issue them to different flows in the system. The message producers should be able to run threads (Threads) in principle. And there will be a set of threads (Pool of Threads) attending the incoming messages and deriving them to the respective flows.

A flow can take a message and return a response (Request / Response), or it can take a message, process it without returning an answer.

Some items need complete Message and other items operate over the Payload.

The elements in the world of Mule / Java are objects. Notably, in C #, the simplest way to implement is using lambdas. So, following TDD, the early testing and deployment has come out that way. You can see in some simple tests:

As an example of send a Payload and receive an answer, using an empty Flow:

var flow = Flow.Create();

Assert.AreEqual(1, flow.Send(1));

To send a payload and transform it:

var flow = Flow.Create()
    .Transform(x => ((int)x) + 1);

Assert.AreEqual(2, flow.Send(1));

The .Transform Transform expects a Func<object, object> which may be provided at the time with a lambda. In a classic Java 7 Mule, we should provide an object that implements an interface having a method to transform the Payload. I have to think whether it is worth having a typed Transform <T> (receiving T and returns T), or Transform <T, S> (receiving and returns T S).

I decided to build the flow by code. In the Mule environment Spring is used to set up the flow using XML. I think it is time to explore this other way, build the flow by code, and put it as the "first way", ie, as the way on which everything else could be mounted. If anyone ever needed a DSL (Domain-Specific Language) for creating flows could be implemented this way by having well designed code.

Following TDD, I still have not a case of using a Message (a complete message with content (Payload) and properties (Properties, a name / value) dictionary. All of the above is to process Payload directly.

Upcoming topics: add Message Payload with the output of messages, routing, assembling branches, etc. ..

Stay tuned!

Angel “Java” Lopez

July 12, 2014

Mass Programming Language (5) Variables Scope

Filed under: .NET, C Sharp, Mass, Open Source Projects, Programming Languages — ajlopez @ 6:18 pm

Previos Post

I finally started a new implementation of variables and their scope in programming language Mass. My idea is:

- Have local variables

- No need to explicitly declare

- Access available "outside" if necessary

The basic idea is:

- Any variable assignment involves the local level

That is, if I assign

a = 3

in a function, this refers to a local variable in the function. No matter if there is a variable external to the function

See for example

# file variable
a = 1

define foo()
    a = 2 # local variable


The first variable a is a variable of the file in process (the module). The variable assigned in the foo function is local to that function, and it is different from the outside variable.

But if we do not assign the variable, and only consulted it, its value is returned. example:

# file variable
a = 1

define foo()
   a # access file variable


In this case, the function foo returns the value to "outside", since this variable has not been assigned in the function when evaluating the return value.

How to edit an "external” variable, that is, a non-local variablel? Well, this is a topic for an upcoming post. The idea: to access the value of a non-local variable, it must be implied, without declaring anything extra. BUT modifying its value must should be explicit: we put something to explicitly declare "we are changing the value of a non-local variable".

Stay tuned!

Angel “Java” Lopez

Node.Js: Links, News And Resources (22)

Filed under: JavaScript, Links, NodeJs — ajlopez @ 11:45 am

Previous Post
Next Post

More links from my collection. More updated links at

javascript – Do you know any tutorial for mongoDB in nodeJS? – Stack Overflow

Sample application built with Backbone.js, Twitter Bootstrap, Node.js, Express, MongoDB

Node.js, Express, Stylus, MongoDB example

Node.js module for grafting a middleware pipeline over a target function

NodeJS html parser npm package using the parser library from the netsurf web browser — it’s fast and accurate

OData query string parser for node.js

theLIFT – A Digital Innovation Group

Express.js by Dan Zajdband – Comunidad Nodejs Argentina – YouTube

Websockets y Node.js en las nubes – MedellínJS (Medellín) – Meetup

NPM shrinkwrap
Lock down dependency versions

Class Diagram of Node.js
This shows the class structure of Node.js at a glance. This covers most of classes in the node manual but has a few exceptions

Bifocals by Dashron
A node.js View library with support for asynchronous sub-views (aka partials) and interchangeable rendering systems.

Node.js, Express, Mongoose demo

Node.js & WebSocket – Simple chat tutorial

Node.js Application using

url routing – Organize routes in Node.js – Stack Overflow

node.js – Using routes in Express-js – Stack Overflow

Node.js: A Todo App with Express | Blog :: The JavaScript Playground

Express.js Tutorial

Creating a basic site with node.js and Express – shapeshed

Getting Started with Express – How To Node – NodeJS

Seattle Node.js (Seattle, WA) – Meetup

Episode 12 – Isaac Schlueter –
The man behind NPM and now the newly annointed leader of Node.js, Isaac Schlueter, stops by for a quick chat.

How to Write Portable Node.js Code – Node.js on Windows Azure

Salesforce API Connection Library for Node.js Applications

My Links

Stay tuned!

Angel “Java” Lopez

GrammGen In C# (2) First Rules

Filed under: .NET, C Sharp, GrammGen, Open Source Projects — ajlopez @ 10:30 am

Previous Post

Let’s see today how a parser is built with GrammGen using code. The idea is to define using GrammGen how to build a tree with expressions detected in the text under process. The text is written in the programming language that we want to implement. The expression tree is created using the GrammGen definition, given by code.

I presented in the previous post for an example of a console program, which employs GrammGen. A parser is defined using rules. The rules indicate:

- How to process text characters
- How then form text elements, such as numbers, names, operators
- How to go from putting together such elements, expressions, commands that define our language to implement.

In the sample of calculator

the rules are defined by the parser:

The first rules:

private static Rule[] rules = new Rule[]
   Rule.Or(' ', '\t', '\r', '\n').Skip(),
   Rule.Or('+', '-').Generate("Oper0"),
   Rule.Or('*', '/').Generate("Oper1"),
// ...

The idea is to get an Expression. The first rule defines that anyone (Rule.Or) of space, tab, carriage return, new line items are ignored (. Skip ()). You can put more than one rule of this type, for example, to set comments to be ignored from the input text.

The second rule defines both + (the plus sign) and – (minus sign) produce a called terminal Oper0. They differ from * (the token) and / (divide sign) because we want to take precedence among operators.

There is a rule to construct integers:


Rule.Get("0-9").OneOrMore().Generate("Integer", MakeIntegerConstantExpression), 

The Rule.Get allows you to specify a range of characters, and then, with the fluent interface defined, you can attach the .OneOrMore () method, which specifies that the rule can be applied once or several times. When you can not apply more, it ends generating a node called "Integer". But in GrammGen a node, in addition to a name, may have an associated object. Al. A second parameter can be passed to Generate method, with a function that creates the associated object.

MakeIntegerConstantExpression job is:

- Get the object that was formed with the rule, in this case, a concatenated string with all digits were found.

- Transform it to integer

- Create a ConstantExpression with the intever as constant value.

The class ConstantExpression is not from GrammGen. It is defined by us. We have the freedom to define the objects we want to attach to each node of the GrammGen generated tree.

The code of MakeIntegerConstantExpression is:

   private static object MakeIntegerConstantExpression(object obj)
       int value = int.Parse((string)obj);

       return new ConstantExpression(value);

In the next posts we will see how the nodes of binary operations are formed, how operator precedence is implemented, how to manage left recursion, and evaluation of the generated expressions.

Stay tuned!

Angel “Java” Lopez

July 11, 2014

Erlang: Links, News And Resources (12)

Filed under: Distributed Computing, Erlang, Functional Programming, Links — ajlopez @ 8:26 pm

Previous Post

AKKA 5 Year Anniversary

erlang-laboratory – Erlang Laboratory — Erlang development in Windows as simple as 1, 2, 3 – Google Project Hosting

Michael Feathers – Microservices and the Failure of Encapsulation

(390) Python (programming language): With the increase of the processors speeds, will high level languages (like python) take over low level languages (like C/C ) since difference in execution speed will not differ that much? – Quora

Damien Katz: What Sucks About Erlang


Why Erlang Is Awesome

Erlang Integers | Programmer’s Paradox

Handling very large integers in Erlang | Teton Technical


inaka/erlang_training · GitHub

inaka/spawnedshelter · GitHub


My Links

Stay tuned!

Angel “Java” Lopez

Play Framework: Links and Resources (1)

Filed under: Java, Links, Play Framework, Scala, Web Development — ajlopez @ 1:56 pm

Play is an open source web application framework, written in Scala and Java, which follows the model–view–controller (MVC)architectural pattern. It aims to optimize developer productivity by using convention over configuration, hot code reloading and display of errors in the browser.[1]

Support for the Scala programming language has been available since version 1.1 of the framework.[2] In version 2.0, the framework core was rewritten in Scala. Build and deployment was migrated to SBT, and templates use Scala instead of Groovy.

Advanced routing in Play Framework – all that jazz

Christopher Hunt on Software Development: Play-ing with WebJars

JsZipper : Play2 Json advanced (& monadic) manipulations – Mandubian Blog

huntc/play-spring · GitHub
A sample Play application with the minimum configuration required to support Spring JSR-299 and JSR-330

guillaumebort/play20-spring-demo · GitHub
Using Spring from within a Play 2.0 application

Stupid Java Tricks » Play Framework 2.1: The Bloom is Off The Rose

Observations on the Play! framework | James Gregory’s Blog

#98 Support for optional trailing slash – Play framework 2.0 – play

Abnorm: A better non-ORM // Speaker Deck

Play CMS
A simple CMS to be able to edit pages, page fragments and images using a WYSIWYG editor

parroit76-play-cms – port of play-cms to version 2.0 of play framework – Google Project Hosting

julienrf/play-scala.g8 · GitHub
g8 template for Play applications

What startups or tech companies are using Play Framework? – Quora

yobriefca screencast

Introduction to Play Framework

yanns/play2-scala-DI · GitHub
Technical prototyp to test different dependency injection solutions.

Sadek Drobi, the Play 2.0 Story and what’s new in 2.1
CTO of Zenexity, a Web Oriented Architecture Company, Sadek is a software engineer specialized in bridging the gap between the problem domain and the solution domain. As core Play developer and co-creator, he works on the design and implementation of the framework. Twitter: @sadache Photos: Blog:

Iteratees in Big Data at Klout « Klout Engineering
In this blog post we describe the usage of Play! Iteratees in our redesigned data collection pipeline.

My Links

Stay tuned!

Angel “Java” Lopez

« Newer PostsOlder Posts »

The Shocking Blue Green Theme. Create a free website or blog at


Get every new post delivered to your Inbox.

Join 66 other followers