"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.

Search This Blog

Saturday, September 22, 2007

Erlinguistics: Counting with a Functional Accumulator

Tim Bray though Erlang weird, which it is, but he's pushing on with it, which is fun and educational, hopefully, for everyone following along.

Tail recursion is really a glorified goto statement, and after a while it starts to feel like an elaborate fake-recursive lie.
Once this style is adopted though, solutions tend use less code and become more tractable. At least code comes out more factored and there's less of it in one place. i.e. you know those long stretches of looping code that can last for a couple of screenfuls? You tend not to find those in code written in a functional style. Assignments don't change the state of a variable 17 lines into a 49-line iteration. So in a sense there is no "lying" in a recursive function, but sometimes some unwinding is needed to get a sense of what's happening.

On counting...

I thought of two ways to count things. Every Erlang process has a process dictionary, i.e. a hashtable or content-addressable store or whatever, with get() and put() calls. This is the kind of thing that the Ruby code above depends on; the square brackets are a dictionary lookup. The problem is, Joe Armstrong severely disses the use of the dictionary... [Tim's analogy elided]

There’s also a hashtable package called ets, of which Joe expresses less disapproval.

Another way to count things, which I suspect would make Erlinguists happier, is to spawn a process for each thing you need to count

Yes, using a process to maintain changeable state is generally a good thing. Think of each such process as a "little database" and a "little messaging protocol" for accessing that database. Counting and inspecting the count would be the degenerate example. This approach usually would be reserved for more complicated kinds of "little databases".

More preferable in this simple counting situation might be to include one or more "accumulators" in the recursive function. Instead of passing around a Counter process id, the actual "count" could be passed around. For example, the original "morse codes in erlang" uses an accumulator that is not a count, but it is an accumulator of a list of results. As the results are accumulated, those results are passed around until the recursion is terminated, and then those results are returned as, well, the results.

A simpler counter kind of accumulator could look like the code below, which is close enough to Tim's original example. I'm not sure what his process_match is doing, but in this case, handle_match is playing that part, and here simply printing information about the match. The count is maintained in the Count "accumulator" which is passed around with the recursion. The top-level function "seeds" the accumulator with 0.

-module(foo).
-export([count_matches/2]).

-import(file, [open/2]).
-import(io, [format/2, get_line/2]).
-import(regexp, [match/2]).

count_matches(Filename, Pattern) ->
  {ok, In} = open(Filename, read),
  count_matches(In, get_line(In, ""), Pattern, 0).

count_matches(_In, eof, _Pattern, Count) ->
  Count;
count_matches(In, Line, Pattern, Count) ->
  case match(Line, Pattern) of
    {match, Start, Length} ->
      handle_match(Line, Start, Length),
      count_matches(In, get_line(In, ""), Pattern, Count + 1);
    nomatch ->
      count_matches(In, get_line(In, ""), Pattern, Count)
  end.

handle_match(Line, Start, Length) ->
  format("Found a match in ~s from ~w for ~w~n", [Line, Start, Length]).
Taking this approach to its limits results in functions like lists:foldl and lists:foldr which "fold" some value over a list of elements, starting from the left or the right of the list, respectively. It's all a variation on "map/reduce", essentially. The above code could be made more general to "fold" over the lines in a file from top to bottom for some given functional argument.

Wednesday, September 19, 2007

Atom and RelaxNG

(Update: Links now work, thanks to Sjoerd Visscher.)

I'm fairly new to the details of Atom format and brand-spanking new to the details of RelaxNG. So here's what I did, and if you have any comments, then add them here or send an email to patrickdlogan at gmail dot com. I also did not find any explicit examples like this on the internets, so this may help someone else -- it's not complex, and that makes me feel good about atom.rnc and relaxng in general.

My objective was to use relaxng to validate an atom entry where the content is inline'd xml. The validation should be for the atom stuff per se, as well as for the specific xml content. A second objective was to apply the relaxng schema for that specific xml to that content separate from the atom stuff. So the xml content should stand alone or be inline'd in an entry and one schema definition should be usable for both cases.

I grabbed atom.rnc, the compact relaxng definition for atom. I grabbed the jing validator. Applying just this schema worked. Good. Good.

Then I spent some time looking at that schema and reading through various relaxng combination mechanisms. The combination takes place at the definition of atomInlineOtherContent in atom.rnc. This is where the inline'd xml content goes.

An interleaved combination did not work, as I found out, because that definition as well as the definition of my own xml includes "text", which causes relaxng trouble. Although I don't fully understand why this should cause trouble if my schema is more specific.

The combination mechanism that did work is to redefine atomInlineOtherContent in my own schema...

namespace atom = "http://www.w3.org/2005/Atom"

# Usage:
# java -jar jing.jar -c atom_policy.rnc example_insurance.atom

# Note: this includes an unmodified atom.rnc grammar from the ietf
# standard. This grammar here redefines the inline content pattern to
# specify that such content should include appropriate attributes from
# the atom spec, e.g. type="application/xml", but the content itself
# should be a  tree of elements.

include "policy.rnc"

include "atom.rnc"
{
  atomInlineOtherContent =
     element atom:content {
        atomCommonAttributes,
        attribute type { atomMediaType }?,
        amitPolicy
     }
}
This looks just like the original definition except the actual content has to match the definition of amitPolicy as defined in policy.rnc. (I should probably redefine the attributes to require a specific type of "application/xml" or something, but this is close enough for now.)

The example entry with policy content validates using this more specific grammar. More goodness.

I met the second objective with just a little bit of cruft. I'd like to use policy.rnc to validate just some xml that starts with amitPolicy and has no atom elements at all.

I could not apply policy.rnc directly because I'd have to add a "start" to that grammar, which then gets the validator bogged down when using that grammar with atom, two starting points, not combined correctly.

Instead I wrote another small schema to define the starting point for a standalone policy...

include "policy.rnc"

# This currently exists to support validating policy xml content
# without being part of an atom entry. There may be another way to
# avoid having this separate little grammar.

start = amitPolicy
There may be another way to do this without defining another schema like this.

Tuesday, September 18, 2007

Erlang Interview

André Pang was interviewed at builder.au re: Erlang...

Our very first server was written in C++, but we realised that we had a problem if the server crashes. There might be 20 VFX houses connected to this server, and when it goes down, they all go down with it. So we looked at using an Erlang server, by writing custom plug-ins to ejabberd, which is a popular XMPP (Extensible Messaging and Presence Protocol) platform -- so we layered all of our code above that.

In the end we found that to be a good solution, in fact the only time I can remember it crashing is when we forgot to allocate swap space for the server and it ran out of memory. Due to the way you can set up ejabberd and Erlang in general is that it really suits a distributed system without a single point of failure. It makes it easy to set up different nodes which all replicate as each other, for instance, there were plenty of times when the primary server went down, but users were automatically connected to the secondary server instead. With a bit of smarts in the client it was possible to reconnect to a secondary server in the middle of the session and only lose a small amount of information in the process.

We had three or four servers around the world, and it was incredibly cheap to deploy, because with the Erlang runtime you don't need any special hardware or anything. It was very reliable and turned out to be a very good decision.

Sunday, September 16, 2007

AMQP, XMPP

Stefan Tilkov suggests...

Personally, I see AMQP on the one side and AtomPub/XMPP on the other side of a fence — AMQP internally, addressing the same problem domain as current, proprietary queueing solutions, and AtomPub and XMPP over the Internet.
I'd like to understand more about his reasoning.

What would be the drivers for this dichotomy? Why are two different messaging systems necessary? What would limit AMQP from being used on the internet scale? What would limit XMPP from being used on the intranet scale?

Without some reasoning behind this dichotomy, it just feels to much like the old WS-* on the intranet, HTTP on the internet. I don't recall seeing a sufficient rationale for that.

Now it seems fairly clear that HTTP fits well on both scales, no?

So is HTTP sufficient for all kinds of "message transfer"? HTTP and XMPP? HTTP, XMPP, and AMQP? Or... how many kinds of messaging are enough?

As an aside, our viking friend suggests Apache can go beyond the traditional as well. I think we have a lot to learn still about how simple the enterprise can eventually be.

Emacs Tag Magic

Tim Bray on programming in C using Emacs...

I’ve been using Emacs, and I seem to recall that it has all sorts of navigation magic.
That would be the "tags" mechanism. Tags work with non-emacs tools as well, but emacs is especially good with them. See the manual.

Tag databases can be created for all kinds of languages.

Those IDE's still have *nothing* on emacs. :-D

Nuke-you-lair

On nuke-you-lair power...

How effective is long term storage of nuclear waste? Stewart's answer was typically provocative. As I recall it, he said something like this: "We don't know, but our framing of the question shows a failure of long term thinking. We've all been imagining that we have to solve the nuclear waste problem for all time to come. In fact, we only have to solve it for a few hundred years. Either by then technology will have advanced sufficiently that it will no longer be a problem, or we will have regressed so far that a few nuclear waste dumps in out of the way places will be the least of our worries."
In other words, we're screwed. Welcome to your post-apocalyptic future.

Saturday, September 15, 2007

Sweet Linux Air

From the RIA Cowboy himself. Yeehaw. While we're waiting for Air to be officially available on Linux...

*** WARNING - THIS IS TOTALLY UNSUPPORTED, UNENDORSED, AND A COMPLETE HACK ***

...

All I need is ADL - the testing tool for AIR applications. So I gave it a try on a Salesforce.com project I’m working on:

jamesw@dos:~/projects/mavericks/examples/air/AccountTracker/bin$ wine ~/flex_sdk-3_b1/bin/adl.exe salesforceTest-app.xml
And to my total surprise the AIR application loaded and ran on Linux! Sweet!
The one component that truly needs Windows or Mac right now can run on Wine on Linux. The degree the API is mapped to the Linux environment is probably limited, but for at least some things, developers can currently use Linux for Air.

Friday, September 14, 2007

Squeak by Example

(via James Robertson)

A nice looking new book for getting started with Squeak Smalltalk, pdf is free online, or you can order it print-on-demand from lulu. They also accept donations for the pdf.

Co-authored by local Portlander Andrew Black.

The book seems comprehensive for getting started, covering the development environment (including the Monticello package tool) as well as the language, the GUI classes, "meta" classes, etc.

This is a good year to learn Smalltalk and Erlang, with two of the best programming language books ever now available for two of the most distinguished programming languages. Every programmer would be better at whatever they do by knowing a good bit about these languages.

Thursday, September 13, 2007

ONLamp: an Introduction to Erlang

From Gregory Brown at ONLamp...

I consider myself someone with a middling grasp of concurrency at best, and though I'd likely be scratching my head trying to write this in many other languages, I hacked this together in about 20 minutes with only a beginner's level of experience in Erlang. This certainly says a lot for the possibilities of the language to make parallel programming very easy.

A Scalable Distributed Data Structure for P2P

Google Tech Talk

Tuesday, September 11, 2007

Robust Composition: Unified Access and Concurrency Control

Mark S. Miller's PhD dissertation, "Robust Composition: Towards a Unified Approach to Access Control and Concurrency Control"...

When separately written programs are composed so that they may cooperate, they may instead destructively interfere in unanticipated ways. These hazards limit the scale and functionality of the software systems we can successfully compose. This dissertation presents a framework for enabling those interactions between components needed for the cooperation we intend, while minimizing the hazards of destructive interference.

Great progress on the composition problem has been made within the object paradigm, chiefly in the context of sequential, single-machine programming among benign components. We show how to extend this success to support robust composition of concurrent and potentially malicious components distributed over potentially malicious machines. We present E, a distributed, persistent, secure programming language, and CapDesk, a virus-safe desktop built in E, as embodiments of the techniques we explain.

Performance of Selective Receive

Pascal Brisset explains (on erlang-questions some time ago) a scenario where Erlang's selective receive can fall behind...

The system is dimensioned so that the CPU load is low (say 10 %). Now at some point in time, the backend service takes one second longer than usual to process one particular request. You'd expect that some requests will be delayed (by no more than one second) and that quality of service will return to normal within two seconds, since there is so much spare capacity.

Instead, the following can happen: During the one second outage, requests accumulate in the message queue of the server process. Subsequent gen_server calls take more CPU time than usual because they have to scan the whole message queue to extract replies. As a result, more messages accumulate, and so on.

snowball.erl (attached) simulates all this. It slowly increases the CPU load to 10 %. Then it pauses the backend for one second, and you can see the load rise to 100 % and remain there, although the throughput has fallen dramatically.

Here are several ways to avoid this scenario...

...

Add a proxy process dedicated to buffering requests from clients and making sure the message queue of the server remains small. This was suggested to me at the erlounge. It is probably the best solution, but it complicates process naming and supervision. And programmers just shouldn't have to wonder whether each server needs a proxy or not.

I'm not sure how it really complicates naming and supervision so much. I think it is the best solution. The problem is not in selective receive, per se, which has a lot of benefits that outweigh this specific scenario. Especially wrong would be to gum up the Erlang language and simple message passing mechanisms just for this.

The problem in this scenario is *coupling* too closely the asynchronous selective receive with the backend synchronous service. This is not an uncommon scenario in all kinds of "service-oriented architectures" and the solution, generally, should be the one quoted above.

A programmer should legitimately wonder whether some kind of a "proxy" is needed when they see this kind of a combination.

This is related to the blogs going round not so long ago among fuzzy, Bill de hÓra, Dan Creswell, and others.

Receptionists for Shared Resources

Carl Hewitt, et al.'s Linguistic Support of Receptionists for Shared Resources (MIT AI Memo 781 -- pdf).

exmpp

Back in December, Mickaël Rémond wrote on the erlang-questions list...

Jabberlang for now rely on ejabberd. You need ejabberd to use it. The shared object you are mentionning comes from ejabberd. That said Jabberlang is a client library that rely on a server implementation which seems strange. That's why we are currently doing some code refactoring. Our target is to have:
  • exmpp: A common XMPP library that is used by ejabberd and Jabberlang
  • Jabberlang: Relying on exmpp.
  • ejabberd: Relying on exmpp.
We are in the middle of this refactoring currently.
Recently, elsewhere, he updated:
Jabberlang will be replaced soon by a much better and easier to use library called exmpp. Stay tuned. It will be published here: http://www.process-one.net/

The Killer App for Multi-Node

From Many Core Era, the question: what's the killer app for many-core?

The true "many core" era will have arrived when we realize this is the wrong question.

By the time we get to a significant number of cores we shouldn't care much about cores any longer.

Monday, September 10, 2007

So You Flip The Common Torch Around

This google tech talk by Van Jacobson on networking is great.

Fun game: the video has closed captions in english. Watch for the phrase around 28 min. into it, where the captions that reads "so you flip the common torch around" and catch what Jacobson actually says. (Answer below.)

Was the caption written by a human or a machine? Was it proofed and edited?

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Answer: "so you flip the combinatorics around"

On The Web

Douglas Crockford at the Rich Web Experience conference...

AJAX applications are highly interactive, highly social, easy to use, and offer great network efficiency, according to Crockford. "The big problem is that it is too damn hard to write these apps," he said.

"The most interesting innovation in software development in 20 years has got to be the mashup," which shows the benefits of distributed programming. "Unfortunately, mashups are insecure [in the browser]," said Crockford, with components unable to be protected from each other.

The model in the browser is fully broken and needs to be fixed, he said. "The Web is an exploit waiting to happen," Crockford said.

Crockford then went through a critique of various Web technologies.

"[JavaScript is a] deeply flawed language," with an unpopular programming model. "But to its credit, it's working really, really well in an environment where Java failed," said Crockford.

The planned JavaScript 2 upgrade also has problems. "It will make the language considerably more complicated," Crockford said.

Good so far, but then...
If the Web is unable to repair itself, it could be replaced with a proprietary system such as Microsoft's Silverlight or Adobe's AIR (Adobe Integrated Runtime), Crockford said. Proprietary systems do present advantages, such as having only one source of new bugs and presenting a simpler upgrade story. But people like open systems and are suspicious of proprietary systems, he said.
Em, AIR is like any other programming language and framework -- it can be used "on the web" or it can be used to route around the web. We need better ways than the browser to be "on the web" but we certainly don't need to route around the web per se.

The modern-day web browser is not the only client that can be "on the web". Look at blogging tools like Bottomfeeder. BF is a great example of an end-user application that is (1) not based in a popular web browser like IE or FF, and yet (2) is "on the web".

On the Road...

We were all delighted, we all realized we were leaving confusion and nonsense behind and performing our one noble function of the time, move.

List Comprehensions

Merlyn Albery-Speyer rewrote my morse code example using erlang's list comprehensions. It's posted on the pdx.erl site. Here I have reproduced it but I'm using the same variable names from my earlier example to make the comparison easier on the eye.

It's doing essentially the same thing in fewer lines of code because the list comprehension syntax is so concise. Not that the previous example was so long in the first place, but coming from an older Lisp world where we wrote out our recursions in "long form" ;-/, I need to remember to keep list comprehensions in my toolkit.

-module(lcmorse).
-export([codes/0, decode/1]).

-import(lists, [prefix/2, reverse/1]).
-import(string, [len/1, substr/2]).


codes() -> 
  [{$A, ".-"},   {$B, "-..."}, {$C, "-.-."}, {$D, "-.."},  {$E, "."}, 
   {$F, "..-."}, {$G, "--."},  {$H, "...."}, {$I, ".."},   {$J, ".---"}, 
   {$K, "-.-"},  {$L, ".-.."}, {$M, "--"},   {$N, "-."},   {$O, "---"}, 
   {$P, ".--."}, {$Q, "--.-"}, {$R, ".-."},  {$S, "..."},  {$T, "-"}, 
   {$U, "..-"},  {$V, "...-"}, {$W, ".--"},  {$X, "-..-"}, {$Y, "-.--"}, 
   {$Z, "--.."}].

decode("") -> [""];
decode(String) ->
  [[Char | Rest] ||
    {Char, Code} <- codes(),
    prefix(Code, String),
    Rest <- decode(substr(String, 1 + len(Code)))].

Saturday, September 08, 2007

Things from Phil Windley

Things from Phil Windley... Longtails and Software... User Centric Identity.

Morse Codes in Erlang

The portland erlang group is considering some of the ruby quizzes to dive into erlang. If you're not used to programming recursively, you'll probably want to start with simpler problems like implementing the member function, factorial, or count to determine the number of occurrences of some element in a list. When those are comfortable, then the ruby quizzes might be a good challenge.

Here's a sequential, recursive solution in erlang to ruby quiz #121: morse code. It's not *tail* recursive so it could maybe blow out some stack given a really long morse code word. (I assume morse code is translated one word at a time, with spaces between words.)

A tail recursive implementation... hmm... would be a bit more complicated. The two "stacks" are the dots and dashes yet to be decoded and the codes to be considered with each undecoded substring. So one way would be to manage the stacks explicitly in one recursive "loop". Another way would be to use continuation passing style.

Here's (I think) a fairly straight-forward recursive style, morse.erl...

-module(morse).
-export([codes/0, decode/1]).

-import(lists, [prefix/2, reverse/1]).
-import(string, [len/1, substr/2]).

%% http://www.rubyquiz.com/quiz121.html
%%
%% decode/1 when given a string of dots and dashes returns a list of
%% all possible decodings using morse code.
%%
%% Examples:
%%
%% morse:decode(".-").
%% ["ET","A"]
%%
%% lists:member("SOFIA", morse:decode("...---..-....-")).
%% true
%%
%% lists:member("SOPHIA", morse:decode("...---..-....-")).
%% false
%%
%% lists:member("EUGENIA", morse:decode("...---..-....-")).
%% true
%%
%% length(morse:decode("...---..-....-")).
%% 5104

codes() -> 
  [{$A, ".-"},   {$B, "-..."}, {$C, "-.-."}, {$D, "-.."},  {$E, "."}, 
   {$F, "..-."}, {$G, "--."},  {$H, "...."}, {$I, ".."},   {$J, ".---"}, 
   {$K, "-.-"},  {$L, ".-.."}, {$M, "--"},   {$N, "-."},   {$O, "---"}, 
   {$P, ".--."}, {$Q, "--.-"}, {$R, ".-."},  {$S, "..."},  {$T, "-"}, 
   {$U, "..-"},  {$V, "...-"}, {$W, ".--"},  {$X, "-..-"}, {$Y, "-.--"}, 
   {$Z, "--.."}].

decode("") ->
  [];
decode(String) when is_list(String) ->
  decode(String, "", [], codes()).

decode("", "", Results, _Codes) ->
  Results;
decode("", PartialDecoding, Results, _Codes) ->
  [reverse(PartialDecoding) | Results];
decode(_String, _PartialDecoding, Results, []) ->
  Results;
decode(String, PartialDecoding, Results, [{Char, Code} | Rest]) ->
  MoreResults =
    case prefix(Code, String) of
      true ->
        decode(substr(String, 1 + len(Code)), [Char | PartialDecoding], Results, codes());
      false ->
        Results
    end,
  decode(String, PartialDecoding, MoreResults, Rest).

Friday, September 07, 2007

Secure Enterprise-grade Persistent Group Chat

Also from Todd Bishop... Microsoft buys MindAlign...

MindAlign is a secure enterprise-grade persistent group chat solution.
Oh, dear. Is there any reason a large organization would not want to base its future messaging capabilities on XMPP?

But I had similar thoughts about email, and yet there's Exchange. One difference may be, though, with email and Exchange, Microsoft got in before email could become much of a platform for messaging applications. I would imagine over the last 10 years there's been little venture money for email-based platforms.

The same is probably not true for "instant messaging". What do you think? Am I just being ignorant in my recollection and/or prognostications?

Just a Router

Via Todd Bishop on Microsoft's Seattle-area buses running Linux-based wi-fi...

"Obviously this could be a sensitive issue for an operating system company like Microsoft," Polson said of the Linux issue, "but it's just a router, and that happens to be the operating system."
Just a router. Problem is for an operating system company like Microsoft, the operating system is disappearing as quick as it can. No one cares, nor should they.

Before long no one will care about Word, SQL-Server, or SharePoint. Excel may last a bit longer, but most people will realize they don't need 3/4 of what's in that, and there are better ways of getting at the 1/4 they do care about.

Microsoft has shown few signs of being a successful "design shop" in an age of increasingly boutique long tails running on increasingly simple, open, common foundations that have little to do with any specific piece of hardware sitting right in front of you.

I know, I know. They've got a lot of money, past success, patents, and Silverspoon. There's hope for them yet.

And they are a sponsor of the Open Router Platform project.

Parallel Jars of Formaldehyde

Phil Windley observing Parallels in action...

One of the cool features of Parallels is something they call “Smart Select.” With Smart Select you can specify which file types are handled by which application and in which OS. So for example, you can specify that Word docs are always opened in Office 2007 in Windows, regardless of which OS you click on the document. Or that clicking on a URL, regardless of which OS you’re using always opens the page in Safari on the Mac.
Little jars of formaldehyde to preserve the remains of yesterday's mammoth operating systems.

(Re)New Web

"Air will set the World on Fire."

The current browser is a terrible platform for the web. Whatever you think about Adobe's Air, per se, it will ultimately change "the browser" for the betterment of the web generally.

Wednesday, September 05, 2007

Naming and Synchronization in a Decentralized Computer System

This is David Reed's dissertation from 1978. Croquet, developed in Squeak Smalltalk, is based on this mechanism.

It's Simply Different

Sam Ruby gushes...

With many frameworks and languages, I get the feeling that I’m dealing with a metal cabinet covered by layers of marine paint; one where scratches tend to reveal sharp edges. With Erlang, I get the feeling of a Victorian mahogany armoire; one where scratches in the wood simply reveal more rich wood.
Reading erlang can be fun. Here's Sam's atom2json.erl.

When combining this kind of concurrency with an imperative language, there's typically a bit of code explosion implementing loops and iterators. The tendency also is to write long stretches of code that update variables and structures in place, even when concurrency and first class functions exist.

Erlang, being a Lisp-like language (really), instead traverses lists recursively.

Erlang, being influence by Prolog (somewhat), combines recursion with (a simpler form of) pattern matching.

List recursion, pattern matching, and simple concurrency mechanisms interact into a code implosion. Not weird at all to this Lisp programmer.

It's Already On

To Bob Warfield's point on the multicore crisis upon us already: yes, even on the desktop.

Here's an exercise -- think of your favorite or your most frustrating desktop applications. Maybe a browser, a mail reader, presentation or drawing apps. No matter which specific application comes to mind, that application almost certainly consists of long stretches of sequential code. Almost certainly a good bit of that code could be concurrent not in the sense of a parallel algorithm, but in the sense of there being no logical reason for C to follow B to follow A other than the languages used reinforce that style.

Anytime time you see an hour glass, you see an opportunity for concurrency.

I've been trying out Yahoo's beta email application. It's fine, but really cries out to be developed in a truly concurrent system. Moving more applications into an environment worse than modern desktops, let alone far from securely concurrent, is just a shame. Modern browsers are horrible platforms. We need a new browser model that is concurrent and secure. We need a new desktop that is concurrent and connected.

Both the desktop and the browser are poorly suited for upcoming many-core laptops and desktops. Not to mention five or ten years from now when we may well be deluged in so much more cheap iron looking to do something useful for us other than running bloated sequential code.

Programming shared memory threads in C# with transactional memory will not get us any closer to where we need to be. We need to think much differently with languages that support that thinking. It's only too bad we're still in the 1970s.

Tony Hoare developed monitors in the early 1970s then replaced them with concurrent message passing in the late 1970s. Then Java brought us monitors again in the mid-1990s.

Over a decade later we're still twiddling bits in critical sections stuck in a stretch of sequential code. It's ludicrous to think that's the natural human problem solving model. The tools have shaped our thinking. And I am rambling.

My Agile Failed - pause - NOT

OK, here's the deal: "agile" *cannot* fail!

Preposterous?

Here's why "agile" cannot fail: it is a set of tools that can be adapted to your needs. You may do better or worse with them. In that sense you may fail to benefit from them, or you may simply prefer not to use them. Or you may benefit from them. In either case it is you suffering or benefiting, not "agile".

If you think "agile" can fail, there is a different problem to talk about.

But "agile" cannot fail in the same way "hammer" cannot fail. (Thanks, Ed, for the analogy.)

Delaying The Inevitable

Dan Creswell on a few of the ways we developers paint ourselves into a corner...

Every time we assume we can keep all our data in a single memory or database (even if it’s a cluster) we’re embedding assumptions into our software that will be broken come the day we must partition across multiple memories or databases.

Each time we choose an algorithm that doesn’t easily partition or assumes a single memory/database we’re storing up trouble in our data and computational models.

In big monolithic systems it’s possible to create (by force) a never-fails environment which allows developers to ignore various edge cases.

Tuesday, September 04, 2007

PDX.erl

Merlyn Albery-Speyer has started a yahoo group for portlanders (and beyond, I presume) interested in erlang.

pdx.erl

The Race Is On, Or Is That Off?

Or: "I just dropped in to see what condition my condition was in."

Tim Bray ponders more cores, hardware (and software -- cannot forget the software) transactional memory as well as erlang, or some sort of erlang transmorgrigication into java or something less weird.

Ralph Johnson addressed that idea, probably accurately.

These are fascinatingly intertwined topics. Dan Creswell sent a link to me the other day: this Sun research paper on Hybrid Transactional Memory (pdf). I hope he blogs about it. He's got a good handle on the situation.

Unlike apparently many smart people at Sun, Microsoft, Intel, and elsewhere, I'm still unconvinced that transactional memory makes the overall problem any easier or better.

I do know that focusing on transactional memory is a short-term solution at best. Erlang addresses the true problem: a simple programming model that can scale out beyond SMP and yet scale down to a single core just as well.

Tim suggests transactional memory will remain well out of sight for application programmers. But these programmers need better tools, no matter how HTM affects them in the small (and eight, even 16, cores should be considered small over the next decade). The results of system programmers using transactional memory in low level SMP code is a drop in the bucket compared to today's and tomorrow's application development problems. These have little to do with a single piece of silicon and have everything to do with networks and complex concurrent collaboration among disparate subsystems.

Not so many years from now we will be awash in more, cheaper, hardware than our current application development languages and tools can reasonably accommodate. We should have a simple model for addressing all that hardware with less developer effort. We need simple languages and tools for concurrency and *distribution* so that we can waste cheap hardware in exchange for leveraging valuable developer ergs.

Today we are wasting hardware running garbage collectors in order to save developer ergs. Increasingly we need to be wasting hardware running large numbers of small processes.

Transactional memory is not even close to the support we need. I am not sure why so many people find it shiny. Maybe I'll be surprised.

Update: Some urls in comments made easier here:

Brit's got a conversation going with Tim Sweeney on transactional memory vs. message passing.

Tim's example for TM is coordinating a lot of objects quickly in a shared memory for some game scenarios. Fair enough - I am unable to compare the complexity of transactional memory vs. traditional "critical section" mechanisms for this. Off the top of my head I would agree that a shared-nothing message passing mechanism does not really address this problem, but I would imagine it still useful for other aspects of that kind of a game system. My bigger point is this: there are relatively few people with that kind of a problem. Most of us have the kinds of problems that are far better addressed by shared nothing message passing.

So what frightens me as much as the transactional memory hardware and/or software itself is the *attention* it is receiving as any sort of general solution to developing software. Is the cost worth the benefit?

Monday, September 03, 2007

Phil Windley on the Microwulf

Phil Windley on driving down the cost of Beowulf clusters...

The world's cheapest supercomputer, built by a Calvin College CS professor Joel Adams and student Tim Brom is very interesting. They built an 8 core Beowulf cluster using four motherboards and a gigabit network switch for less than $2500. The resulting machine has a price/performance ratio of $100/Gigaflop. That's just plain fun.

I think there ought to be a yearly competition of this sort for students. Who can build the fastest supercomputer for $2500?

Rob Pike on Concurrency and Message passing in Newsqueak

Rob Pike and Luca Cardelli created a simple, concurrent language called Squeak (not to be confused with Squeak Smalltalk) for simplifying programming user interfaces. Pike then turned that into Newsqueak, a more complete programming language. (See "Squinting at Power Series", (pdf)).

Newsqueak has processes like Erlang. But instead of an implicit inbox and outbox per process, Newsqueak has channels as first-class types. All channels are half-duplex, synchronous communicating, well, "channels", as in C.A.R. Hoare's Communicating Sequential Processes. Newsqueak also has only immutable data values, although it does have true variables rather than single-assignment. (Not sure yet how that interacts with concurrent processes running closures over variables lexically known to each process.)

And so Newsqueak can be used to do Erlang-like programming and vice versa, using processes/channels/functions or processes/pids/functions to implement something like the other's mechanisms.

Although Newsqueak does not have the distribution mechanisms or the failure mechanisms of Erlang. And rather than using pattern matching over all the messages in a process inbox, in Newsqueak a process might use something like one channel per pattern or encode all the possible patterns into a structured type passed over a single channel.

Russ Cox has an overview of CSP in the context of Bell Labs where Newsqueak was developed and then led to other interesting things.

Pike is now at Google and not too long ago recorded an interesting and well-done Tech Talk on Newsqueak and concurrent, message passing programming generally...

  • Define components as interfaces with all data flow and sharing done as communication over channels.
  • The interface is a type; implementations of that interface just honor the protocol.
  • Composition is linear in complexity of design but superlinear in expressibility. (The opposite of composition of state machines.) Interleaving is free. Compose interfaces, not state machines.
  • Parallelism is not the point, but falls out for free. Networking and remote execution are not the point, but also can fall out (although not quite for free).

...Concurrent processes with message passing can be a powerful model for programming, whether the problem is intrinsically parallel (server design) or not (power series)...

The expressiveness - notation - is important.

Update: Ehud linked here from Lambda the Ultimate, and that thread has several comments of its own.

Sunday, August 26, 2007

OK -- yeah, something about JAVA

When I first read the news that SUNW is changing to JAVA, I had to stop and think...

It's not April 1. What day is it? Literally I thought it was a joke.

I used Suns long before Java and imagine I will use them after Java is buried. The timing is curious when SUNW seems to be getting a good bit of non-Java press.

What do I know about these things? I'm pretty sure about this: Java isn't even the hottest thing on the JVM these days.

That's Fine

Bob Ippolito, Exploring Erlang. It's being used for MochiAds. Nice introductory slides.

Some of the Java people looking at Erlang are finding that it's not Java.

There's a reason for this. Unless you've done a fair bit of Lisp or other functional programming, you're not likely to "get" sequential Erlang in a day. Some will, others will practice then "get" it, and still others will run back to Java and pull the blanket over their heads.

That's fine. Just be aware: if you've only ever programmed with...

for (int i = 0; i < a.length; i++) ...

...then you will have to learn to think differently. There is a reason for this.

That's fine.

Thursday, August 23, 2007

US News and World Report

A good essay by Mort Zuckerman...

No one knows the true value of all that residential real estate at the base of the pyramid in which mortgages back up the collateral debt obligations that in turn back up the short-term loans that many banks and hedge funds have made to finance these CDOs. A recent review of would-be homeowners is hardly encouraging. Almost all exaggerated their incomes to win approval, and almost 60 percent inflated their incomes by more than 50 percent. Too many home loans did not require any down payment, principal repayment, or documentation...

With home prices falling rather than rising, refinancing is impossible for borrowers who fall behind. Defaults have accelerated. As one pioneer in the bundling of mortgages into marketable securities put it, "We're not really sure what the guy's income is, and...we're not sure what the house is worth."...

Many pension funds, insurance companies, hedge funds, and banks hold swaps and subprime derivatives but have not yet reported their losses, or at least not all of their losses, making it difficult to understand how big their exposure is. They are having difficulties determining the value of assets, making them impossible to sell, i.e., illiquid. The danger is that a liquidity crisis will drive financial institutions into insolvency, which could have a major impact on the economy.

The central banks have seen the threat. The European Central Bank has put up $212 billion "to assure orderly conditions in the euro money market." It's an amount so staggering that it perversely led the markets to fear that the ECB knows something that would indicate the situation is worse than it seems. The Federal Reserve similarly stated that it would provide "reserves as necessary." The concern is that the market has such anxiety about all debts, up and down the food chain, that no one will wish to buy them. Put it the other way: Fewer and fewer lenders are ready to lend. Many were going to sell high-yield bonds to finance their growth; they have had to withdraw them. In July, the issuance of these bonds dropped about 90 percent from June to a mere $2.4 billion. Even high-quality investment-grade bond offerings from companies with excellent credit fell from $109 billion in June to only $30 billion in July.

Wednesday, August 22, 2007

JSON Security

Interesting posts and comments on json and security in browsers: robubu and resig. Boils down to: "browser security pretty much sucks no matter what" and "if your json parser relies on eval(), you are a fool, no matter how fast it is".

As Patrick Mueller commented...

Approach 2 and 3 should, simply, NEVER, EVER, EVER be used. There are plenty of libraries available today to parse JSON data structures, and none of them will EVER, EVER be able to read the whacked out Approach 2 and 3 styles. EVER.

Data, baby, data!

JSON is data. There is no way any bit of it should ever be treated as code. Some day browsers will become real platforms for applications and we will laugh at all this.

That seems a long way off.

What a difference a day makes

On August 16...

William Poole, president of the St. Louis Federal Reserve Bank, told Bloomberg News in an interview that the subprime mortgage rout doesn't threaten U.S. economic growth, and only a "calamity" would justify an interest-rate cut now.
And the next day...
The Fed just issued a strange press release and a special announcement lowering the discount window borrowing rate by 50bp, to 5.75%. The more widely followed Federal Funds rate is unchanged at 5.25%...

This would be a reversal of policy from just 10 days ago.

The special announcement is the bigger news. Not only did they cut the rate, but they've increased the borrowing time to 30 days and have increased what they will accept as collateral. All importantly, they are accepting home mortgages and related assets.

Nothing to see over here. Just go on about your day. Move along.

This is fascinating stuff. Poor Ben Bernanke following in Greenspan's shoes. This from Greenspan back a few years...

Alan Greenspan was a study in contradiction. On Monday, he extolled the virtues of the levered-up homeowner to a credit union conference. The next day, in a speech to the Senate Banking Committee, he was singing a different tune altogether. Fannie Mae and Freddie Mac, the giant providers of mortgage capital, he warned, "are expanding at a pace beyond that consistent with systemic safety," and that "preventative actions are required sooner, rather than later."

For a Federal Reserve chairman who has demonstrated that he couldn't identify reckless behavior if it ran him over, it was rather surprising to hear him chide Fannie and Freddie for their recklessness.

Greenspan's latest comments reminded me of a speech he gave on March 6, 2000, which I have dubbed "An Ode to Technology." In the speech, he waxed on about the wonders of technology and how it had brought us a new era and all that other stuff. Folks may not remember that date, but it was four days before the Nasdaq Composite hit its all-time high of 5,048.62. Despite the recovery over the past year ago, the composite is still down nearly 60% from the March 2000 peak.

One-a-days

Via Steve Dekorte, mortgage lenders in August so far are failing at an average of one per day...

Again the question is raised, who will be refinancing the trillion dollars of mortgage resets over the next year?
Also...
...approximately $500 billion of adjustable rate mortgages are scheduled to reset skyward in 2007 by an average of over 200 basis points. 2008 holds even more surprises with nearly $700 billion ARMS subject to reset, nearly 3/4 of which are subprimes.
Ah, it'll blow over. ;-/

Pushy And Stuff

Dan Creswell has a nicely done discussion on that whole push/pull thing.

Rather than focus solely on either approach in isolation, I think the best solution is to use a combination. This has a couple of advantages:

  1. Clients can potentially use whichever method is more appropriate for them.
  2. It provides significant opportunity for fine tuning.
  3. It provides a nice simple recovery model.
  4. Responsibility is balanced throughout the system keeping complexity down.
For some kinds of information, just providing "pull" could be sufficient. For others, "push" may be preferred, but as Dan (and Bill, previously) explained, having that available to be pulled as well pays off.

Tuesday, August 21, 2007

Polling and/or Pushing

Dan Creswell writes in his bookmark notes (so what do I link to?)...

Polling is indeed nice and simple but it also has it's problems - how often to poll, resource consumption etc all of which the average enterprise finds offensive - probably why they'd rather do push even though it adds complexity.
Which is why I'm glad all those smart people worked on http and atom (links to the usual suspects omitted). For most cases, maybe it comes down to starting like this (related posts: Bill, Mike)...
  • Follow those specs (http, atom format, atompub) as far as they take you, i.e. when the customer can afford to obey the rules of polling, aggregating, etc.
  • When the customer has a need to know more immediately, or has a need to know many intermittent things without always knowing whom to poll, then use atom entries over xmpp.
Straying from that only under exeptional conditions.

The "Ease" Argument Again?

Dan Diephouse argues...

Making an RPC application is much easier. This is one of the killer features of SOAP/WSDL. I can take my business service and build a web service out of it with very little effort (I assert that there are non-evil ways to do this, but thats another story). I can then be interoperating with a .NET application in just a minute or two. Or I can take a WSDL, generate a set of objects, and just write some glue code between my internal objects and the web service objects.
Sigh. Again with the "ease" argument. There're enough counterarguments to the false sense of security provided by "easy tooling". Heck, I don't even see the dotnet people making that case any longer. (Admittedly, since I work with zero dotnet programmers these days, I don't have to watch those lists.)

Designing with HTTP and related standards is something everyone should be studying right now, even if they're not taking it into production. This will get easier, even with Java, and the results will pay dividends way beyond what the current IDE "tooling" provides for "easy RPC".

If not, I still may have that Word document an SAP consultant sent me, telling me how to hand-edit a WSDL to get SAP's SOAP to interoperate with other SOAPs in Java and dotnet. That may make things *easier* for you.

...and I'm done.

Monday, August 20, 2007

Our Viking Blogger

For some reason he thought he could quietly blog away in some other corner of the internets, but fuzzy found him. Our co-worker Erik has a blog. He's been working with some folks on using Flex and Rails.

Friday, August 17, 2007

Secret Sauce

Sam Ruby writes...

The “secret sauce” is pattern matching. Things like “if these conditions are met, this code fires, with the following variables set”. With Erlang, this metaphor is everywhere. Function calls are an exercise in pattern matching. Database queries are an exercise in pattern matching. Message passing is... oh, you get the idea.
I would suggest pattern matching is 1/3 of the secret sauce. The other two parts being...
  • Implicit mailbox per process with pattern-based rather than solely chronological reception.
  • Fail fast without failure coding. Function and case patterns and guards define the *success* cases. Failures to match by default result in failing the process.
I'll expand on these at some point. They are significant features not found in most popular languages, and all three combine to reinforce each other.

Shoot for Five

Sam Ruby on the future of "messaging"...

Ten years from now, we will be using SMS text messages to change the channel on the televison...

Remember all of those incompatible protocols I mentioned above? You know what happened to them?

Well, somebody had a bright idea to define an inter-networking protocol (they called it “internet” for short) that could be used as a gateway between these local area networks. Eventually, people stopped using the often proprietary LAN protocols in favor of directly connecting into the internet protocol itself.

Ain’t it funny how that worked out?

Enterprisey Edits On Wikipedia

Went to wikipedia to view the page on "Enterprisey". Got redirected to the page on "Enterprise software". Huh?

Looked at the change log for "Enterprisey". Damn. A couple of back and forths, and the current result appears to me to be rather, well, "Enterprisey". Here's what's on *that* page. At the top...

Enterprise Software is software that solves an enterprise problem (rather than a departmental problem) and usually enterprise software is written using Enterprise Software Architecture. Due to the cost of building what is often proprietary software only large organizations attempt to build software that models the entire business enterprise and is the core system of governing the enterprise and the core of business communications within the enterprise.
I'm not sure why the term "solves" is not in quotes there.

And at the bottom...

Some enterprise software vendors using the latter definition develop highly complex products that are often overkill for smaller organizations, and the application of these can be a very frustrating task. Thus, sometimes "enterprise" might be used sarcastically to mean overly complex software. The adjective "enterprisey"[citation needed] is sometimes used to make such sarcasm explicit.
Relegating the wonderful term "Enterprisey" to the bottom of a rather staid page like "Enterprise software" is just not right. But claiming that "enterprisey" merely implies "overkill" is blasphemy.

Forever, the term "Enterprisey" will mean this... (animation). As in, "It's enterprisey!"

I took a pass at editing the explanation of "enterprisey" on the "Enterprise software" page. Please take it and run with it.

I wonder who's been editing these pages. Back to the logs and do some searching.

Thursday, August 16, 2007

Dunno

Brit Butler left a good comment in a recent post...

I've watched this video and also read the slides from Sweeney's POPL presentation. Sweeney basically comes out on the side of Transaction Memory without saying much about the message passing model (though he later goes in to detail on LtU). I think TM is ugly, regardless of what Simon Peyton-Jones or Sweeney says. They're smart people but it seems like an ugly hack of a system. It is the maintenance of a style that is begging for deprecation. I'd kind of hate to see us save it. All the same, their intelligence makes me wonder if message-passing really can't scale to Sweeney's needs. What are your thoughts on where some shared state is necessary? Is that handled well in Erlang? Do Sweeney and Peyton-Jones arguments really hold weight? Is it just a "right tool for the job" kind of thing?
The best anyone can say about STM is the jury is still out. All I can say for sure is it is not my cup of tea for the systems I've been involved with over the last 25+ years, which are actually fairly wide ranging.

SPJ, et al. are *extremely* smart and capable people, far more than I am, so I have to give them some leaway, and perhaps I will be swayed toward STM for some reason currently beyond my line of sight. I admire nearly everything else about Haskell and GHC other than STM.

An irony for me, as for the "right tool for the job" argument is this:

I can see someone making the argument in some domain I don't usually work in that shared memory threads are better than shared nothing message passing for performance reasons. Some hard-real time scenario (I think I was real tired when I wrote that. Must have been thinking back to the days when I'd get into "Is automatic garbage collection practical?" debates. Nobody has those anymore, do they? Because I've got some real good arguments for GC.), some huge number crunching scenario, etc. where every byte and every cycle has to count in the extreme. But the irony then is that STM seems far more suited to a language like Haskell, which is also unlikely to be suited for these performance scenarios.

My only fear is that for the masses including myself, we need *simple* mechanisms, and the fewer of those, the better. Shared nothing messages seem to scale up, out, and down. STM seems more complicated, and an incomplete solution, and only a solution for shared memory. No thanks, at least until bigger brains than my own can show me why I should change my mind. They seem sidetracked on this one.

Good To Be The King(s)

Steve Dekorte's been tracking the credit fiasco with a number of good articles. And notes on the multi-billions of bailouts so far...

AFAICS, the net result is a transfer of wealth from the people who's dollars are devalued by the creation of money from such purchases to the lenders in the banking industry whose greed induced them to make poor decisions. The Fed was created and is run by bankers, so it shouldn't come as a surprise that it's principle purpose it to serve their interests at the expense of all others.

Andre Pang Video On Concurrent Programming And Games, Etc.

A nice video of Andre Pang on games, multi-cores, and, wait for it... erlang...

The more your computing environment resembles a game, the more cores/nodes/concurrency/networks you will need just to feed your little (shared) corner of the world.

Wednesday, August 15, 2007

The Well

From today's NYT Business Day. The papers by and large are worried about toys from China, and, oh, there is that war in the Middle East. But the most interesting story (assuming Bush is not going to call an end the war) is the credit crunch...

Turmoil in the subprime mortgage market spread again yesterday — this time to a type of short-term security held by money market mutual funds. These funds have become the investment of choice for many people seeking a safe haven...

The amount of commercial paper in the United States has grown to $2.2 trillion, according to Lehman Brothers, with about $1.2 trillion backed by residential mortgages, credit card receivables, car loans and other bonds. The major buyers include pension funds, insurance companies, hedge funds and short-term money market funds...

Until recently, the crisis in the credit markets has been limited to problems related to subprime mortgages, those given to borrowers with questionable credit histories. But as these troubles seep into other parts of the securities markets, fears of losses are rising in unexpected places...

“If the stigma of mortgage-related extendable-asset-backed commercial paper spreads to asset-backed commercial paper as a whole, you could see bailout events,” said Peter G. Crane, president of Crane Data, the publisher of a newsletter about money market mutual funds. But he added: “The stuff that the money funds are invested in are the highest quality, so it’s the last thing to have trouble.”

However, the investment strategies that once were considered conservative no longer are.

This could get a bit messier. "Bailout events".

Elsewhere in the same paper...

In a weary voice, Mr. Fanlo noted that executives from Kohlberg Kravis Roberts, including Henry Kravis and George Roberts, had been working closely with him to get through the “unprecedented” conditions the company faced.

He said he had been through numerous financial crises “and this is the most disturbing liquidity crisis, with real impact throughout the economy if it does not rectify.”...

Countrywide and most other mortgage lenders rely heavily on borrowing from banks, brokerage firms and bond investors to make loans that they quickly turn around and sell to investors through mortgage securities. In his report, Mr. Bruce said he had previously underestimated the risks to Countrywide.

“If enough financial pressure is placed on CFC or if the market loses confidence in its ability to function properly then the model can break, leading to an effective insolvency,” Mr. Bruce said in his note, referring to the company by its stock ticker symbol. “If liquidations do occur in a weak market, then it is possible for CFC to go bankrupt.”...

One analyst suggested that the market would not recover until more funds and banks detailed their exposures to mortgage securities and other debt acquired during the recent credit boom.

“The more funds that come to confession the better it is,” said Douglas M. Peta, chief market strategist at J. W. Seligman & Company. “Once all this stuff is out, all the analysts and the people with the sharp pencils can figure out how bad it is and they can put prices to it.”

Oh, right: people rushing to announce their rating is bad. We see that all the time.

Winterp

After EZDraw, another cool (weird?) GUI programming tool in the early 1990s was Winterp, an xlisp-based toolkit. Lots of weird stuff back then...

WINTERP uses a small, fast, object-oriented mini-Lisp interpreter based on XLISP-PLUS (David Betz, Tom Almy, Luke Tierney, et al), and has an object oriented interface to the OSF/Motif widget class hierarchy, and a combination of high-level object and functional interfaces to the Xtoolkit, Xlib, and underlying Unix system libraries. This environment significantly simplifies the construction of GUI-based applications, and makes these applications easier to modify and extend throughout the software life-cycle. It allows for the development of extensible applications in a safe execution environment -- errors in a new module won't destroy the whole system.

Don't Fidget With Widgets, Draw!

The best thing I came across, between MCV in the 1980s and the web in the 1990s was Joel Bartlett's Scheme library (for his fantastic Scheme->C system, oh, that was something) called EZDraw...

This report describes a graphics server, ezd, that sits between an application program and the X server and allows both existing and new programs easy access to structured graphics. Programs may draw, edit, and sense user events in terms of application-defined graphical objects. When run on workstations with 10 MIPS or faster processors, interactive response is excellent, indicating that ezd’s simple structured graphics drawing model can be widely applied. The enthusiastic response of ezd’s initial users and the variety of uses to which they have put it to suggest that there is a tremendous pent-up urge to draw with programs and that ezd has lowered the barriers to doing so.
Here's an image of an application using EZDraw to draw map graphics and display weather information from the location clicked on the map. A "mashup" in its day, I suppose...

5.3. Weather Forecasts

National Weather Service forecasts for the United States are sometimes available for network access. The ezd application shown in Figure 6 was constructed to fetch such forecasts for the contiguous 48 states. The mouse-sensitive diamonds on the map identify cities that issue forecasts. When the mouse is positioned over a diamond, text describing the region covered by the forecast is displayed. When the mouse is clicked on a diamond, the forecast is obtained via the network and displayed in the text area at the bottom of the window. The text is scrolled using the scroll bar on the left of the text. The mouse can be used to select areas of text for copying into other X applications. The radio buttons DISC, ZONE, WARN, and EXTEND select the type of forecast, the HELP push button replaces the forecast text with help text, and the QUIT push button terminates the application.

Every graphical element of this application, a 300 line Scheme program running entirely in the ezd server, is constructed using ezd. The text area, slider, check buttons, and push buttons are drawn with a library of interactors that use the basic ezd drawing capabilities. A simple ezdbased drawing tool was used to collect the 133 line segments and 50 city locations defining the the map by tracing a newspaper weather map (copied onto a transparency and taped over the display) and then positioning the cities on it.

The application graphics are automatically positioned based upon the size of the window. This is done by grouping the graphics into three drawings: one containing the map, one containing the buttons, and one containing the text area and slider. When the window is initially created or resized, the drawings are overlayed onto the window by centering the map at the top of the window, attaching the buttons to the right side of the window, and using the rest of the window below the buttons for the text area. Even though ezd does no automatic window layout, explicit layout requires only 5 ezd commands, generated by a 22 line Scheme procedure.

"National Weather Service forecasts for the United States are sometimes available for network access." How about that!

Weird Patterns

James Robertson relays someone's notion that MVC may have held back Smalltalk adoption early on. That's taking a modern perspective on a problem that did not exist back in the day.

I don't remember anyone complaining about MVC programming in Smalltalk in my circles in the mid-to-late 1980s. That was just how to program Smalltalk, and it was better than most of the other graphics libraries we had at hand on workstations. And MVC was no more weird than Flavors on Lisp Machines.

I do remember a paper by Ward Cuningham we got a hold of, marked "draft, do not circulate" (but we did, a lot). I've never found a published version of it. I've got the hard copy somewhere -- I should scan it in. Maybe Ward's got the original.

That paper explained the MVC objects with a simple, little wire list drawing application. Hmm... it's in one of two file cabinets, I'm sure.

Aaaaaanyway... the point is back then there were few if any preconceptions about anything, and not a lot of choice: mostly you built everything yourself. Only Smalltalk and Lisp had much to offer, prebuilt.

And programming in Smalltalk or Lisp was just heaven compared to when we had to drop down and do anything else. There were not many things to compare MVC *to*, in order to have any perspective that it may be "weird" or "too complicated". It just wasn't, and is still preferable to 87 percent of everything else.

Weird Jobs

Dominique Boucher on programming jobs in Montreal, but I would suppose the same is true in a handful of North American cities...

Great programmers are not looking for jobs. They already have one. And they don't want to switch from one Java job to another, unless they are dissatisfied with other aspects of their job. But a fraction of them would easily consider another job if it involved Scheme, Lisp or Erlang programming (or other non-mainstream languages like OCaml, Prolog, Haskell, etc.).

So I claim that it is easier to recruit Scheme, Lisp, or Erlang programmers, even in Montreal, than Java/C# programmers.

Programming Collective Intelligence

This new book on Programming Collective Intelligence looks really interesting. I missed the author's session at OSCON few weeks back. Here's the presentation in pdf.

Anyway...

Toby Segaran's new book, Programming Collective Intelligence, teaches algorithms and techniques for extracting meaning from data, including user data. This is the programmer's toolbox for Web 2.0. It's no longer enough to know how to build a database-backed web site. If you want to succeed, you need to know how to mine the data that users are adding, both explicitly and as a side-effect of their activity on your site.

There's been a lot written about Web 2.0 since we first coined the term in 2004, but in many ways, Toby's book is the first practical guide to programming Web 2.0 applications.

Get your map/reduce going. ;-/

Tuesday, August 14, 2007

Weird Computing in Portland

Portland, Oregon has an interesting (and forgotten?) history in concurrent computing. Remember these companies/products?

Not to mention Sequent or Intel's work here on the i432 and the more practical i960.

These were all "weird" for one reason or another back in a time when almost anything new in hardware or software could be considered weird, and almost everything *was* new. I didn't work in any of these companies (well, Intel, later) but I knew at least one person in each of them.

People used to get together at the (weird) Oregon Graduate Center or the Cedar Hills McMenamins or wherever and talk about all these things, not as being weird, just as being the things that were happening around the west side of Portland and Beaverton. The "Silicon Forest".

"Weird" stuff went on in software too. See "The Gem–Stone data management system". I worked with five of the eight authors a decade ago (almost a decade after this paper, which itself was almost a decade after the start of the company, which included several of those authors), and the really interesting thing is, I think all five are still with (one of them "back at") Gemstone.

Now *that* is weird.

ATW

True or false? The 1980s (and earlier) were far more innovative than the 2000s for computer engineering and software development.

Anyone remember the Atari Transputer Workstation?

I'm not sure if the 1980s were more innovative. But it sure seems like there were fewer "rules" back then. That only makes sense.

Funny and Informative

(via Steve Loughran)

This XML Security presentation (pdf) is funny *and* educational.

Weirdnesses

Ironic. Tim Bray chose to offer "Erlang itself? It’s too weird"...

...the same day he chose to offer...

The Methodphitamine

That’s the name of Jay Phillips’ metaprogramming model and his write-up of it... As an example of the apparently infinite richness lurking under Ruby’s hood, it’s mind-boggling and awe-inspiring.

I’m not sure I actually like it.

So is Ruby "too weird"?

I've got nothing against Ruby weirdness. Weirdness has its place. I learned several "weird" languages before I *ever* learned a "normal" curly-braced language.

Luckily. =8-D

The Amazing Gloppita Gloppita Machine

As seen in a comment on Sam Ruby's blog...

There’s still plenty of life and value in SOAP and SOA

Agreed! See, for instance, OASIS forms six committees to simplify SOA. You just don’t see that kind of forward-thinking committee-making from the REST advocates.

:-D

Maybe these six committees can come up with "A Busy Developer's Guide to At Least One Permutation of the WS-I that All Vendors Can Nearly Agree Upon, Given Three More Revs of Their Software".

Flinging It

An anonymous commentator disparages...

Why go on about shared memory? Amdahl's law is the key. Most Erlang nuthuggers haven't even heard of it, let alone understood the consequences.
I'd be interested in reading more about such erlang nuthuggers. References?

Monday, August 13, 2007

Dater

Bill de hÓra:

I think that increased data volumes will impact day to day programing work far more than multicore will. A constant theme in the work I've done in the last few years has been dealing with larger and larger datasets...

Good luck explaining to data professionals and system architects that centralised relational databases are not the right place to start anymore.

Another reason not to care so much where the "core" is as long as you got enough of them, the data close enough at hand, and a programming language to use them easily.

The Multicore Wall

An anonymous comment to my most recent thingy mentioning Erlang says...

Not everyone is buying the Erlang hype.
And the comment links to Steve Dekorte's recent post on "the multi-core wall".

Fair cautions about "Erlang hype" aside, I don't get the point. Erlang does not present a shared-memory programming model. Although Erlang can take advantage of multi-core chips, the model for using Erlang on a multi-core node is no different than for using Erlang on a *multi-node* environment with single-core, dual-core, or multi-core nodes.

Also Steve's note about tight coupling of data and code "aka object-orientation" also applies to Erlang -- an Erlang process is essentially such a coupling, and the interface to that process is the message protocol.

I think Steve's argument is right in line with Erlang. His argument goes more against the systems that have one model for intra-process and another for inter-process computing. C and pthreads, Java and its threads, even Haskell and its Software Transactional Memory fall into the category the will suffer according to Steve's argument.

In any case before a "multi-core" chip gets up to 80 cores the on-chip cache and the memory/bus architecture will have to change to something "less shared" anyway. A lot of those transistors will be taking more of a "multi-system-on-a-chip" flavor. All of which will work in Erlang's favor, or at least won't work against Erlang.

Contrary to the original article linked from Steve's, this doesn't, shouldn't, and won't be a NUMA (Non-Uniform Memory Access) architecture, at least not in the way I understand that term. NUMA defines non-uniform access to a *shared* memory, i.e. all the cores can access all the memory as if it were a single, "uniform" memory. Under the covers some memory is closer to one node than to another. Wrong model!

The "multi-system-on-a-chip" architecture will have independent caches, buses, and memories, but not present this as one shared memory. That would be ludicrous. At least to this barely-hardware-literate programmer.

Freescale, nee Motorola, is heading in that direction with multi-core Power chips with per-core backside caches and Power-based system-on-a-chip-like products with a CPU, a graphics processor, and another "media processor".

Not So Far Off Bets

Sam Ruby's "long bets" don't seem so far off considering how quickly changes are happening on the internets....

So, without further ado, here’s my long bets for the moment, with the only caveat that in some cases I pick specific implementations as exemplars of a larger field.

By the way, have you seen the erlang "slave" and "pool" libraries? These might not do entirely what you want. Good news: applicable as-is. Even better: they can be (re-)implemented in not-so-much erlang to do entirely what you want.

Maybe its time really has come.

More Gushing

From Erlang Overview

Mnesia is a nice example of the power of Erlang: in how many languages could you write a fully-featured industrial-strength distributed DBMS in less than 20,000 lines of code?

Sunday, August 12, 2007

Bits of Wisdom: HOPL III's History of Erlang

Lots of interesting bits in Joe Armstrong's HOPL III paper on the History of Erlang. The paper is available as a PDF for ACM members or others wanting to purchase just that paper. Not available outside the walled garden of the ACM, that I know of.

Anyway on to just some of the bits I appreciated.

In 1985, when I joined the Lab, SPOTS had finished and DOTS was starting. I asked my boss Bjarne D¨acker what I should do. He just said “solve Ericsson’s software problem.” This seemed to me at the time a quite reasonable request...

We were... lucky in being the first group of people in the company to get our hands on a UNIX operating system, which we ran on the VAX. What we were supposed to do was “to find better ways of programming telephony” (a laudable aim for the members of the computer science lab of a telecommunications company). This we interpreted rather liberally as “program basic telephony in every language that will run on our Unix system and compare the results.” This gave us ample opportunities to a) learn new programming languages, b) play with Unix and c) make the phones ring...

