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:

https://github.com/ajlopez/ScalaSharp

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:

https://github.com/ajlopez/ScalaSharp/tree/master/Src/ScalaSharp.Core/Ast

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

https://github.com/ajlopez/ScalaSharp/tree/master/Src/ScalaSharp.Core/Commands
https://github.com/ajlopez/ScalaSharp/tree/master/Src/ScalaSharp.Core/Expressions

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
http://www.ajlopez.com
http://twitter.com/ajlopez

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)
            this.writer.WriteLine(value);

        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:

[TestMethod]
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]);
            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

http://www.ajlopez.com

http://twitter.com/ajlopez

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

https://github.com/ajlopez/Mass/blob/master/Src/Mass.Core.Tests/MachineFiles/Local.ms

# file variable
a = 1

define foo()
    a = 2 # local variable
end

foo()

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:

https://github.com/ajlopez/Mass/blob/master/Src/Mass.Core.Tests/MachineFiles/Scope.ms

# file variable
a = 1

define foo()
   a # access file variable
end

foo()

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

http://www.ajlopez.com

http://twitter.com/ajlopez

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
http://www.ajlopez.com
http://twitter.com/ajlopez

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
https://github.com/gravel-st/gravel
Smalltalk in Java

http://www.rowledge.org/resources/tim’s-Home-page/Squeak/RTOSinSmalltalk.html.pdf
http://www.rowledge.org/resources/tim’s-Home-page/Squeak/RTOSinSmalltalk.html.pdf

SmalltalkInspect
http://smalltalkinspect.podspot.de/post/024-en-smalltalk-under-the-pi-an-interview-with-tim-rowledge/

tim’s Home page
http://www.rowledge.org/tim/

Oral History of Adele Goldberg – YouTube
http://www.youtube.com/watch?v=IGNiH85PLVg

ALTO-Smalltalk-72
http://lively-web.org/users/Dan/ALTO-Smalltalk-72.html

hhzl (Hannes Hirzel)
https://github.com/hhzl?tab=repositories

Lively Kernel – Home
http://www.lively-kernel.org/

Viewpoints Research Institute
http://vpri.org/index.html

Welcome to Self — Self – the power of simplicity
http://selflanguage.org/

Fast and Dynamic
http://www.infoq.com/presentations/dynamic-performance

Jon’s Place: Roz & RobotsConf
http://blog.huv.com/2013/11/roz-robotsconf.html

rmod.lille.inria.fr/archives/papers/Poli13a-IWST13-ObjectSpacesVirtualization.pdf
http://rmod.lille.inria.fr/archives/papers/Poli13a-IWST13-ObjectSpacesVirtualization.pdf

Smalltalk intro i
http://www.slideshare.net/garduino1/smalltalk-intro-i

Smalltalks13 pharo techoverview
http://www.slideshare.net/pharoproject/smalltalks13-pharo-techoverview

Smalltalks 2007 to 2012 History – YouTube
http://www.youtube.com/watch?v=fSjugDrjUpw

norvig.com/design-patterns/design-patterns.pdf
http://norvig.com/design-patterns/design-patterns.pdf

SqueakSource de l’Ecole des Mines de Douai
http://car.mines-douai.fr/squeaksource/@DYCJfebGRHRMSKdm/eRqLNQqo

Seed: Pharo Kernels
http://www.youtube.com/watch?v=kfSCGYUAv4s

Germán Arduino: Finalizó Smalltalks2013
http://germanarduino.blogspot.com.ar/2013/11/finalizo-smalltalks2013.html

Smalltalks2013 – a set on Flickr
http://www.flickr.com/photos/garduino/sets/72157637139811735/

nativeboost – Squeak NativeBoost plugin source code – Google Project Hosting
https://code.google.com/p/nativeboost/

My Links
http://delicious.com/ajlopez/smalltalk

Stay tuned!

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

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
http://www.ajlopez.com
http://twitter.com/ajlopez

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 http://atechnologyjobisnoexcuse.com/2012/04/coffees-for-coders/

Keep tuned!

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

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
http://www.ajlopez.com
http://twitter.com/ajlopez

March 5, 2014

End Of Iteration 2014w09

Previous Post
Next Post

More interesting stuff for my neuron, and deliberate TDD (Test-Driven Development) practice.

Annalisa

A lot of new work at

https://github.com/ajlopez/Annalisa

It takes an string and extract information based on rules. For example, it can detect the brand of a product description, its weight, weight unit, etc. I put an online demo in Spanish for analyze or search into Preciosa project data:

http://preciosaannalisa.herokuapp.com/

