Category Archives: Erlang

New Month’s Resolutions: March 2017

A new month begins, and it’s time to write down my new resolutions. First, a review of the February resolutions:

– Improve SharpGo [complete] see repo
– Improve BlockchainSharp [pending]
– Improve SimpleBlockchain [complete]
– Continue Solidity Compiler [complete] see repo
– Continue ChineseP [pending]
– Improve ErlSharp [complete] see repo

Additionally, I worked on:

– Start RskSharp [complete] see repo
– Start TensorSharp [complete] see repo
– Improve AjDrawJs [complete] see repo
– Improve SimpleForth [complete] see repo
– Improve CrysSharp [complete] see repo
– New Bitcoin example in SimpleGA [complete] see repo
– Improve Husky, my Haskell interpreter [complete] see repo
– Improve SimpleLisp [complete] see repo
– Improve CrysJS [complete] see repo

My new resolutions:

– Continue RskSharp
– Continue SimpleBlockchain
– Continue Solidity Compiler
– Continue ChineseP
– Continue TensorSharp

Stay tuned!

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

Elixir: Links And Resources (3)

Previous Post

Develop fast web apps in Phoenix using pjax
http://rny.io/elixir/phoenix/2015/09/20/pjax-in-phoenix.html

knewter/complex
https://github.com/knewter/complex

Phoenix for Railsies: Form Helpers and Models
http://www.sitepoint.com/phoenix-for-railsies-form-helpers-and-models/

[Elixir] From Functions |> Processes
http://avinasha.com/elixir-from-functions-processes/

Testing callbacks in Elixir – The Pug Automatic
http://thepugautomatic.com/2015/09/testing-callbacks-in-elixir/

A deep dive into the Elixir Ecto library.
http://www.glydergun.com/diving-into-ecto/

Phoenix: Templates Are Just Functions
http://www.jeramysingleton.com/phoenix-templates-are-just-functions/

Sending and receiving email with Elixir
http://reganmian.net/blog/2015/09/03/sending-and-receiving-email-with-elixir/

PostgreSQL indexing with Ecto
http://rny.io/elixir/ecto/postgresql/2015/08/31/postgresql-indexing-with-ecto.html

Building Elixir From Source
http://wsmoak.net/2015/09/08/building-elixir-from-source.html

bryanjos/elixirscript · GitHub
https://github.com/bryanjos/elixirscript

My Links
https://delicious.com/ajlopez/elixir

Stay tuned!

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

Elixir: Links And Resources (2)

Previous Post
Next Post

The Erlangelist: Beyond Task.async
http://www.theerlangelist.com/2015/07/beyond-taskasync.html

Daniel Berkompas – Changing Your Ecto Encryption Key
http://blog.danielberkompas.com/elixir/security/2015/07/09/changing-your-ecto-encryption-key.html

“Ephemeral P2P” Project — Medium
https://medium.com/@losvedir/ephemeral-p2p-project-ff07cbd20261

Michal Muskala – Coding, thoughts, and ideas
http://michal.muskala.eu/2015/08/06/parallel-downloads-in-elixir.html

Elixir configs
http://nhu313.github.io/elixir/2015/07/30/elixir-config.html

Elixir for the Functional Rubyist | Indiegogo
https://www.indiegogo.com/projects/elixir-for-the-functional-rubyist#/story

The Erlangelist: Outside Elixir: running external programs with ports
http://www.theerlangelist.com/2015/08/outside-elixir.html

P2P WebRTC file sharing app: Broker using Phoenix
http://zohaib.me/p2p-webrtc-file-sharing-app-broker-using-phoenix/

Elixir in Action Review and Q&A with the Author
http://www.infoq.com/articles/elixir-in-action-erlang-review

Phoenix 1.0 – the framework for the modern web just landed · Phoenix
http://www.phoenixframework.org/blog/phoenix-10-the-framework-for-the-modern-web-just-landed

Email notifications about errors in Elixir
http://reganmian.net/blog/2015/08/26/email-notifications-about-errors-in-elixir/

Using Dilayzer with Elixir Integration Tests – Learning Elixir
http://learningelixir.joekain.com/dialyzer-and-integration-tests/

Core Elixir: List.delete_at/2 – Various and Sundry CS
http://variousandsundry.com/cs/blog/2015/08/20/core-elixir-list-dot-delete-at-slash-2/

Using Recursion In Elixir To Break Your OO Brain – Rob Conery
http://rob.conery.io/2015/09/04/using-recursion-in-elixir-to-break-your-oo-brain/

The Erlangelist
http://www.theerlangelist.com/

Elixir, Docker and PG2
http://blog.jonharrington.org/elixir-and-docker/

My Links
https://delicious.com/ajlopez/elixir

Stay tuned!

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

Elixir: Links and Resources (1)

Next Post

