Monthly Archives: April 2010

Working in AjIo: Io-Like interpreter in C#

Last year, I discovered Io programming language:


Io is a prototype-based programming language inspired by Smalltalk (all values are objects, all messages are dynamic), Self (prototype-based), NewtonScript (differential inheritance), Act1 (actors and futures for concurrency), LISP (code is a runtime inspectable/modifiable tree) and Lua (small, embeddable).

It has a simple syntax, and its features are based in functional languages, Smalltalk, Self and others. As usual, I want to write my own version, with a twist: support for native objects. That is, to implement an interpreter over a virtual machine plus class libraries. The current choices are Java or .Net.

Two weeks ago, @MartinSalias pointed me to Io, again. Then, past weekend, I started my own implementation, based only in the written specification. It will be not exactly the same language, and it is still work in progress.

The code is in my Google project AjCodeKata:

in the trunk, under AjIo folder. There is a .NET solution, with three projects:

The class library is the core, the console program can be used to interact with the interpreter, and the test project has the test I wrote during the design/coding process.

Actually, I have written the lexer, the parser, and the main languages objects, using TDD approach, as usual. You can write:

Some days ago, I implemented the assignment operators (syntax suger over setSlot, newSlot, updateSlot):

but, now, you have native .NET object support:

Next steps:

– Write more comparison operators (I only write ==)
– Native numbers (now, only ints are parsed, but other can be managed, try 1 / 6, it returns a real)
– Precedence in arithmetic operators (now 2 + 2 * 3 returns 12, instead 8)
– for, foreach, range, and more (I only write if())
– block() (I have method())
– include()
– Begin to write some Io library objects

About last point: I should decide how to implements things like:

List clone

Possible approaches:

– List as a derived object (Object clone) with its own slots, wrapping a native list
– List clone returning native ArrayList, then ArrayList type has associated “slots”
– No List, and use directly the native objects

As in AjSharp, original Io has agents and coroutines. I want to add AjSharp features (agents, goroutines, channels, queue channels, futures) to AjIo. Original Io implements agents with virtual machine “threads”: that is, it’s not using operating system threads, the virtual machine executes the many agents code, switching from one code to another during running (I guess, I don’t see the implementation code in Io). I won’t take that approach, in my first attempts.

As usual, I had fun written this stuff!

Keep tuned!

Angel “Java” Lopez

Beyond talking about Best Practices

This week, Hari Hariri (@hhariri) posted an interesting post:

Loved the show but I have toget back to the real world now

Hariri comments about his experience in two developers shows, where he gave talks. He wrote:

As usual, to set the context, I asked a series of questions regarding unit tests:

“How many of you know what a Unit Test is” – 80% put up their hand.

“How many of you do Unit Testing?” – 10% put up their hand.

“How many of you think Unit Testing is valuable?” – 80% put up their hand

The first show was for PHP developers. I guess that PHP developers used to work a bit different than other developers, at least in my times of PHP dev. Maybe, today, they have more tools to do the job. But the second show Hariri attended, was in front of 200 persons interested in software architecture.

Recently, in an internal talk in a software company, @MartinSalias asked similar questions, and the results were like Hariri’s ones. I didn’t take notes about the results, but in one of my talks, the results had the same bias: lot of people likes best practices, XP disciplines, etc… few ones were implemented them.

So, where is the problem? Hariri writes:

“A is good. I like A. I should do A. But I won’t do A”.

People identify themselves with the issues we talk about. They see the value writing automated tests and complying with design principles adds. They get excited, yet they don’t do it. Why?

I usually ask this question too, and the typical responses are:

1. Tight Schedules.

2. Decrease in Productivity. Drag and Drop is more productive

3. Customers want deliverables. Tests are not deliverables

and my all time favorite

4. “I’m paid to write code, not tests”.

Well, there are many reasons, each software developer and team have reasons to not apply TDD, automated testing, code reviews, pair programming, etc…

Let take one topic: TDD. Why people are not using TDD more in daily work? My guess:

– They know what is TDD, but they never practice it, they have many doubts

– If they work in a team, not all members knows about TDD, and the TDD-aware person didn’t practice or master TDD.

What they need? I think they need three points:

– Know the rationale behind TDD (they grasp this point in talks, articles, conference, books…)

– Practice TDD

– Have a mentor to ask questions, resolve doubts

I resolved the second point working in my personal projects. And the third one, asking coworkers, using web forums, reading examples, more books, reviewing open source code project, and I still working in the above three points. But I guess not all software developer has the available time and will to improve their skills in the same way. I push for a “self-learn” software developer, but the reality is, not everyone has the time to take that way. And it is a way with risks: you are on your own, and if you don’t have a dedicated mentor, it’s difficult to learn all the topics you need to cover in order to be proficient in TDD or in another best practice.

I’m working with Hogwarts Project team, to resolve such points: give people the support to learn TDD, IoC, SOLID principles, and more. Not only example, but rationale. Not only theory, but practice. Not only practice, but evaluation and post-support. In our case, the end customer bought the best practices idea: we have not needed to convince management of the advantages of best practices. We are in the early stage of the project: first deliverables are beta ones, and only internally distributed. But I hope that when the project gains more moment, more material and gained experience will be published and shared with the community.

Keep tuned!

Angel “Java” Lopez

Twitter as the Ultimate Service Bus for Applications

I want to describe a proposal about using Twitter from applications. I guess this idea is not new, and that there are some real implementations in twittersphere. My point is to describe something simple and extensible.

Suppose you want to operate in a virtual marketplace. Actually, you are going to a website, enter your offer, wait for replies. An alternative method could be to use a Twitter account to send offer messages.

Something like this:

Every other application could read the feed from @ajmarket and then take action: response, make a counteroffer, publish it in a website, do market analysis, etc.

I propose a message format:

If you need to send more information, you can add links to data (possibly in JSON format, ok, it could be XML, but I prefer JSON):

Each application should define the valid verbs and arguments. The application that reads the messages (or write new ones) can be distributed, no need to have a entry point, in a URL. Twitter account is the more flexible entry point for such kind of applications.

Imagine you can build anything that involves many applications sending messages to possible many applications.

Even more: each application twitter account could be viewed as an agent. If you need to plan a trip, an “intelligent” application could be listen on Twitter, and take conversations with other Twitter agents to resolve your plan or problem.

The underlying application could run in Azure, Amazon, your own center. You can switch or support other message transport, Yammer instead of Twitter, or anything alike in the future.

Abstract: use Twitter as a pubsub channel, with a simple but flexible message format.

It should be something like this out there.

Keep tuned!

Angel “Java” Lopez

Microsoft moving to open source

In an unexpected decision, Microsoft has decided today to take a great turn in its direction. According to an upcoming press release, the software giant will be open source its core applications, including Excel, Word, full Office, Visual Studio, Sharepoint, SaaS servers, Windows Operating Systems and an old Multiplan version.

Apparently, the move was undergoing since last century. Gates retirement two years ago was only a preparation for this great move, impulsed internally by Steve Ballmer himself. Top executives have twittered messages to top open source developers, like @migueldeicaza, @ayende and others, to add them to its staff in the next days.

But this is only the top of the iceberg. More news will be announced:

– Entity Framework development dropped, replaced by NHibernate trunk

– Linq will be donated to Oracle, to be added to Java

– Web Service stack will be erased completly, replaced by REST, Json serialization, and Javascript code.

– JQuery will be added as scripting language to Excel

– Silverlight application will be compiled to Javascript, using some Google implementaiton

– The design and development process will be directed by something like JSR (Java Specification Requests), hearing the community voices

– Bing site will redirect to Google main page, automatically

– Future income will be based on book selling, and AdSense advertising in the MSDN pages.

The formal news will be twittered today, including links to main SVN addresses, located at Google Code.

MS don’t open source Biztalk and Dynamics CRM, because lack of interest of the three (3) users in the world that are still using that software.

Angel "Java” Lopez