DictSharp

I started a simple in-process, in-memory key/value store in C#:

https://github.com/ajlopez/DictSharp

A dictionary with a an internal tree, instead of using hashes. I should complete the node split operation, enumerate the keys, and compress the keys. A key is an string, and the associated value could be typed or a generic object.

SimpleGeoLoc

Motivated by a use case of Preciosa project, I wrote:

https://github.com/ajlopez/SimpleGeoLoc

A simple JavaScript module to manage a list of geolocated items (via latitude, longitude), and then retrieve the items near a point in a given radius.

OStore

I refactored my in-memory repository:

https://github.com/ajlopez/OStore

to support optional autonumeric ids, and tests using SimpleUnit. Notably, I found an issue: SimpleUnit can be installed as global module in NPM (Node Package Manager) but the bin file has a shebang (!#) in the first line, ending with \r\n (carriage return line feed). Then, Linux operating system take the shebang, and use it as the name of the program to execute the script, WITH THE CARRIAGE RETURN in the name. So, I fixed it removing the carriage return. Weird thing in the third millenium. I updated

https://github.com/ajlopez/AjGenesisNode
https://github.com/ajlopez/SimpleUnit

to have no carriage return in bin scripts.

Others

I worked on two non-public projects, using C#. I started my Python samples https://github.com/ajlopez/PythonSamples. I added some nodes to AST (Abstract Syntax Tree) in https://github.com/ajlopez/ScalaSharp.

More fun is coming.

Keep tuned!

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

January 23, 2014

Erlang: Links, News And Resources (6)

Previous Post
Next Post

Elixir – A modern approach to programming for the Erlang VM on Vimeo
http://vimeo.com/53221562

15 Erlang – Distributed Programs – Node Creation – YouTube
http://www.youtube.com/watch?v=UZ93akCarck

JLOUIS Ramblings: Acme as an editor
http://jlouisramblings.blogspot.co.uk/2013/04/acme-as-editor_20.html

Erlang/OTP at EE: journey and lessons learned – Erlang User Group (London, England) – Meetup
http://www.meetup.com/erlangusergroup/events/116722662/

Erlang Factory – Dublin Erlang Factory Lite 2013 – Register
https://www.erlang-factory.com/conference/Dublin2013/register

Aprendiendo Erlang: Comunicación entre procesos (Ping-Pong).
http://aprendiendo-erlang.blogspot.com.ar/2011/06/comunicacion-entre-procesos-ping-pong.html

Erlang — Concurrent Programming
http://www.erlang.org/doc/getting_started/conc_prog.html

extend/bullet · GitHub
https://github.com/extend/bullet
Bullet is a Cowboy handler and associated Javascript library for maintaining a persistent connection between a client and a server.

duomark/erlangsp · GitHub
https://github.com/duomark/erlangsp
Erlang Services Platform

Erlang the movie II the sequel
http://www.gar1t.com/blog/2013/03/21/erlang-the-movie-ii-the-sequel/

Erlang-style Supervisor Module for Scala Actors ←
http://jonasboner.com/2008/06/16/erlang-style-supervisor-module-for-scala-actors/

Open Telecom Platform – Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/Open_Telecom_Platform

What They Don’t Teach You About Running a Business When Taking Your CS Degree
http://www.infoq.com/presentations/Business-Lessons-Cesarini

Parsing packets Erlang style using core.logic
http://tgk.github.com/2013/02/parsing-packets-erlang-style-using-core-logic.html

ErlangDC 2013 Conference
http://erlangdc.com/

jacobgroundwater/federation · GitHub
https://github.com/jacobgroundwater/federation
Node.js. Federation is inspired by Akka and Erlang, and borrows some semantics from the actor model.

Federation by jacobgroundwater
http://underflow.ca/federation/
Federation is a federated message network for distributed environments

Programming Rules
http://www.erlang.se/doc/programming_rules.shtml

[erlang-questions] hobbyists, erlang, elixir (was Improve $handle_undefined_function)
http://erlang.org/pipermail/erlang-questions/2013-January/071949.html

Merge branch ‘bjorn/remove-parameterized-modules/OTP-10616′ · 35adf88 · erlang/otp
https://github.com/erlang/otp/commit/35adf88290339ecdbbcd0a1290032d599bda26c4#commitcomment-2459599

Persisting your entities in erlang
http://marcelog.github.com/articles/erlang_persistence_entities.html

My Links
http://delicious.com/ajlopez/erlang

Keep tuned!

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

« Newer PostsOlder Posts »

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

Follow

Get every new post delivered to your Inbox.

Join 69 other followers