Programming in Elixir with the Phoenix Framework – Building a basic CRUD app · Garrett Heinlen
http://gogogarrett.sexy/programming-in-elixir-with-the-phoenix-framework-building-a-basic-CRUD-app/

Introduction – Elixir
http://elixir-lang.org/getting-started/introduction.html

Elixir Documentation – Elixir
http://elixir-lang.org/docs.html

The Languages And Frameworks That You Should Learn In 2015 | wwwDesigned
http://wwwdesigned.com/the-languages-and-frameworks-that-you-should-learn-in-2015/

edgurgel/poxa
https://github.com/edgurgel/poxa

The Polyglot in the Code – An Elixir/Ruby Mashup – Johnny Winn – YouTube
https://www.youtube.com/watch?v=Fy3eXXDuuAA

Elixir is for programmers
http://blog.pluralsight.com/elixir-is-for-programmers

Elixir
http://elixir-lang.org/crash-course.html

Lost in a World of Data | Virtuous Code
http://devblog.avdi.org/2013/12/30/lost-in-a-world-of-data/

Elixir: Modern Programming for the Erlang VM
http://www.infoq.com/presentations/Elixir-Erlang-VM

elixir-lang/ecto
https://github.com/elixir-lang/ecto

Writing RabbitMQ Plugins With Elixir
http://videlalvaro.github.io/2013/06/writing-rabbitmq-plugins-with-elixir.html

A Week with Elixir
http://joearms.github.io/2013/05/31/a-week-with-elixir.html

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

Erlang: Is Elixir (elixir-lang.org) production ready? – Quora
http://www.quora.com/Erlang/Is-Elixir-elixir-lang-org-production-ready?srid=d34&st=ns

Elixir
http://elixir-lang.org/

My Links
https://delicious.com/ajlopez/elixir

Stay tuned!

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

Erlang: Links, News And Resources (14)

Previous Post

Leapsight Semantic Dataspace – for High Resolution Customer Engagament Marketing | Erlang Solutions
https://www.erlang-solutions.com/resources/webinars/leapsight-semantic-dataspace-high-resolution-customer-engagament-marketing

Webinars | Erlang Solutions
https://www.erlang-solutions.com/resources/webinars

London Erlang User Group: Data and logic on acid: Introducing Leapsight Semantic Dataspace (LSD) | Erlang Solutions
https://www.erlang-solutions.com/event/london-erlang-user-group-data-and-logic-acid-introducing-leapsight-semantic-dataspace-lsd

Erlang: The Unintentional Neural Network Programming Language
http://www.erlang-factory.com/upload/presentations/384/GeneSher.pdf

Announcing gerl: Genetic Programming in Erlang
http://dan.bravender.net/2007/9/27/Announcing_gerl%3A_Genetic_Programming_in_Erlang.html

A Generalized Parallel Genetic Algorithm in Erlang
http://personal.denison.edu/~lalla/MCURCSM2011/6.pdf

mlen/genetic
https://github.com/mlen/genetic

A genetic algorithm example in Erlang. | Dream Child
https://atrueswordsman.wordpress.com/2010/12/14/a-genetic-algorithm-example-in-erlang/

Programming in Elixir with the Phoenix Framework – Building a basic CRUD app · Garrett Heinlen
http://gogogarrett.sexy/programming-in-elixir-with-the-phoenix-framework-building-a-basic-CRUD-app/

Introduction – Elixir
http://elixir-lang.org/getting-started/introduction.html

Elixir Documentation – Elixir
http://elixir-lang.org/docs.html

BEAM File Format
https://synrc.com/publications/cat/Functional%20Languages/Erlang/BEAM.pdf

Hitchhiker’s Tour of the BEAM
http://www.erlang-factory.com/upload/presentations/708/HitchhikersTouroftheBEAM.pdf

Joe Armstrong
http://joearms.github.io/

Erlang Factory SF Bay Area 2015
http://www.erlang-factory.com/sfbay2015#home

Reactive Cloud Actors: An Evolvable Web of Events
http://www.infoq.com/articles/reactive-cloud-actors

unbalancedparentheses/gut
https://github.com/unbalancedparentheses/gut
gut is a template printing, aka scaffolding, tool for Erlang. Like rails generate or yeoman

FiaR @ ErlangBA Meetup by Inaka Labs on Prezi
https://prezi.com/o0_apxvgf3py/fiar-erlangba-meetup/

organix/tartjs
https://github.com/organix/tartjs
Tiny Actor Run-Time in JavaScript

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

Stay tuned!

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

Erlang: Links, News And Resources (13)

Previous Post
Next Post

[erlang-questions] Why do we need modules at all?
http://erlang.org/pipermail/erlang-questions/2011-May/058768.html

How I Start.
http://howistart.org/posts/erlang/1

edgurgel/poxa
https://github.com/edgurgel/poxa

Erjang – inside Erlang on the JVM // Speaker Deck
https://speakerdeck.com/krestenkrab/erjang-inside-erlang-on-the-jvm

