Angel \”Java\” Lopez on Blog

September 16, 2014

RuScript, Ruby Interpreter in JavaScript (1) The Project

Filed under: JavaScript, NodeJs, Open Source Projects, Ruby, RuScript — ajlopez @ 5:08 pm

When I have free time, I’m working on:

I’m writing the code following the TDD (Test-Driven Development) workflow (see commit history)

The idea is to have a Ruby interpreter written in JavaScript, so it can run at the browser, or at the server with Node.js. I’m not implementing a compiler yet, because I want to do “baby steps”, and because Ruby semantic could be different to JavaScript one. Ie, the resolution of methods, or check if a variable is local to a function or not, are examples of divergences between the languages. So, I decided to write an interpreter.

I’m applying “dog fooding”: the parser is written using:

I’m applying SimpleGrammar in other projects, like RustScript. There is an implementation in C#, too, named GrammGen). A fragment of the defined rules for RuScript parser:

// Expression Level 1
get('Expression1', 'Plus', 'Expression0')
    .generate('Expression1', function (values) { return new AddExpression(values[0], values[2]); }),
get('Expression1', 'Minus', 'Expression0')
    .generate('Expression1', function (values) { return new SubtractExpression(values[0], values[2]); }),

// Expression Level 0
get('Expression0', 'Multiply', 'Term')
    .generate('Expression0', function (values) { return new MultiplyExpression(values[0], values[2]); }),
get('Expression0', 'Divide', 'Term')
    .generate('Expression0', function (values) { return new DivideExpression(values[0], values[2]); }),

// Term
get('Term', 'LeftBracket', 'ExpressionList', 'RightBracket')
    .generate('Term', function (values) { return new IndexedExpression(values[0], values[2]); }),
get('@@', 'Name').generate('ClassVariable', 
    function (values) { return new ClassVariableExpression(values[1].getName()); }),
get('@', 'Name').generate('InstanceVariable', 
    function (values) { return new InstanceVariableExpression(values[1].getName()); }),
get('LeftParenthesis', 'Expression', 'RightParenthesis')
    .generate('Expression0', function (values) { return values[1]; }),
get('LeftBracket', 'RightBracket')
    .generate('Array', function (values) { return new ArrayExpression([]); }),
get('LeftBracket', 'ExpressionList', 'RightBracket')
    .generate('Array', function (values) { return new ArrayExpression(values[1]); }),

For each discovered element, the grammar is building an expression, that can be evaluate using a context. A context has the values of the visible variables. Example:

function NameExpression(name) {
    this.evaluate = function (context) {
        var value = context.getValue(name);
        if (typeof value == 'function')
            return value();
        return value;
    this.getName = function () { return name; };
    this.setValue = function (context, value) {
        context.setLocalValue(name, value);

function InstanceVariableExpression(name) {
    this.evaluate = function (context) {
        if (!context.$self.$vars)
            return null;
        return context.$self.$vars[name];
    this.getName = function () { return name; };
    this.setValue = function (context, value) {
        if (!context.$self.$vars)
            context.$self.$vars = { };
        context.$self.$vars[name] = value;

function ClassVariableExpression(name) {
    this.evaluate = function (context) {
        if (!context.$self.$class.$vars)
            return null;
        return context.$self.$class.$vars[name];
    this.getName = function () { return name; };
    this.setValue = function (context, value) {
        if (!context.$self.$class.$vars)
            context.$self.$class.$vars = { };
        context.$self.$class.$vars[name] = value;

function ConstantExpression(value) {
    this.evaluate = function () {
        return value;

I have access to JavaScript features from Ruby, example, a test:

exports['Evaluate JavaScript global name'] = function (test) {
    global.myglobal = 42;
    var context = contexts.createContext();
    var parser = parsers.createParser("js.myglobal");
    //parser.options({ log: true });
    var expr = parser.parse("Expression");
    var result = expr.value.evaluate(context);
    test.equal(result, 42);

The js namespaces allowed the access to JavaScript defined variables, and all its ecosystem, at the browser or at the server.

I want to share my advances at RubyConf 2014 Argentina.

Next steps: access to Node.js require, web site examples using Node.js/Express, console examples, browser examples, etc.

Stay tuned!

Angel “Java” Lopez

September 13, 2014

New Month’s Resolutions: September 2014

Filed under: .NET, C Sharp, JavaScript, NodeJs, Open Source Projects — ajlopez @ 5:34 pm

A bit late, time to review my August’s Resolutions:

- Write jQuery mock to be used in console tests/Node.js [complete] see repo
- Write simple functions in JavaScript for array manipulation [complete] see repo
- Continue with Liqueed project [complete] see repo
- Start with Distributed Aktores [partial] see repo
- Startwith Distributed AjErl [pending]

Additionally, I worked on:

- Give an intro talk about Express [complete] see repo see presentation see samples
- Improve AjScript [complete] see repo
- Improve RuScript, Ruby interpreter in JavaScript [complete] see repo
- Refactor SimplePipes [complete] see repo
- Generate Node.js/Express server code from RAML [complete] see repo
- Create Dynamic Site from JSON to Express [complete] see repo
- Improve RustScript, Rust interpreter in JavaScript [complete] see repo
- Create Mochy, test framework a la Mocha [complete] see repo
- Create RSharp, R language interpreter in C# [complete] see repo
- Refactor (and simplify) SimpleRules, rule engine in JavaScript [complete] see repo
- First samples for SimpleMule [complete] see repo
- Improve output for SimpleUnit [complete] see repo

My new month’s resolutions:

- Distributed Aktores
- Distributed AjErl
- Web support and example for RuScript
- Complete Mochy
- Improve RSharp
- Work with NodeJs on Deep Learning, Internet of Things, Artificial Intelligence
- Work on Code Generation using AjGenesis for Node
- Work on Liqueed Project

Stay tuned!

Angel “Java” Lopez

September 11, 2014

Express: Links, News And Resources (7)

Filed under: Express, JavaScript, Links, NodeJs, Web Development — ajlopez @ 3:44 pm

Previous Post
Next Post

More links at

29 Node.js Frameworks for Fast Web Application Development

Introduction to the MEAN Stack – Tuts Code Tutorial–cms-19918


Node.js Pinterest Clone Script – Myyna build your own pinterest

A Sample App with Node.js, Express and MongoDB – Part 2 | Dev Notes

The Ultimate Guide To Node.js Express by Greg Cerveny | Udemy

hacksparrow/multer · GitHub


An Introduction To Full-Stack JavaScript | Smashing Coding

KeystoneJS · Node.js cms and web application platform built on Express and MongoDB

JedWatson/keystone · GitHub

My Links

September 8, 2014

Express: Links, News And Resources (6)

Filed under: Express, JavaScript, Links, NodeJs, Web Development — ajlopez @ 6:22 pm

Previous Post
Next Post

More links at

node.js – Express.js routing for bower components – Stack Overflow

node.js – How to change bower’s default components folder? – Stack Overflow

Boilerplate web app using Backbone.js, ExpressJS, node.js, MongoDB | Kroltech


Full-Stack JavaScript With MEAN And Yeoman

51 Elliot: Testing Express.JS REST APIs with Mocha

node.js – Layouts in Express 3 and EJS – Stack Overflow


traider is an open source to ecommerce | coded with love (and javascript: nodejs, angularjs and mongodb)

Express.js Fundamentals | Flippin’ Awesome

StrongLoop | How to run Node.js on the JVM with Avatar.js and LoopBack


Build a sentiment analysis application with Node.js, Express, sentiment, and ntwitter


Express.js Guide by Azat Mardanov [Leanpub PDF/iPad/Kindle]


Create and Deploy a Node.js Website to Heroku by Joshua Chittick | Udemy

eBay Dev Blog | Node.js with Express and Closure Templates

My Links

Stay tuned!

Angel “Java” Lopez

September 5, 2014

Express: Links, News And Resources (5)

Filed under: Express, JavaScript, Links, NodeJs, Web Development — ajlopez @ 3:36 pm

Previous Post 
Next Post

Some of my old links, more updated info at

Davide Moro: Yeoman, Express and AngularJS



Raspberry Pi – [Episode 3] Get Coding With Coder – CodeProject


Tutorial – Getting Started With Node.js, Express, MongoDB | Christopher Buecheler – Web, Writing, Cocktails and More

Security Issue – Cross-Site Scripting with connect.methodOverride() · Issue #831 · senchalabs/connect

Rolling Your Own RSS Feed with Express and Jade

Do Not Use bodyParser with Express.js – Andrew Kelley


Intro to Cartero on Vimeo


Express.js Book


Express Web Application Development | Packt Publishing

Modular web applications with Node.js and Express – TJ Holowaychuk

Organizing node.js and Express web applications —

node.js – Logging in express js to a output file? – Stack Overflow

My Links

Stay tuned!

Angel “Java” Lopez

September 3, 2014

Express: Links, News And Resources (4)

Filed under: Express, JavaScript, Links, NodeJs, Web Development — ajlopez @ 6:58 pm

Previous Post
Next Post

Some of my old links, more updated info at

Working With Data in Sails.js | Nettuts+
Sails.js is an up and coming Node.js framework

Express.js and Node.js as a prototyping medium | Chris Webb

Even Better In-Browser Mockups with Node.js · An A List Apart Article

Node at Work: A Walkthrough · An A List Apart Article

Getting Started With Node and Express « Eric Elliott – JavaScript Architect (A JavaScript Blog)

hermanjunge/herman-sessions-tutorial-101 · GitHub
Una introducción a sessions (sesiones) usando NodeJS y ExpressJS

Building Parse Web Apps with the Express Web Framework | Parse Blog

Twitter Bootstrap LESS with Node.js & Express – Stack Overflow

Node.js – express – jade – compile SASS/LESS – Stack Overflow

Understanding Express.js | Evan Hahn

Render ejs with express – Node.js for express

alexferreira/restgen · GitHub
The goal of restgen is to provide a micro framework that helps you to write a RESTful webservice using NodeJs, Express, Mongoose (MongoDB)

The MongoDB NoSQL Database Blog, The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js

autoric/express-train · GitHub
Express Train is a framework for building 12 factor web applications in nodejs, based on express 3.

My Links

Stay tuned!

Angel “Java” Lopez

August 28, 2014

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

Filed under: JavaScript, Links, NodeJs — ajlopez @ 5:44 pm

Previous Post
Next Post

gf3/sandbox – GitHub

Building A Node.JS Server That Won’t Melt – A Node.JS Holiday Season, part 5 ✩ Mozilla Hacks – the Web developer blog

cpsubrian/node-eventflow · GitHub

Count the Number of Object keys/properties in Node.js | Vance Lucas

leoasis/makery.js · GitHub

about process.binding – Google Groups!topic/nodejs/R5fDzBr0eEk

SportZing/node-pass-reset · GitHub

nCombo – Node.js Cloud App Framework

hacksparrow/node-easyimage · GitHub

EasyImage – Nodejs Image Processing Module | Blogfreakz – Web Design and Web Development resources

gm : GraphicsMagick for node.js

big-integer – Live Demo!

node.js – Any libraries that can make accessing Google APIs as a service account simpler for NodeJS? – Stack Overflow

Passport – Simple, unobtrusive authentication for Node.js.

jfromaniello/winser · GitHub
As Windows Service

eldargab/easy-app · GitHub

» Node.js on Raspberry Pi JeeLabs

The Step of the Conductor – How To Node – NodeJS

Industrial/graphflow · GitHub

cha0s/mongoose-api · GitHub

How to use stream.pipe –

My Links

Stay tuned!

Angel “Java” Lopez

August 20, 2014

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

Filed under: JavaScript, Links, NodeJs — ajlopez @ 5:10 pm

Previous Post 
Next Post

A Node.js speed dilemma: AJAX or Socket.IO? | Web Builder Zone

Nodejs-code |

niftylettuce/node-google-drive · GitHub
Node.js library to access Google Drive’s API

Making an ‘Authorized Request’ to a Google API using node.js (with everyauth authentication) – Stack Overflow

smurthas/gdata-js · GitHub
Simple Google Data API client for OAuth 2.0

bioinformatics – node.js modules

YOKOFAKUN: Server-side javascript: translating a DNA with Node.js

rogerwang/node-webkit · GitHub
node-webkit is an app runtime based on Chromium and node.js. You can write native apps in HTML and Javascript with node-webkit

Chris Sainty: Creating desktop apps with NodeJS

dominictarr/hipster · GitHub
Text editor in node.js

Serializing/storing closures – nodejs | Google Groups

meelash/Mundlejs · GitHub
Client-side module bundler, cacher, loader

medikoo/find-requires · GitHub
Find all require() calls. Fast and solid implementation backed with direct scanner and esprima ast parser

agrueneberg/Corser · GitHub
CORS middleware for Node.js

express.js middleware to support CORS pre-flight requests

jawerty/Node2Blog · GitHub
A simple and easy to setup node.js blog template. For the casual blogger.

Find files or directories by name

npm package to deploy node.js apps

http – Extracting POST data with Express – Stack Overflow

My Links

Stay tuned!

Angel “Java” Lopez

August 19, 2014

Smalltalk: Links, News And Resources (19)

Filed under: Links, Programming Languages, Smalltalk — ajlopez @ 3:33 pm

Previous Post

ESUG: 2014

Pharo Open Source Smalltalk — News


Philippe Back Interviews Nicolas Petton on Amber Smalltalk by philippeback on SoundCloud – Hear the world’s sounds


smallworks: Why I’m using git in my Pharo projects

Dyla’14 at PLDI, Edinburgh, UK


Self Mallard (4.5.0) released | Self

Self | Fun through simplicity

stic13 – YouTube

(349) Programming Languages: Why create any more programming languages? – Quora

Anyone interested in smalltalk? : learnprogramming

ST 4U 510: Dynamic Code Generation in Pharo

Was Alan Kay wrong? And why does that matter?

Smalltalk on Raspberry Pi | a blog on Smalltalk on the Raspberry Pi

My Links

Stay tuned!

Angel “Java” Lopez

August 14, 2014

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

Filed under: JavaScript, Links, NodeJs — ajlopez @ 3:10 pm

Previous Post 
Next Post

Links from my collection. Recent links at

creationix/uvrun · GitHub


javascript events – Filtering Stream object in node.js – Stack Overflow

node.js – custom stream object? (nodejs) – Stack Overflow

How to Use Buffers in Node.js –

How I move files on node.js – Stack Overflow

node.js – What is the difference between util.pump(streamA, streamB) and streamA.pipe(streamB)? – Stack Overflow

json rpc – What’s the best way to make one node.js server “talk” to another? – Stack Overflow



Joey Nelson: Node.js for noobs: Grabbing POST content

node.js Extracting POST data – Stack Overflow

Accessing the HTTP message body (e.g. POST data) in node.js | Frank Grimm – realtime-web framework for nodejs

How to exit in Node.JS – Stack Overflow

eldargab/make-flow · GitHub

circuit/ at master · tatumizer/circuit · GitHub

jrcryer/phpunit-watchr · GitHub

node_modules in git

My Links

Stay tuned!

Angel “Java” Lopez

« Newer PostsOlder Posts »

Theme: Shocking Blue Green. Get a free blog at


Get every new post delivered to your Inbox.

Join 67 other followers