“small languages” were thought desirable:

“Large languages present many problems (in implementation, training etc) and if a small language can describe the application succinctly it will be preferable.”...

My own contribution to LOTS was to program POTS. This I did first in Smalltalk and then in Prolog. This was fairly sensible at the time, since I liberally interpreted Bjarne’s directive to “solve all of Ericsson’s software problems” as “program POTS in Smalltalk.”

(Aside: POTS is Plain Old Telephony System. LOTS is a system supporting Lots of pOTS. On to more bits...)
Erlang began to change rapidly. We now had two people working on the implementation (Robert and myself) and a large user community (three people). We would add features to the language and then try them out on our users. If the users or implementors liked the changes, they stayed in. If the users disliked the changes or if the implementation was ugly, the changes were removed. Amazingly, the fact that the language was changing under their feet almost every day didn’t particularly bother our users. We met our Bollmora users once or twice a week for about six months. We taught them programming, they taught us telephony and both sides learned a lot...

I always considered the morning coffee break to be the key forum where the brilliant ideas you had on the way to work were trashed and where all the real work was done. It was in these daily brainstormings that many a good idea was created. It’s also why nobody can quite remember who thought of what, since everybody involved in the discussions seems to remember that it was they who had the key idea...

In designing Erlang, we wanted to abstract all hardware as reactive objects. Objects should have “process semantics;” in other words, as far as the software was concerned, the only way to interact with hardware was through message passing. When you send a message to a process, there should be no way of knowing if the process was really some hardware device or just another software process. The reason for this was that in order to simplify our programming model, we wanted to model everything as processes and we wanted to communicate with all processes in a uniform manner. From this point of view we wanted software errors to be handled in exactly the same manner as hardware errors. So, for example, if a process died because of a divide by zero it would propagate an {’EXIT’,Pid,divideByZero} signal to all the processes in its link set. If it died because of a hardware error it might propagate an {’EXIT’,Pid,machineFailure} signal to its neighbors. From a programmer’s point of view, there would no difference in how these signals were handled.