Erjang – A JVM-based Erlang VM
http://www.infoq.com/presentations/Erjang-A-JVM-based-Erlang-VM

integration – Java to Erlang messages – Stack Overflow
http://stackoverflow.com/questions/4132554/java-to-erlang-messages

Erlang — The Jinterface Package
http://www.erlang.org/doc/apps/jinterface/jinterface_users_guide.html

Erjang, Why? – Java to the Limit
http://www.javalimit.com/2009/12/erjang-why.html

josephmisiti/awesome-machine-learning
https://github.com/josephmisiti/awesome-machine-learning

https://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf
https://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf

Prettt-tty, pretty, pretty good!: Actors are not a good concurrency model
http://pchiusano.blogspot.com.ar/2010/01/actors-are-not-good-concurrency-model.html

5 Programming Languages You’ll Need Next Year (and Beyond) – Dice News
http://news.dice.com/2014/07/29/5-programming-languages-youll-need-next-year-beyond/

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

Stay tuned!

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

AjErl Implementing Erlang in C# (2) Expressions

Previous Post

Some time ago I write this project, an Erlang implementation as interpreter using C #. Let review today the implementation of expressions. An expression is evaluated in a context. For example, the variable X, is an expression that is evaluated in a context that tells how that variable is bound to a value or it is free.

All expressions are written using the workflow TDD (Test-Driven Development). After some expressions, this interface emerge in a refactor, and now all expressions implement it:

public interface IExpression
{
    object Evaluate(Context context, bool withvars = false);

    bool HasVariable();
}

The key method is Evaluate. It can allow or not that some variables are still unbound after the evaluate. There is a boolean method HasVariable that indicates the existence of variables in the expression. The simplest expression is a constant expression:

public class ConstantExpression : IExpression
{
    private object value;

    public ConstantExpression(object value)
    {
        this.value = value;
    }

    public object Value { get { return this.value; } }

    public object Evaluate(Context context, bool withvars = false)
    {
        return this.value;
    }

    public bool HasVariable()
    {
        return false;
    }
}

The Evaluate method does not use the provided context, it is only returning the original constant value, defined in the constructor. The expressions are grouped in a tree of expressions that is recursively evaluated.

An expression that evaluates a variable:

public class VariableExpression : IExpression
{
    private Variable variable;

    public VariableExpression(Variable variable)
    {
        this.variable = variable;
    }

    public Variable Variable { get { return this.variable; } }

    public object Evaluate(Context context, bool withvars = false)
    {
        if (!context.HasValue(this.variable.Name))
            if (!withvars)
                throw new Exception(string.Format("variable '{0}' is unbound", this.variable.Name));
            else
                return this.variable;

        return context.GetValue(this.variable.Name);
    }

    public bool HasVariable()
    {
        return true;
    }
}

This time, the context is used. If the variable is not bound to a value, it can return the unbound value, or raise an exception, depending on a boolean withValues. Some times, Erlang expects and needs that an expression be complete evaluated, having no unbound variables.

This code was implemented following the workflow of TDD. Some tests as examples (but it is only the final result, the important thing is the workflow, the dynamic of the programming activity). For a constant expression:

[TestMethod]
public void CreateSimpleConstantExpression()
{
    ConstantExpression expr = new ConstantExpression(10);

    Assert.AreEqual(10, expr.Value);
}

[TestMethod]
public void EvaluateSimpleConstantExpression()
{
    ConstantExpression expr = new ConstantExpression(10);

    Assert.AreEqual(10, expr.Evaluate(null));
}

For a variable expression:

[TestMethod]
public void CreateSimpleVariableExpression()
{
    Variable variable = new Variable("X");
    VariableExpression expression = new VariableExpression(variable);

    Assert.AreEqual(variable, expression.Variable);
}

[TestMethod]
public void EvaluateVariableExpression()
{
    Variable variable = new Variable("X");
    Context context = new Context();
    context.SetValue("X", 1);
    VariableExpression expression = new VariableExpression(variable);

    Assert.AreEqual(1, expression.Evaluate(context));
}

[TestMethod]
public void EvaluateUndefinedVariableExpression()
{
    Variable variable = new Variable("X");
    Context context = new Context();
    VariableExpression expression = new VariableExpression(variable);

    Assert.AreEqual(variable, expression.Evaluate(context, true));
}

[TestMethod]
public void RaiseIfEvaluateUndefinedVariableExpression()
{
    Variable variable = new Variable("X");
    Context context = new Context();
    VariableExpression expression = new VariableExpression(variable);

    try
    {
        expression.Evaluate(context, false);
        Assert.Fail();
    }
    catch (Exception ex)
    {
        Assert.AreEqual("variable 'X' is unbound", ex.Message);
    }
}

Upcoming topics: explore other expression implementations, data structure implementations for variables, maps, and more…

Stay tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez