Angel \”Java\” Lopez on Blog

December 28, 2011

Smalltalk: Links, News and resources (2)

Filed under: Links, Programming Languages, Smalltalk — ajlopez @ 8:56 am

Previous Post
Next Post

More links about Smalltalk, this time: Smalltalk tutorials and introductory articles.

Pharo by Example
http://www.pharobyexample.org/

Pharo the collaborActive book
http://book.pharo-project.org/book

PharoCast
http://www.pharocasts.com/
Pharo Smalltalk screencasts

Videos: Learning Web Development with Seaside
http://programminggems.wordpress.com/2010/02/24/videos-learning-web-development-with-seaside/

Learn Smalltalk with ProfStef
http://amber-lang.net/learn.html
Online, using Amber (Smalltalk translated to Javascript)

Why I love Smalltalk
http://pupeno.com/2011/07/28/why-i-love-smalltalk/

Double dispatch
http://www.cincomsmalltalk.com/userblogs/ralph/blogView?showComments=true&printTitle=Double_dispatch&entry=3485318158

Class formats and CompiledMethod uniqueness
http://marianopeck.wordpress.com/2011/05/07/class-formats-and-compiledmethod-uniqueness/

Departure: VM introduction
http://marianopeck.wordpress.com/2011/04/02/departure-vm-introduction/

Magritte Tutorial
http://www.lukas-renggli.ch/smalltalk/magritte/tutorial.pdf

Some Persistency Approaches
http://book.seaside.st/book/advanced/persistency

Dynamic Web Development with Seaside
http://book.seaside.st/book/

Messing with 3D in Dolphin Smalltalk
http://www.object-arts.com/support/videos_files/Aragon3d.html

La magia del Smalltalk: Capítulo 8 – Algo útil con el #become:
http://diegogomezdeck.blogspot.com/2005/08/la-magia-del-smalltalk-captulo-8-algo.html

La magia del Smalltalk: Capítulo 1 – ¡No entiendo nada!
http://diegogomezdeck.blogspot.com/2005/07/la-magia-del-smalltalk-captulo-1-no.html

La magia del Smalltalk: Capítulo 0
http://diegogomezdeck.blogspot.com/2005/07/la-magia-del-smalltalk-captulo-0.html

Smalltalk 4 U 3: Getting Started with GLASS and Pharo
http://www.jarober.com/blog/blogView?showComments=true&printTitle=Smalltalk_4_U_3:_Getting_Started_with_GLASS_and_Pharo&entry=3465009117

Laser Game – A Development Example for Squeak 3.9
http://squeak.preeminent.org/tut2007/html/

IBM Smalltalk Tutorial
http://www.inf.ufsc.br/poo/smalltalk/ibm/tutorial/content.html

One Assertion Per Test
http://www.artima.com/weblogs/viewpost.jsp?thread=35578

Help for Etoys.
http://patricioacevedo.blogspot.com/2010/02/help-for-etoys.html

Video: Continuations and Subroutine Calls
http://programminggems.wordpress.com/2010/02/17/video-continuations-and-subroutine-calls/

Smalltalk Daily 07/21/10: Polymorphic Behavior
http://www.cincomsmalltalk.com/blog/blogView?entry=3457156697

Smalltalk Television Video Collection
http://smalltalk.org/videos

My Links Smalltalk Tutorials
http://delicious.com/ajlopez/smalltalk+tutorial

More links about Smalltalk are coming.

Keep tuned!

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

December 27, 2011

COBOL: Links, News and Resources (1)

Filed under: COBOL, Links, Programming Languages — ajlopez @ 9:43 am

Next Post

More than 30 years ago, I wrote programs in COBOL, for IBM mainframes and other machines. Now, the language is alive and still in use. Some of my links:

http://en.wikipedia.org/wiki/COBOL

COBOL (play /ˈkbɒl/) is one of the oldest programming languages. Its name is an acronym forCOmmon Business-Oriented Language, defining its primary domain in business, finance, and administrative systems for companies and governments.

The COBOL 2002 standard includes support for object-oriented programming and other modern language features.[1]

 

Visual COBOL integration with Visual Studio 2010
http://www.youtube.com/watch?v=-1Pi0rxjk3Y

Java apps have most flaws, Cobol apps the least, study finds
http://www.computerworld.com/s/article/9222503/Java_apps_have_most_flaws_Cobol_apps_the_least_study_finds

RES – An Open Cobol To Java Translator
http://sourceforge.net/projects/opencobol2java/

Koopa Cobol Parser
http://sourceforge.net/projects/koopa/

Why Cobol Modernization Is Relevant Today
http://cloudcomputing.sys-con.com/node/1723532

Grace Hopper: Programming Pioneer
http://www.crn.com/news/channel-programs/18836964/grace-hopper-programming-pioneer.htm

COBOL
http://www.csee.umbc.edu/courses/graduate/631/Fall2002/COBOL.pdf

COBOL’s Not Dead. Make it Play Nice with the Modern Enterprise
http://www.readwriteweb.com/enterprise/2011/01/cobols-not-dead-in-the-enterprise.php

COBOL – The New Age Programming Language
http://www.shlomifish.org/humour/bits/COBOL-the-New-Age-Programming-Language/

Micro Focus Announces CICS® for .NET
http://www.microfocus.com/aboutmicrofocus/pressroom/releases/pr20100712268224.asp

Net Express with .NET
http://download.cnet.com/Net-Express-with-NET/3000-2069_4-10866201.html

Geriatric Java struggles to stay relevant
http://www.infoworld.com/d/developer-world/geriatric-java-struggles-stay-relevant-700

A Comparison Of .net COBOL, Visual Basic and C#
http://www.codeproject.com/KB/net-languages/COBOLvsVBvsCSharp.aspx

Ideone
http://ideone.com/
Ideone is something more than a pastebin; it’s an online compiler and debugging tool which allows
to compile and run code online in more than 40 programming languages.

The Future of the Mainframe
http://lips.informatik.uni-leipzig.de/files/Spruth2007TheFutureoftheMainframeEUROcmgNrnberg.pdf

Enterprise Applications: 20 Things You Might Not Know About COBOL (as the Language Turns 50)
http://www.eweek.com/c/a/Enterprise-Applications/20-Things-You-Might-Not-Know-About-COBOL-As-the-Language-Turns-50-103943/

Cobol-IT
http://www.cobol-it.com/
Open Source COBOL Compiler

COBOL to Java Automatic Migration with GPL’ed Tools
http://www.infoq.com/news/2009/07/cobol-to-java

APL, COBOL, & Dijkstra
http://www.zdnet.com/blog/murphy/apl-cobol-dijkstra/568

Free Cobol
Programming
http://www.freebyte.com/programming/cobol/

The COBOL Programming Language
http://groups.engin.umd.umich.edu/CIS/course.des/cis400/cobol/cobol.html

Cobol hits 50 and keeps counting
http://www.guardian.co.uk/technology/2009/apr/09/cobol-internet-programming

COBOL
http://www.microfocus.com/mcro/cobol/

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

More links about programming languages are coming.

Keep tuned!

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

December 23, 2011

Smalltalk: Links, News and Resources (1)

Filed under: Links, Programming Languages, Smalltalk — ajlopez @ 8:52 am

Next Post

You know I was working on the implementation of my open source Smalltalk VM AjTalk (Recently, I was posting about translation from Smalltalk to Javascript). My first contact with Smalltalk was in the eighties, and since then, I was interested in it. It never become a “mainstream” programming language (yes, I know, it’s more than a programming language), and it suffered “balkanization” in its history, according to Ken Beck: many competing companies, implementing different VMs and class libraries (compare this with the unified history of Java, Ruby, Python, .NET, etc.). This is the first in a series of post about Smalltalk, this time: Smalltalk videos.

Alan Kay shares a powerful idea about ideas
http://www.ted.com/talks/alan_kay_shares_a_powerful_idea_about_ideas.html

Hitler se entera que Fidel habla de objetos en la Smalltalks
http://vimeo.com/30529851

PharoCasts
http://www.pharocasts.com

PharoCasts Basic UI building
http://www.pharocasts.com/2010/01/basic-ui-building.html

Smalltalk.org Videos
http://smalltalk.org/videos

Physical EToys Team (Richo, Sebas y Gonzalo) – Ganadores del 1er Premio ESUG Innovation Award
http://www.youtube.com/watch?v=Q4iKUXVFL7o

Esteban Lorenzano – Ganador del 3er puesto de ESUG Innovation Award
http://www.youtube.com/watch?v=YcRlgvX-qhY

The Amp Goes to 11: TDD in Smalltalk
http://www.youtube.com/watch?v=mXoxfmcDDJM

Smalltalk Daily 07/21/10: Polymorphic Behavior
http://www.cincomsmalltalk.com/blog/blogView?entry=3457156697

Dan Ingalls on the History of Smalltalk and the Lively Kernel
http://www.infoq.com/interviews/ingalls-smalltalk

Video: Continuations and Subroutine Calls
http://programminggems.wordpress.com/2010/02/17/video-continuations-and-subroutine-calls/

Part of the series: Workshop on Self-sustaining Systems (S3) (SS 2008)
http://www.tele-task.de/archive/lecture/overview/3624/

Self and Super: Explaining Method Lookup
http://www.jarober.com/blog/blogView?entry=3443681744

Video: Associating Domain Objects with Components
http://programminggems.wordpress.com/2010/02/10/video-associating-domain-objects-with-components/

Brian Foote and Dave West Discuss Craftsmanship
http://www.infoq.com/interviews/foote-west-craftmanship;jsessionid=43251D6AF9D1103D73DDC8984A63CF0E

Failure: An Illustrated Guide
http://www.infoq.com/presentations/bryant-failure-guide

Smalltalk Daily 12/04/09: Multiple UIs, one Domain Model
http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_12/04/09:_Multiple_UIs,_one_Domain_Model&entry=3437364817

“Introduction to GemStone” Videos
http://programminggems.wordpress.com/2009/12/01/smalltalks-2/

Smalltalk Daily 11/24/09: Overrides
http://www.cincomsmalltalk.com/blog/blogView?entry=3436507467

Dan Ingalls: Seven (give or take) Smalltalk implementations
http://video.google.com/videoplay?docid=2409496407757723940&q=dan+ingalls

Smalltalk Daily 9/18/09: Exploring Objects
http://www.cincomsmalltalk.com/blog/blogView?entry=3430713089

RailsConf 09: Robert Martin, “What Killed Smalltalk Could Kill Ruby”
http://www.youtube.com/watch?v=YX3iRjKj7C0

Avi Bryant on Trendly, Ruby, Smalltalk and Javascript
http://www.infoq.com/interviews/bryant-smalltalk-trendly

Smalltalk Daily 9/22/08: Seaside Tutorial 1
http://www.cincomsmalltalk.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_9/22/08:_Seaside_Tutorial_1&entry=3399525731

CS 2340 – Smalltalk Tutorial – Creating a canvas
http://www.youtube.com/watch?v=jv7ciEUQzbk

Video: Programando de a pares con Diogenes Moreira
http://www.codeandbeyond.org/2011/06/video-programando-de-pares-con-diogenes.html

QCon Keynote: Forty Years of Fun with Computers
http://www.infoq.com/presentations/Forty-Years-of-Fun-with-Computers

Kinect and Etoys
http://tecnodacta.com.ar/gira/2011/01/kinect-and-etoys/

Kinect and Etoys
http://www.youtube.com/watch?v=YnqqaHvbeqg

Smalltalk Television
http://www.smalltalktelevision.com/

Videos: Learning Web Development with Seaside
http://programminggems.wordpress.com/2010/02/24/videos-learning-web-development-with-seaside/

IV Conferencia Internacional en la UTN _ Espone Andy Kellens de Bélgica- DIARIO LACALLE
http://www.youtube.com/watch?v=qTCQlY00FTE&NR=1

Conferencia Internacional en la UTN- Hernán Wilkinson de FAST- DIARIO LACALLE
http://www.youtube.com/watch?v=I50bTfQr8l8

Messing with 3D in Dolphin Smalltalk
http://www.object-arts.com/support/videos_files/Aragon3d.html

Object Arts, Videos
http://www.object-arts.com/support/videos.html

TDD Static vs. Dynamic – Parte 1/2
http://www.youtube.com/watch?v=RLAZjiK4UHc

TDD Static vs. Dynamic – Parte 2/2
http://www.youtube.com/watch?v=wXW9WN9ay2E

ESUG 2010 – Interview Smalltalk Community Argentina
http://blip.tv/citilabcornella/esug-2010-interview-smalltalk-community-argentina-4230386

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

More links about Smalltalk, AjTalk and Javascript are coming.

Keep tuned!

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

December 21, 2011

Node.js: Links, News and Resources (4)

Filed under: JavaScript, Links, NodeJs — ajlopez @ 8:46 am

Previous Post
Next Post

I want to extend the Social Gaming Toolkit to support Node.js as game server. Meanwhile, these are my new links about Node:

Node.js v0.6.5 Manual & Documentation
http://nodejs.org/docs/v0.6.5/api/

15 Papers you should read when interested in node.js’s background
https://plus.google.com/111191895515210271225/posts/HN2ZTbf7Cgg

Turing Machine, in Javascript and Node
https://gist.github.com/1449124

nodeca / ndoc
https://github.com/nodeca/ndoc
js port of pdoc, with extentions

Announcing SilkJS
http://www.sencha.com/forum/showthread.php?160128-Announcing-SilkJS
I am pleased to announce SilkJS, a V8 based Swiss Army Knife (and HTTP server).

Node.js modules you should know about: lazy
http://www.catonmat.net/blog/nodejs-modules-lazy/

ecto / duino
https://github.com/ecto/duino
Arduino framework for node.js

Blazing fast node.js: 10 performance tips from LinkedIn Mobile
http://engineering.linkedin.com/nodejs/blazing-fast-nodejs-10-performance-tips-linkedin-mobile

Node.js Performance Tips from LinkedIn
http://www.readwriteweb.com/hack/2011/12/nodejs-performance-tips-from-l.php

c9 / nog
https://github.com/c9/nog
Nog is a simple node powered web log (aka blog) —

Understanding callback functions in Javascript
http://recurial.com/programming/understanding-callback-functions-in-javascript/

pekim / node-java
https://github.com/pekim/node-java
A bridge from node.js to a Java process

pekim / node-jdbc
https://github.com/pekim/node-jdbc
Using JDBC from node

pekim / tedious
https://github.com/pekim/tedious
Node TDS module for connecting to SQL Server databases

Node.js Database Drivers
http://nodejsdb.org/

DrBenton / Node-DBI
https://github.com/DrBenton/Node-DBI
A SQL database abstraction layer strongly inspired by the PHP Zend Framework Zend_Db API, with support of multiple Node.js database engines

Node.js isn’t cancer. Threads aren’t evil. The Node.js-is-cancer fibonacci server revisited.
http://www.youtube.com/watch?v=_wyQvafohlE

Fabric Engine Benchmark: Node.js Fibonacci Server
http://fabric-engine.com/2011/11/benchmark-node-js-fibonacci-server/

joshfire / node-crawler
Web Crawler/Spider for NodeJS + server-side jQuery ;-)

Dillinger
http://dillinger.io/
Dillinger is a cloud-enabled HTML5 Markdown editor.

Node.js for Java developers
http://www.ibm.com/developerworks/web/library/j-nodejs/index.html
Lightweight, event driven I/O for your web apps

Node.js vs Ruby On Rails
http://nodejs-vs-ror.nodejitsu.com/

Flatiron
http://flatironjs.org/
an unobtrusive framework initiative for node.js
Flatiron’s approach is to package simple to use yet full featured components and let developers subtract or add what they want.

node.js version selection
http://www.scalarium.com/blog/2011-11-21-node/

Node.js research
http://www.wilcoxd.com/whitepapers/node_js/

hookio / hook.io
https://github.com/hookio/hook.io
a distributed EventEmitter and i/o framework for node.js

Node Toolbox
http://toolbox.no.de/

A short guide to Connect Middleware
http://stephensugden.com/middleware_guide/
Connect is an extensible HTTP server framework for node, providing high performance “plugins” known as middleware.

broofa / node-int64
https://github.com/broofa/node-int64
Support for representing 64-bit integers in JavaScript

fifield / node-webcl
https://github.com/fifield/node-webcl
A WebCL implementation for node.js
WebCL is a set of bindings of OpenCL for JavaScript
OpenCL (Open Computing Language) is a framework for writing programs that execute across heterogeneous platforms consisting of CPUs, GPUs, and other processors.

cloudhead / http-console
https://github.com/cloudhead/http-console
simple, intuitive HTTP REPL — Speak HTTP like a local

REPL
http://nodejs.org/docs/v0.6.0/api/repl.html
A Read-Eval-Print-Loop (REPL) is available both as a standalone program and easily includable in other programs

Aydes.com
http://www.aydes.com/
Argentinean company working with Node.js

Parsing JavaScript with JavaScript
http://swizec.com/blog/parsing-javascript-with-javascript/swizec/2909

Debug node.js applications on Windows with iisnode integrated debugging
http://tomasz.janczuk.org/2011/11/debug-nodejs-applications-on-windows.html

Creating a quick Todo listing app on Windows using IIS7, Node.js and Mongodb
http://www.amazedsaint.com/2011/09/creating-10-minute-todo-listing-app-on.html

The Node Beginner Book
http://nodebeginner.org/

Node Tuts
http://nodetuts.com/

Mixu’s Node book
http://book.mixu.net/

Helicon Zoo — a repository of web frameworks and applications for Microsoft IIS.
http://www.helicontech.com/zoo/
Including Pythong, Django, Ruby, Rails, Node.js, Perl

xk / node-sound
https://github.com/xk/node-sound
Sound library for Node

Using Node.js in an ASP.NET MVC application with iisnode
http://weblogs.asp.net/jgalloway/archive/2011/10/26/using-node-js-in-an-asp-net-mvc-application-with-iisnode.aspx

Node.js modules
http://nodejs.org/docs/v0.6.5/api/modules.html

arunoda / drev
https://github.com/arunoda/drev
DREV – Distributed Redis based EventEmitter for NodeJS

caolan / nodeunit
https://github.com/caolan/nodeunit
Easy unit testing in node.js and the browser, based on the assert module

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

More links about Node.js, Javascript, Node.js on Windows/Azure are coming.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.c

December 19, 2011

Social Games Programming (Part 6) Testing Game and Service with TDD and QUnit

Filed under: .NET, Azure, Game Development, QUnit, Test-Driven Development — ajlopez @ 8:44 am

Previous Post
Next Post

In my previous post, I presented the new version of Windows Azure Toolkit for Social Games. It has simple games to demonstrate the use of Javascript, HTML 5 canvas, game moves processing, Azure worker roles and web roles. Let’s explore in this post the making of client game logic, in Javascript, using TDD and QUnit.