The average increase in productivity was a factor of 8. This factor and the conclusion of the report were highly controversial and many theories were advanced to explain away the results. It seemed at the time that people disliked the idea that the effect could be due to having a better programming language, preferring to believe that it was due to some “smart programmer effect.” Eventually we downgraded the factor to a mere 3 because is sounded more credible than 8. The factor 3 was totally arbitrary, chosen to be sufficiently high to be impressive and sufficiently low to be believable. In any case, it was significantly greater than one, no matter how you measured and no matter how you explained the facts away...

1989 also provided us with one of our first opportunities to present Erlang to the world outside Ericsson. This was when we presented a paper at the SETSS conference in Bournemouth. This conference was interesting not so much for the paper but for the discussions we had in the meetings and for the contacts we made with people from Bellcore. It was during this conference that we realised that the work we were doing on Erlang was very different from a lot of mainstream work in telecommunications programming. Our major concern at the time was with detecting and recovering from errors. I remember Mike, Robert and I having great fun asking the same question over and over again: “what happens if it fails?”— the answer we got was almost always a variant on “our model assumes no failures.”We seemed to be the only people in the world designing a system that could recover from software failures...

I started writing the emulator myself in C but soon Mike interfered and started making rude comments about my code. I hadn’t written much C before and my idea of writing C was to close my eyes and pretend it was FORTRAN. Mike soon took over the emulator, threw away all my code and started again. Now the Erlang implementor group had expanded to three, Mike, Robert and myself. Mike wrote the inner loop of the emulator very carefully, since he cared about the efficiency of the critical opcodes used for concurrent operations. He would compile the emulator, then stare at the generated assembler code, then change the code compile again, and stare at the code until he was happy. I remember him working for several days to get message sending just right. When the generated code got down to six instructions he gave up...

The AXD301 was a spectacular success. As of 2001, it had 1.13 million lines of Erlang code contained in 2248 modules. If we conservatively estimate that one line of Erlang would correspond to say five lines of C, this corresponds to a C system with over six million lines of code. As regards reliability, the AXD301 has an observed nine-nines reliability —and a four-fold increase in productivity was observed for the development process...

Just when we thought everything was going well, in 1998, Erlang was banned within Ericsson Radio AB (ERA) for new product development. This ban was the second most significant event in the history of Erlang: It led indirectly to Open Source Erlang and was the main reason why Erlang started spreading outside Ericsson...

...projects that were already using Erlang were allowed to continue but had to make a plan as to how dependence upon Erlang could be eliminated. Although the ban was only within ERA, the damage was done. The ban was supported by the Ericsson technical directorate and flying the Erlang flag was thereafter not favored by middle management...

Since we had spent the last ten years designing and building fault-tolerant telecoms devices, we turned our attention to Internet devices, and our first product was a fault-tolerant e-mail server called the mail robustifier. Architecturally this device has all the characteristics of a switching system: large numbers of connections, fault-tolerant service, ability to remove and add nodes with no loss of service. Given that the Bluetail system was programmed by most of the people who had designed and implemented the Erlang and OTP systems, the project was rapidly completed and had sold its first system within six months of the formation of the company...

The plans within Ericsson to wean existing projects off Erlang did not materialise and Erlang is slowly winning ground due to a form of software Darwinism. Erlang projects are being delivered on time and within budget, and the managers of the Erlang projects are reluctant to make any changes to functioning and tested software.

The usual survival strategy within Ericsson during this time period was to call Erlang something else. Erlang had been banned but OTP hadn’t. So for a while no new projects using Erlang were started, but it was OK to use OTP. Then questions about OTP were asked: “Isn’t OTP just a load of Erlang libraries?”—and so it became “Engine,” and so on.

After 2002 some of the surviving Bluetail members who moved to Nortel left and started a number of 2nd-generation companies, including Tail-F, Kreditor and Synapse. All are based in the Stockholm region and are thriving.

Outside Sweden the spread of Erlang has been equally exciting. In the UK, an ex-student of mine started Erlang Consulting, which hires out Erlang consultants to industry. In France, Processone makes web stress-testing equipment and instant-messaging solutions. In South Africa, Erlang Financial Systems makes banking software. All these external developments were spontaneous. Interested users had discovered Erlang, installed the open-source release and started programming. Most of this community is held together by the Erlang mailing list, which has thousands of members and is very active. There is a yearly conference in Stockholm that is always well attended.

Recently, Erlang servers have begun to find their way into highvolume Internet applications. Jabber.org has adopted the ejabberd instant messaging server, which is written in Erlang and supported by Process-one.

