self halt

November 13, 2009

soek.goodies.st – exploring open-source Smalltalk libraries

Filed under: Smalltalk, coding4fun, s3 — Ernest Micklei @ 9:48 pm
Tags: , , , ,

Soek is a Smalltalk application that provides a different way to navigate through documentation and source code of a Smalltalk library. Instead of the classic multi-list browser view in an image, Soek offers a flat view on all methods and classes and is build using the Seaside Web framework.

Soek documenting Seaside

I discovered this way of publishing a framework when I worked with Rails and did most of my searches on Railsbrain.com. Not only I could easily find a particular class or method, it also showed me similar methods, other implementations, classes and their sources. The learning effect was great and it became my standard search tool and recommendation to others.

Wanting this for the Smalltalk community too, I started creating the application Soek in Cincom WebVelocity to have a similar view on libraries such as Seaside, Glorp, Cloudfork and even my own projects. I figured out how to parse the comment, declaration and body of a method, defined new syntax highlighting rules for Smalltalk and integrated the client-side search javascript functions from RailsBrian.com, kindly provided by Brian Chamberlain.

Because most libraries that I use are pretty stable, those documentation pages can very well be cached. So to make this happen, I developed a Publisher component that can generate all static pages to files creating a documentation set for each library. Next, I created a public Amazon S3 bucket to host all these documentation sets. Finally, I added a Launcher application as the front-end for this bucket to select which library documentation to explore. Available library information (name,version, s3-url,site-url) is accessed from a Amazon SimpleDB domain using Cloudfork ActiveItem.

The result is now available at soek.goodies.st

The Soek application is made open-source under MIT license and published in the Cincom WebVelocity Community.

Update: Current version fails to work in IE (6+). Use any of Firefox, Safari, Chrome instead for the time being.

February 26, 2009

Tooling available for VAStGoodies

Filed under: Open source projects, Smalltalk, coding4fun — Ernest Micklei @ 10:18 am
Tags: , ,

Early this year,  Adriaan van Os announced VAStGoodies.com that wants to be the open source software repository for the VA Smalltalk community. To promote this great initiative, I proposed to create some tools that allow you to contribute to VAStGoodies.com directly from your Smalltalk image. Initially, it includes an editor to edit project annotations and an uploader that takes a versioned ConfigurationMap to publish it. Future versions will enable you to download new and updated versions of projects directly into your repository.

Edit Project Annotations

Using Annotations, you can provide information related to the applications/maps that you are going to publish. This information will be stored as Envy fields in your own repository so entering is only required the first time you publish. The license type is a required field. You can use Wiki syntax for writing a description. Currently, VAStGoodies supports annotations for Users and Configuration Maps.

vastgoodies_editannotations

Publishing to VAStGoodies.com

In the Configuration Maps Browser you can select a version of your Map to publish. You will see two menu items related to VAStGoodies. The “Publish” action will check your licence type and ask to confirm the upload.

publish_menu

Installing the tools

Download the configuration map “VAStGoodies.com Tools” from VAStGoodies.com. Before loading this into your image, make sure you have loaded the SstHttpCommunications applications. As always, suggestions for improvements are welcome.

May 23, 2008

Ring Benchmark – my first concurrent Erlang

Filed under: coding4fun, erlang — Ernest Micklei @ 10:47 pm
Tags: ,

Following the advice of Dave Thomas who said: “any developer should learn a new language every year” on RailsConf 2007 in Berlin, I decided that Erlang was going to be my challenge for 2008. However, the first months of 2008 passed without any Erlang until I listened to Joe Armstrong himself at Qcon in London. His talk was inspiring to me so right afterwards I bought his book and start reading it on my flight home.

After working myself through the first chapters, I finally got to the part that explained concurrent programming. In his book, he invites the reader to create an Erlang program that implements the Ring Benchmark. So I did and here is my version.

Problem:

Create N processes in a ring. Send a message round the ring M times so that a total of N * M messages get sent. Time how long this takes for different values of N and M.

Solution:


-module(ring_benchmark).
-export([start/2]).
%
% Create a ring of N processes through which a message is send M times.
% First, create a chain of processes: First,...,Last
% Then send a composed message to the first process containing:
% - throw, the type of request
% - the message (payload)
% - the process id of the last created process of the ring
% - number of times the message must be thrown through the ring.
%
% @author Ernest Micklei, PhilemonWorks.com, May 2008
%
start(N,M) ->
	First = spawn(fun() -> receive_send(void) end),
	io:format("Created ~p~n",[First]),
	Last = connect(First,N-1),
	io:format("~p will send messages to ~p~n", [First,Last]),
	First ! {throw,ball,Last,M},
	done.
%
% Create a new process that will send messages to the process with ID = To
% Repeat this Count times, forming a chain (not a ring!) of processes.
% Return the process ID of the last created process.
%
connect(To,Count) ->
	Next = spawn(fun() -> receive_send(To) end),
	io:format("Created ~p~n",[Next]),
	io:format("~p will send messages to ~p~n", [Next,To]),
 	case (Count =:= 1) of
		true -> Next;
		false -> connect(Next,Count-1)
	end.
%
% Each process will exectue this in a loop.
% To is the process ID of the next process in the ring.
% If a throw request is received then send it to the ring.
% When the message is received, throw it again if the count > 0
% Else, send a die request to kill all processes of the ring.
%
receive_send(To) ->
	receive
		{Message,Ring,Count} ->
			case (To =:= void) of
				true ->
					io:format("~p received ~p (~p)~n",[self(),Message,Count]),
					case (Count =:= 0) of
						true ->
							{_,TimeAfter} = statistics(runtime),
							io:format("Completed in ~p [ms]~n",[TimeAfter]),
							Ring ! die;
						false ->
							Ring ! {Message,Ring,Count-1}
					end,
					receive_send(void);
				false ->
					io:format("~p received ~p (~p), sending it to: ~p~n",
						[self(),Message,Count,To]),
					To ! {Message,Ring,Count},
					receive_send(To)
			end;
		{throw,Message,Ring,Count} ->
			io:format("start throwing ~p ~p times through ring starting at: ~p~n",
				[Message,Count,Ring]),
			statistics(runtime),
			Ring ! {Message,Ring,Count},
			receive_send(To);
		die ->
			io:format("~p died~n",[self()]),
			case (To =:= void) of
				true -> void;
				false -> To ! die
			end
	end.


Download source

If you are interested in numbers, N=10.000, M=10.000 on my Mac Book Pro took 101.290 milliseconds (runtime). I might update this post later after doing some more tests with different parameter sets.

Blog at WordPress.com.