Archive for Uncategorized

Finger Tree: A Functional Value Object

Tags: , , , , , , ,

A Finger Tree is a data-structure that supports amortized O(1) addition and removal of elements from either end [1]. It also can support a large number of common sequence operations, including concatenation, very efficiently. Our implementation is based on the Hinze-Paterson structure [2], simplified for use as a Deque. It is possible to implement a […]

Continue reading » 8 Comments

In-Order Message Delivery

Tags: , , , , , ,

The Actor Model explicitly avoids placing constraints on message delivery order beyond causality [1]. Messages may not be delivered before the message which caused them to be sent. In other words, time can’t flow backward. Beyond that, messages arrive in a non-deterministic order. This can sometimes have surprising consequences. Two messages sent in sequence from […]

Continue reading » 1 Comment

Circuit Breaker Stability Pattern

Tags: , , , , ,

[Update 2014-02-02: I’ve posted a video showing a visualization of this pattern at http://www.youtube.com/watch?v=WEXh1WoppMU] In a loosely-coupled system connected with asynchronous messages, a flood of client requests can exceed the capacity of a service. When this happens, we would prefer that the service respond with an indication of the overloaded condition, rather than making us […]

Continue reading » No comments

Actors Make Better Observers

Tags: , , , , , , , , , ,

The Observer pattern causes temporal coupling in systems with synchronous message passing. This can lead to failure in Object-Oriented systems. Asynchronous messaging avoids the pitfalls. Actor-based implementations more accurately realize the original intent of the pattern. The intent of the Observer pattern is to “define a one-to-many dependency between objects so that when one object […]

Continue reading » 3 Comments

Parsing Expression Grammars, part 4

Tags: , , , , , , ,

This article could probably be called “Left Recursion Considered Harmful“. PEG parsers are unambiguous and relatively easy to reason about. A little reasoning about left-recursive PEGs shows that they don’t make sense. The motivation to use left recursion seems to be driven by the desire to build left-associative parse-trees for arithmetic operators. However, parse-tree generation […]

Continue reading » 2 Comments

Parsing Expression Grammars, part 3

Tags: , , , , , , ,

We build on the parsers from part 2 of this series to enhance and extend their capability. In particular, we extend the concept of modular grammars to construct chains of parsers which define a multi-stage transformation pipeline. The parsers forming these chain are enhanced to match and transform tree-structures, rather than being limited to simple […]

Continue reading » 1 Comment

Parsing Expression Grammars, part 2

Tags: , , , , , , , , ,

It’s usually not enough to simply recognize patterns in an input stream. Soon we will want to take action based on what we recognize. In order to facilitate this, we will begin creating semantic values from the input tokens and trigger semantic actions when certain patterns are recognized. In part 1 of this series we […]

Continue reading » 2 Comments

Parsing Expression Grammars, part 1

Tags: , , , , ,

Parsing Expression Grammars (PEGs) define a powerful class of matchers for recognizing strings of a formal language [1]. They’re well suited to parsing the syntax of computer languages. PEG-based tools like OMeta [2] have been successfully applied to a wide variety of transformation problems [3] [4]. The fundamental elements of PEGs can be described compactly […]

Continue reading » 2 Comments

Playing the Stooge with Humus

Tags: , , , , , , ,

Happy New Year and welcome to 2011. With the coming of the new year, I’m happy to announce the availability of a simulator/debugger environment for Humus, (Note: the 2011 version has been archived). Please note that this is a simulator of the Humus language written in JavaScript, so it runs very slowly. It is intended […]

Continue reading » 1 Comment

Evaluating Expressions, part 7 – Transactions and Exceptions

Tags: , , , , , , , , , ,

In part 7 of our series implementing programming language constructs with actors, we implement parallel execution of block statements. Parallel execution motivates the use of single-assignment data-flow variables. We also introduce transactions and exception handling. The only extension required to our grammar from part 6 is the inclusion of a THROW statement: stmt ::= ‘LET’ […]

Continue reading » 1 Comment

Evaluating Expressions, part 6 – Actor Primitives

Tags: , , , , , , , , , , ,

In part 6 of our series implementing programming language constructs with actors, we explore meta-circular definition of imperative actor primitives. We have now moved beyond expressions which yield values, and focus on statements which cause effects. The constructs explored here are the heart of any actor-based system. In order to support actor primitive statements, our […]

Continue reading » 5 Comments

Evaluating Expressions, part 5 – Recursion

Tags: , , , , , , , , , , ,

Some language environments provide an interactive interface called a Read-Eval-Print-Loop (abbreviated REPL). One key characteristic of a REPL is the ability to incrementally define, extend and re-define your environment. This is particularly challenging in a pure-functional context, such as the evaluator we have developed so far. Modularity and incremental development seems to imply the need […]

Continue reading » 4 Comments

Evaluating Expressions, part 4 – Pattern Equations

Tags: , , , , , , , , , ,

In part 4 of our series implementing programming language constructs with actors, we extend our pattern matching behaviors to support pattern equations. These are true equations that express relationships between patterns. They form the basis for introducing LET and IF expressions. The grammar for our extended language is shown below. Changes from part 3 are […]

Continue reading » 6 Comments

Evaluating Expressions, part 3 – Pairs and Parallelism

Tags: , , , , , , , , ,

In part 3 of our series implementing programming language constructs with actors, we explore parallel evaluation of sub-expressions and introduce pairs. Pairs allow the construction of tuples, generalizing structured multi-part patterns and values. In order to support pair expressions and patterns, we’ve refactored the grammar from part 2 to separate out literal constants expressions and […]

Continue reading » 6 Comments

Evaluating Expressions, part 2 – Conditional Special Form

Tags: , , , , , ,

We continue exploring actor implementation of programming language constructs by adding a special form for conditional expressions. This will not increase the expressive power of the language. In part 1 we implemented a Turing-complete pure untyped lambda calculus. Now we add direct efficient support for conditional expressions and introduce basic pattern matching. Changes from the […]

Continue reading » 3 Comments

Evaluating Expressions, part 1 – Core Lambda Calculus

Tags: , , , , ,

One of the best ways to understand programming language constructs is to implement them. We will begin by implementing a simple, yet Turing-complete, functional expression language. In subsequent articles, we will extend this language with additional features. For now we will focus on just the “untyped” lambda calculus, augmented with constants. The grammar for our […]

Continue reading » 7 Comments

“Dining Philosophers” in Humus

Tags: , , , , , , ,

The “Dining Philosophers” problem is a classic example used to illustrate various challenges with concurrency. We will approach this problem by incrementally designing the actors which model the problem and its solution in Humus. Through this example we will explore the avoidance of deadlock and starvation in the design of actor-based systems. Basic Thinking/Eating Cycle […]

Continue reading » 2 Comments

Message Passing, part 2 – Object-Oriented Method Invocation

Tags: , , , , , , ,

This is part two of an article exploring what we mean when we say “message-passing”. Part one described how synchronous rendezvous can be expressed with actors. Part two describes an actor implementation of object-oriented method invocation. For Object-Oriented developers from the Smalltalk tradition, message-passing involves a dynamic method lookup, invocation of that method with the […]

Continue reading » 2 Comments

Message Passing, part 1 – Synchronous Rendezvous

Tags: , , , , , , ,

What do we mean when we say “message-passing”. For Object-Oriented developers from the Smalltalk tradition, message-passing involves a dynamic method lookup, invocation of that method with the target object as an implicit parameter, and return of a result object. By contrast, message-passing in synchronous communication models (such as Ï€-calculus) involves “rendezvous” between sender and receiver, […]

Continue reading » 3 Comments

Actors in Clojure – Why Not?

Tags: , , , , , , , , , , ,

In his article about state management in Clojure, Rich Hickey discusses his reasons for choosing not to use the Erlang-style actor model. While Erlang has made some implementation choices that can lead to problems, the problems are not intrinsic to the Actor Model. As the actor implementation with the longest history of success, Erlang naturally […]

Continue reading » 14 Comments