The ban within Ericsson ERA was apparently a power struggle, with the side in favor of the ban promoting popular languages like C++ and Java, and "off the shelf" components. The results are speaking for themselves now, with Joe Armstrong back at Ericsson, and Erlang thriving in more of their products.

Luke Gorrie wrote of this a couple months ago in LtU...

I'm not an Ericsson insider but I can tell you that this is old history from when C++/Java/UML were hyped towards executives. Today Erlang is bigger than ever within Ericsson and they're shipping major new products on it. They even managed to hire Joe Armstrong back.
Joe Armstrong wrote of this about a year ago on the erlang list...
In 2004 I rejoined Ericsson, after 6 years, working in start-ups and research.

Had things changed? - Yes

Had the ban (which caused us to leave) worked? - No.

"Was Erlang still banned?" - I asked, "Don't ask, just use it", they said...

Ericsson has no corporate policy, regarding Erlang.

Corporate policy is way more abstract than talking about individual technologies - nobody in above middle management knows how a phone works...

We (Ericsson) have a number of products written in Erlang - these earn stuff called MONEY...

We (and this includes me) are developing "secret-project-number-1" and "secret-project-number-2" etc. these we hope will one day earn MONEY

Why Ask Why?

From http://www.dailysouthtown.com

What if you or I could secretly commit crimes against our fellow citizens, bury the evidence of the crime by stamping it "TOP SECRET," refuse to answer questions when we are accused of committing the crime, and then, before we can be prosecuted for the crime, we can make a law that says the crime we committed is no longer a crime. And then call ourselves heroes.