There are online tests at:

http://watgames4.cloudapp.net/Test

Let’s run the Tic Tac Toe Game Logic tests:

http://watgames4.cloudapp.net/Samples/ClientTest/TicTacToeGameTest

This page is using QUnit for client Javascript unit testing. I wrote about that library at:

TDD with Javascript and QUnit

The above page is testing the Tic Tac Toe logic. Remember, each game is implemented in parts, the logic is one of them:

The client code resides in TicTacToeGame.js inside the SocialGames.Web project. Their first lines:

TTTColor = { Empty: 0, Cross: 1, Circle: 2 };
function TicTacToeGame() {
    this.board = [
     [TTTColor.Empty, TTTColor.Empty, TTTColor.Empty],
     [TTTColor.Empty, TTTColor.Empty, TTTColor.Empty],
     [TTTColor.Empty, TTTColor.Empty, TTTColor.Empty]
     ];
}
TicTacToeGame.prototype.move = function (x, y, color) {
    this.board[x][y] = color;
};
TicTacToeGame.prototype.isEmpty = function (x, y) {
    return this.board[x][y] == TTTColor.Empty;
};
....

The client test page (TicTacToeGameTest.cshtml) was built at the same time, using a TDD (Test-Driven Development) approach. Look at first tests:

test("Create Empty Board", function () {
    var game = new TicTacToeGame();
    for (var x = 0; x < 3; x++)
        for (var y = 0; y < 3; y++)
            ok(game.isEmpty(x, y));
    equal(game.isTie(), false);
    equal(game.hasWinner(), false);
});
test("Valid Moves on Empty Board", function () {
    var game = new TicTacToeGame();
    for (var x = 0; x < 3; x++)
        for (var y = 0; y < 3; y++) {
            ok(game.isValid(x, y, TTTColor.Cross));
            ok(game.isValid(x, y, TTTColor.Circle));
        }
});
test("No Winner in Empty Board", function () {
    var game = new TicTacToeGame();
    equal(game.getWinner(), TTTColor.Empty);
});
test("Get Winner in First Row", function () {
    var game = new TicTacToeGame();
    game.move(0, 0, TTTColor.Cross);
    game.move(1, 0, TTTColor.Cross);
    game.move(2, 0, TTTColor.Cross);
    equal(game.getWinner(), TTTColor.Cross);
    equal(game.isTie(), false);
    equal(game.hasWinner(), true);
});

The idea is to take baby steps, one test at a time, designing the game logic “API”, its expected behavior. In this way, you expend less time debugging in a dynamic language like Javascript, and you gain a test suite that can save your day in case of major refactoring. Look at the Four In A Row logic and client tests: you will find a similar approach.

Ok, not all can be easily tested, or build using TDD. Some of the game-agnostic services are using Ajax and Blob Storage, and to test them you must consider asynchronous Ajax calls. You can check:

http://watgames4.cloudapp.net/Test/ServerInterfaceTest

(You must be logged in using your Facebook or Windows Live ID, an example of use of Federated Security and Access Control Service (ACS))

This time, the system under test is the game-agnostic Server Interface:

There are some tricks in the test code (ServerInterfaceTest.cshmlt), an excerpt:

test("Call User/Verify", function () {
    var success = function (result) { ok(true); start(); };
    var error = ajaxGetError;
    stop(10000);
    expect(1);
    si.sendAjaxGet(apiURL + "user/verify", success);
});

expect is a QUnit function that prepare the framework to receive 1 ok(true) sometime during the test run. That confirmation is included in callback function success that it will be called after the successful processing of the asynchronous call .sendAjaxGet. Async life is not easy ;-)

More code analysis is coming. And some adapt to use Node.js as game server.

Keep tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

December 15, 2011

AjLisp in Ruby (2) Context with Name and Values

Previous Post

One of the first classes I implemented in AjLispRb is the environment. This time I called it a context: a dictionary where to save name/values, to store the atom values. The code:

module AjLisp
class Context
    def initialize(parent = nil)
        @parent = parent
        @values = Hash.new
    end
    
    def getValue(name)
        if @values.has_key?(name)
            return @values[name]
        end
        
        if @parent != nil
            return @parent.getValue(name)
        end
        
        return nil
    end
    
    def setValue(name, value)
        @values[name] = value
    end
end
end

The class was coded using TDD, the first tests at test/test_context.rb. Some tests:

def test_not_defined_is_nil
    context = AjLisp::Context.new
    assert_nil(context.getValue(:foo))
end
def test_set_and_get_value
    context = AjLisp::Context.new
    context.setValue(:foo, "bar")
    assert_equal("bar", context.getValue(:foo))
