Angel \”Java\” Lopez on Blog

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:

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

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:

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

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 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

July 8, 2014

New Month’s Resolutions: July 2014

Filed under: C Sharp, JavaScript, NodeJs, Open Source Projects, Programming Languages — ajlopez @ 4:50 pm

A new month started, time to review my June 2014 resolutions, and write new ones:

– Continue AjErl [pending]
– Continue ScalaSharp [complete] repo 
– Continue SharpGo [complete] repo
– Variable scope in Mass Language [complete] repo
– Start SimpleItems [pending]
– Continue SimpleApps [partial] repo
– Continue ClojSharp [pending]
– Continue DictSharp [pending]
– First AjErl distributed use case [pending]
– First Aktores distributed use case [pending]
– Write C# Posts [complete] Spanish Posts
– Write TDD Post [complete] Spanish post
– Improve my personal site code [complete]

Additionally, I worked on:

– Create and publish first version SimpleCurry, functional programming helpers in JavaScript [complete]  repo
– Create and publish first version LoadJsons, load JSON model from many files, in JavaScript/Node [complete]  repo
– Create a Dynamic Site in Express 4, defined by JSON [complete]  repo
– Generate Express 4 code using AjGenesisNode [complete]  repo
– Generate Sinatra code using AjGenesisNode [complete]  repo
– Improve AjGenesisNode, AjGenesisNode-Model, AjGenesisNode-Entity [complete]  repo repo repo
– Continue DylanSharp [complete]  repo
– Create SharpBus, Mule-like simple bus in C# [complete]  repo

These are my resolutions for July 2014:

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

More fun is coming.

Stay tuned!

Angel “Java” Lopez

July 4, 2014

Smalltalk: Links, News And Resources (18)

Filed under: Links, Programming Languages, Smalltalk — ajlopez @ 10:04 pm

Previous Post 
Next Post

gravel-st/gravel · GitHub
Smalltalk in Java’s-Home-page/Squeak/RTOSinSmalltalk.html.pdf’s-Home-page/Squeak/RTOSinSmalltalk.html.pdf


tim’s Home page

Oral History of Adele Goldberg – YouTube


hhzl (Hannes Hirzel)

Lively Kernel – Home

Viewpoints Research Institute

Welcome to Self — Self – the power of simplicity

Fast and Dynamic

Jon’s Place: Roz & RobotsConf

Smalltalk intro i

Smalltalks13 pharo techoverview

Smalltalks 2007 to 2012 History – YouTube

SqueakSource de l’Ecole des Mines de Douai

Seed: Pharo Kernels

Germán Arduino: Finalizó Smalltalks2013

Smalltalks2013 – a set on Flickr

nativeboost – Squeak NativeBoost plugin source code – Google Project Hosting

My Links

Stay tuned!

Angel “Java” Lopez

May 9, 2014

New Month’s Resolutions: May 2014

Time to review my April 2014 resolutions:

– Continue AjLispScala [pending]
– Continue AjGenesisNode-Express [partial] see repo
– Continue AjGenesisNode-PHP [pending]
– Continue RuScript [pending]
– Continue RustScript [complete] see repo
– Distributed Messages in AjErl [partial] see repo
– Give a talk Intro to Node.js [complete] see repo see online talk
– Publish a new Node.js video tutorial [complete] see post

Additionally, I worked on:

– Start SharpGo interpreter [complete] see repo
– Start SimpleNeuron in JavaScript [complete] see repo
– Refactor, extend and publish new version of SimpleFlow [complete] see repo
– Improve SimpleScraper [complete] see repo
– Improve ClojSharp [complete] see repo
– Improve Aktores [complete] see repo

The resolutions for the new month, May 2014:

– Work on SimpleScraper, first use cases
– Continue RuScript
– Continue RustScript
– Continue SharpGo
– Continue Distributed Messages in AjErl
– Improve Mass Language
– Continue Aktores (first distributed features)

More fun is coming!

Keep tuned!

Angel “Java” Lopez

April 5, 2014

Always Be Coding

Filed under: Open Source Projects, Programming Languages, Software Development — ajlopez @ 10:49 am

As a professional software developer, we should pursue to be better programmers. One activity I adopted some years ago, is: "Always Be Coding”. Every day, write a piece of code. Try something new. Improve something old. Open your brain. Explore a new path. Learn a new language. Practice TDD every day. Push for simplicity. Start a simple project “Hello world” using new technology or operating system. Write a simple web site using the new web framework in the block. If you write C# or Java, try Ruby or Clojure. If you use Ruby on Rails, try Sinatra, or make a switch to Python and Django. If you like Lisp, try ClojureScript for a web project. If you like Smalltalk, try Pharo and Seaside. If you are a programming language geek, go for Rust, Go, Dart. If you write ASP.NET MVC for a living, try SignalR, then Node.js and Socket.IO. Change your editor. Change your programming language. Or write your own.

Even if all these languages, technologies, libraries, and frameworks are not in your “daily work”, the new insights are welcome. And the constant practice makes the master. If you keep the brain open, new ideas could fertilize your mind and your skill toolbox. In our profession, the change is the only constant. Altought there are other things to practice, “soft” skills, teamwork, you (and me) should be trained every day.

So, to put my money where my mouth is, every day I write a piece of code, in public and non-public projects. Partial evidence:

That’s is my public commitment: to write code every day. To learn something new, to practice an skill, to explore a new way of doing things. Always be coding

More fun is coming.

Original photo from

Keep tuned!

Angel “Java” Lopez

April 3, 2014

New Month’s Resolutions: April 2014

Review of my March’s resolutions:

– Work on DictSharp [complete] see repo
– Give talk about Node.js Distributed Applications [complete] see repo see online slides
– Improve SimpleGammon [complete] see repo
– Improve Annalisa [complete] see repo
– Add @for to Templie [pending]
– Work on PreciosaAnnalisa online web services [complete] see repo
– Improve my Node.js Distributes Applications samples [complete] see repo see repo see repo
– Work on ScalaSharp [complete] see repo
– Improve ClojSharp [complete] see repo
– Improve SimpleAsync, do operation (functions in parallel) [pending]
– Improve Aktores [pending]
– Distributed messages in AjErl [pending]
– Add variable scope to Mass language [pending]
– Start code generation as a service [partial]

Additionally, I worked on:

– Complexo, simple complex numbers operations in JavaScript [complete] see repo
– Started RustScript, a Rust programming language interpreter in JavaScript [complete] see repo
– Continue RuScript, a Ruby interpreter in JavaScript [complete] see repo
– Continue RubySharp, a Ruby interpreter in C# [complete] see repo
– Started AjLispScala, a Lisp interpreter in Scala, using TDD and SBT [complete] see repo
– Recorded a second video Node.js Spanish tutorial [complete] see post

For this new month, my resolutions are:

– Continue AjLispScala
– Continue AjGenesisNode-Express
– Continue AjGenesisNode-PHP
– Continue RuScript
– Continue RustScript
– Distributed Messages in AjErl
– Give a talk Intro to Node.js
– Publish a new Node.js video tutorial

More fun is coming.

Keep 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 70 other followers