Welcome to the New America...

There will be no examining of the individuals being spied upon, to decide if the surveillance is reasonable. Director of National Intelligence Mike McConnell called it "modernizing" FISA, and graciously submitted to post-surveillance "reviews."

McConnell assures us the new law's targets will be foreigners, not Americans.

So, relax. You can trust the Administration of the Freely Reigning Executive never to abuse or stretch the limits of its power. Or, you can stay off the phone with your friends overseas.

An anonymous commenter wonders what I have to worry about, if I've done nothing wrong. Why, they probably don't want to listen to my phone calls anyway. The point of the comment is allocating new cell numbers, etc. happens faster than FISA warrants can be granted.

Well, there have long been scenarios where an eves dropping had to occur more quickly than a FISA warrant could be obtained. And so, predating even Bush's presidency, FISA warrants have been granted ex post facto.

An investigation is allowed to occur and then the FISA review is performed as a check-and-balance on the executive branch. This is *critical* to a democracy, and not just to me making calls to my Aunt Trudy.

RTGGC

Recently see at LtU...

We have developed a fully incremental, real-time generational collector based on a tri-partite nursery, which partitions the nursery into regions that are being allocated, collected, and promoted. Nursery collections are incremental, and can occur within any phase of a mature collection.

We present the design, mathematical model, and implementation of our collector in IBM's production Real-time Java virtual machine, and show both analytically and experimentally that the collector achieves real-time bounds comparable to a non-generational Metronome-style collector, while cutting memory consumption and total execution times by as much as 44% and 24% respectively.

Blog Archive

About Me

Portland, Oregon, United States
I'm usually writing from my favorite location on the planet, the pacific northwest of the u.s. I write for myself only and unless otherwise specified my posts here should not be taken as representing an official position of my employer. Contact me at my gee mail account, username patrickdlogan.