end
def test_get_value_from_parent
    parent = AjLisp::Context.new
    parent.setValue(:foo, "bar")
    context = AjLisp::Context.new(parent)
    assert_equal("bar", context.getValue(:foo))
end

Initially, I used strings for names, but now I'm using Ruby symbols like :foo. I have a test that ensures the independence of parent and child context values:

def test_override_value_from_parent
    parent = AjLisp::Context.new
    parent.setValue(:foo, "bar")
    context = AjLisp::Context.new(parent)
    context.setValue(:foo, "bar2")
    assert_equal("bar2", context.getValue(:foo))
    assert_equal("bar", parent.getValue(:foo))
end

Each context can have a parent. There is a top context, defined in lib/ajlisp.rb:

module AjLisp
@context = Context.new
@context.setValue :quote, FPrimitiveQuote.instance
@context.setValue :first, PrimitiveFirst.instance
@context.setValue :rest, PrimitiveRest.instance
@context.setValue :cons, PrimitiveCons.instance
@context.setValue :list, PrimitiveList.instance
@context.setValue :lambda, FPrimitiveLambda.instance
@context.setValue :flambda, FPrimitiveFLambda.instance
@context.setValue :mlambda, FPrimitiveMLambda.instance
@context.setValue :let, FPrimitiveLet.instance
@context.setValue :define, FPrimitiveDefine.instance
@context.setValue :do, FPrimitiveDo.instance
@context.setValue :if, FPrimitiveIf.instance
@context.setValue :definef, FPrimitiveDefinef.instance
@context.setValue :definem, FPrimitiveDefinem.instance
@context.setValue :+, PrimitiveAdd.instance
@context.setValue :-, PrimitiveSubtract.instance
@context.setValue :*, PrimitiveMultiply.instance
@context.setValue :/, PrimitiveDivide.instance
def self.context
    return @context
end
# ...
end

New context are created in many primitives. At the begin, there is a top context like:

If you have a defined form that returns the second element of a list:

(define second (a) (first (rest a)))

now you have a top context with the new slot:

The top context has a new slot named second with a lambda value (lambda (a) (first (rest a))

When you invoke:

(second (quote (one two three)))

during the invocation a new context is created, its parent set to the top context, and having a new name/value pair:

That context is discarded after second evaluation (unless the context were referenced by recently created closure, details in upcoming post). When you define a simple value:

(define one 1)

the top context is modified, to have a new name/value pair:

Next topics: primitives and special form primitives, their invocation, closures, macros, native methods invocation.

Keep tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

December 14, 2011

AjCoRe, A Simple Content Repository (2) Stores

Filed under: .NET, AjCoRe, Content Repository, Open Source Projects — ajlopez @ 10:04 am

Previous Post

I did some advances in my open source project AjCoRe, simple implementation of a content repository written in C#:

https://github.com/ajlopez/AjCoRe

If Content Repository is a new concept to you, check my links http://delicious.com/ajlopez/contentrepository and Roy Fielding’s JSR-170 overview .

Key concepts: there are Workspaces. Each workspace has a Root Node. Each Node can have Child Nodes, and Properties. A Property has a Name and a Value:

In the above diagram, nodes and workspaces are represented by interfaces. The idea is to have different implementations of that abstractions. In my previous post, I presented two such implementations: one representing a file system, allowing only read only operations. And another implementation, a more extensible one, using arbitrary nodes in memory. Since then, I added the support of saving and retrieving those arbitrary nodes using a store.

Now, the project looks:

where:

A: It is the concrete base implementation of workspace and nodes, based in memory, with the new support of having an optional store

B: The read-only implementation of workspace and nodes, representing an existing filesystem/directory

C: The new IStore (abstract) and the first concrete implementation, using a directory hierarchy and XML files to persists nodes in a workspace

D: The transaction support, during the lifetime of a session

Let’s see the new store capabilities. The Stores.IStore interface:

public interface IStore
{
    IEnumerable<string> GetChildNames(string path);
    PropertyList LoadProperties(string path);
    void SaveProperties(string path, PropertyList properties);
    void RemoveNode(string path);
}

Stores.Xml.Store is the first concrete implementation. Anyone could write another ones, using JSON, a relational database or a NoSQL backend. You can create, remove nodes, updated their properties, using a session, in the same way as in the previous post. BUT NOW, the workspace can be created injecting an IStore implementation in its constructor. Example (more details in the tests):

// Reference store in a directory
Store store = new Store("c:\\myworkspace");
// Workspace using that store to retrieve root node and their descendant
// (lazy loading)
Workspace workspace = new Workspace(store, "myws");
// Session accesing that workspace
Session session = new Session(workspace);
// You can use session to get the root node
// in case you have no direct workspace reference
INode root = session.Workspace.RootNode;
// Updates are made into a transaction
using (var tr = session.OpenTransaction())
{
    // Accessing a node
    INode node = root.ChildNodes["father"];
    // Changing a property
    session.SetPropertyValue(node, "Name", "Adam");
    
    // Creating a nodes    
    INode newnode = session.CreateNode(node, "newson", new Property[] {
                        new Property("Name", "Abel")
                    });
    
    // Removing a node
    session.RemoveNode(newson);
    tr.Complete();
}

The tr.Complete()  is in charge of updating the XML files where the properties of nodes are saved. An example file:

<?xml version="1.0" encoding="utf-8"?>
<Properties>
  <Name>John</Name>
  <Age type="int">35</Age>
  <Male type="bool">true</Male>
  <Hired type="datetime">2000-01-01T00:00:00</Hired>
  <Height type="double">167.2</Height>
  <Salary type="decimal">120000.5</Salary>
</Properties>

The key code in Transaction.Complete:

var nodestoupdate = 
    this.operations.Where(op => !(op is RemoveNodeOperation)).Select(op => op.Node).Distinct();
var nodestodelete = 
    this.operations.Where(op => op is RemoveNodeOperation).Select(op => op.Node).Distinct();
nodestoupdate = nodestoupdate.Except(nodestodelete);
foreach (var node in nodestoupdate)
    this.store.SaveProperties(node.Path, node.Properties);
foreach (var node in nodestodelete)
    this.store.RemoveNode(node.Path);

I could improve it, taken in account that some IStore implementation could prefer update each property, instead of a full node (I think in a database store).

I want to write another IStore implementation supporting JSON (I should design how to save the original type of each property). Other pending work: retrieve a node from a workspace using its full path, or query nodes (using XPath? Hmmm… I'm still in doubt).

Keep tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

December 13, 2011

AjTalk And Javascript (Part 2) Compiling a Simple Class

Filed under: AjTalk, JavaScript, Open Source Projects, Programming Languages, Smalltalk — ajlopez @ 10:01 am

Previous Post

In this post I will explain with an example how Smalltalk code can be compiled to Javascript using AjTalk.Compiler, named ajtalkc. As usual, the code is in my repo:

http://code.google.com/p/ajtalk/

I filed out a simple Pharo class: Point. Top fragment:

Object subclass: #Point
	instanceVariableNames: 'x y'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Graphics-Primitives'!
!Point commentStamp: '<historical>' prior: 0!
I represent an x-y pair of numbers usually 
designating a location on the screen.!
!Point methodsFor: '*Polymorph-Geometry' stamp: 'gvc 10/31/2006 11:01'!
directionToLineFrom: p1 to: p2
	"Answer the direction of the line from the receiver
	position.
	< 0 => left (receiver to right)
	= => on line
	> 0 => right (receiver to left)."
	^((p2 x - p1 x) * (self y - p1 y)) -
		((self x - p1 x) * (p2 y - p1 y))! !
....

I compiled it using the ajtalkc.exe command line program (see AjTalk.Compiler console project in AjTalk solution; it has a CodeFiles folder with my fileouts):

ajtalkc CodeFiles\PharoCorePoint.st

A new file is created: Program.js. Let's explore how a class is represented in Javascript. These lines define the Point class as a Javascript function, and its class as another Javascript function:

function PointClass()
{
}
function Point()
{
}

Nothing special. The following two lines are:

Point.prototype.__class = PointClass.prototype;
Point.classPrototype = PointClass.prototype;

In this way, every instance of Point class has a variable __class that points to the singleton PointClass.prototype. And the function/”class” Point has a variable classPrototype to point to the same singleton, if it needed.

How to create a new instance of point? Using a PointClass method, in this case defining its basicNew method:

PointClass.prototype['_basicNew'] = function() { return new Point(); };

I added an underscore to avoid name collision with any Javascript common method.

Now, how to assure all instances have two instance variables? Defining them at the propotype:

Point.prototype.x = null;
Point.prototype.y = null;

And the most interesting par: how to translate a method? Let be the min method in Smalltalk:

min
	"Answer a number that is the minimum
	of the x and y of the receiver."
	^self x min: self y! !

Its translation to a method in the Point prototype:

Point.prototype['_min'] = function()
{
    var self = this;
    return send(send(self, '_x'), '_min_', [send(self, '_y')]);
};

Notice that I defined the variable self to be used in the rest of the method (specially in any Javascript closure, where this could not survive). And the use of an utility method send that takes: a target object, the name of the method to invoke, and an array with the arguments.

All this is work in progress. Now, I'm generating additional lines to use Program.js  from Node.js, but if I removed them, I could use the code at client side, from the browser. I should write different compilers for server and client sides. I plan to write a translator to Ruby, too, just as a proof of concept of the power of having an abstract model of the program to execute.

Next topics: compiler options; compiling to browser, to node; how to run in Node.js; using the generated Javascript code; utility functions, inheritance, blocks and closures.

Keep tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

December 9, 2011

Clojure: Links, News and Resources (3)

Filed under: Clojure, Java, Links, Lisp, Programming Languages, Web Development — ajlopez @ 1:43 pm

Previous Post
Next Post

More links about Clojure, this time, oriented to Web Development:

Conjure
https://github.com/macourtney/Conjure
A Rails like framework for Clojure

Building a Clojure Web application with Incanter, Compojure, and Leiningen
http://data-sorcery.org/2009/11/29/incanter-webapp/

Cascade
https://github.com/hlship/cascade/wiki/
Cascade is an action-oriented web framework written in idiomatic Clojure

Benefits of using Clojure (Lisp) in web/enterprise development
http://bitumenframework.blogspot.com/2009/09/benefits-of-using-clojure-lisp-in.html

a minimal web app
http://www.learningclojure.com/2009/09/minimal-web-app.html

Snakes on the Web
http://jacobian.org/writing/snakes-on-the-web/

sjl / newseasons
https://github.com/sjl/newseasons
A simple Clojure webapp for notifying users when new seasons of their favorite TV shows hit iTunes.

One syntax to rule them all
http://wagjo.blogspot.com/2011/07/one-syntax-to-rule-them-all.html

Hello Web : Dynamic Compojure Web Development at the REPL
http://www.learningclojure.com/2011/03/hello-web-dynamic-compojure-web.html

Clojure on Heroku with Noir and Mongo in 10 minutes
http://thecomputersarewinning.com/post/clojure-heroku-noir-mongo

ulsa / cljvaadin
https://github.com/ulsa/cljvaadin
Sample Vaadin web app using Clojure

Noir
http://www.webnoir.org/
The Clojure web framework

Deploying a Clojure web app on Heroku
http://blog.jayway.com/2011/06/13/deploying-a-clojure-web-app-on-heroku/

Tackling my first Clojure project, a Graphical HTTP Benchmarker
http://blog.andrewvc.com/tackling-my-first-jlojure-project-a-graphical

A BRIEF OVERVIEW OF THE CLOJURE WEB STACK
http://brehaut.net/blog/2011/ring_introduction

Clojure on Heroku
https://gist.github.com/1001206

dbyrne / 4clojure
https://github.com/dbyrne/4clojure/
An interactive problem website for Clojure beginners.

The Universal Server
http://vimeo.com/21825857
In this code cast I demonstrate the awasomeness of dynamic programming languages by showing how to interactively create and use a universal server, inspired by Joe Armstrong.

Reddit Clone in 10 minutes and 91 lines of Clojure
http://bestinclass.dk/index.clj/2010/02/reddit-clone-in-10-minutes-and-91-lines-of-clojure.html

Interactive Web Development with Clojure
http://charsequence.blogspot.com/2010/09/interactive-web-development-with.html

Building REST APIs for Clojure Web Applications
http://mmcgrana.github.com/2010/08/clojure-rest-api.html

Developing and Deploying a Simple Clojure Web Application
http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html

Clojure Web Development with Ring
http://mmcgrana.github.com/2010/03/clojure-web-development-ring.html

My Links
http://delicious.com/ajlopez/clojure+webdevelopment

More link about Clojure and Lisp are coming.

Keep tuned!

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

December 8, 2011

Second Sabbatical Week of the Year

Today, December 8th, is the first day of my second sabbatical week of the year. It ends on December 18th. So, I wrote down my personal backlog, list of commitments for these days. A sabbatical week is an opportunity to do some research, work and coding, beyond the common task of every day. It’s quality time employed to practice and improve. After some planning, this is the list of the technical topics to dive into (there is a list of non-tech ones, too, in Spanish):

Write code, working on:

- AjCoRe, implementing a IStore.
– AjContab, this time a .NET version.
– AjActors, based on the last AjAgents implementation.
– AjLispRb, completing primitives, macros, file parsing.

Write posts about:

- AjTalk generating AjScript (2 posts)
– Social Games (2 posts)
– AjLisp on Ruby
– AjLisp on Javascript
– Ruby Fun Day (2 posts, in Spanish)
– My day at RubyConfAr (2 posts, in Spanish)
– My day at Smalltalks 2011 (2 posts, in Spanish)
– jBPM5, Drools by JBoss (1 post)

Some of the above posts are part of a series.

Practice and Study:

- Clojure, via REPL, or simple Eclipse
– Ruby
– Python
– Web Service Security (.NET)
– Java and Maven (oops ;-)

Other:

- Assists to Ruby Buenos Aires Meetup

Most of these activities will have visible outcomes, ex. posts will be published here or in my Spanish blog, although they will probably posted during AND after the sabbatical week. The code will be published at my repos.

Keep tuned!

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

Older 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 66 other followers