Embrace change

«The best way to predict the future is to invent it» — Alan Kay 
Filed under

development

 

Some news on my Go activities

During the last days I've been busy with and around Googles programming language Go. I've continued my development of the Tideland Common Go Library (http://code.google.com/p/tideland-cgl/) which is the base for future developments. The first application I'm already designing is called Tideland Knowledge Management and Retrieval, a kind of wiki with structured facts that have individual typed properties, tags, and semantic references. So the CGL will contain almost everything I need for such a kind of server applications:

  • a container for business logic,
  • a framework for the web front end,
  • authentication, authorization, and accounting,
  • monitoring,
  • and more.

Just take a look at the link above. Here you can follow the progress, view and retrieve the sources, and place issues. The next part I'll implement is a kind of supervisor like it is known from Erlang. There are restrictions in Go, but I've already got some ideas. If it works alright it will be integrated into the logic container, which is already usable right now.

Beside developing I've finished my first article about Go. It will be printed next month. Additionally I'm preparing a talk about Go I'll give at the iX CeBIT Forum 2010 on March, 2nd. Maybe some of you are there so that we can discuss a bit about Go later.

Loading mentions Retweet
Filed under  //   development   golang  

Comments [0]

One month of Go evaluation

I've spent the december with evaluating Googles new programming language Go. The first comments on the language in the net haven't been very positive: nothing new, no clear paradigm, my language (insert your favorite language here) is better due to (insert your favorite feature here). So I'll start with a rant too: the name Go isn't really good. Just try to google it, you get too many misleading links. *smile* So it's very often called or tagged golang. A different name would be better.

The language itself really seems to be nothing new. Since 1996 I mostly used Java, Python, Smalltalk, and Erlang/OTP. And I find many aspects of those languages in Go. So everybody expecting something revolutionary will be disappointed. Instead Google just put many useful features of those languages above - and others - together, useful in the sense of productivity. So I've been really astonished how fast I've been able to reimplement some of my libraries inGo. My favorite features of the language are:

  • Even if it is a static typed language it behaves almost like a dynamically typed language. Implicit declarations, no line ending, no braces for the if- and the for-statement, simplified for statement, implicit visibility.
  • Garbage collection absolves the developer from memory management, nothing new for many VM languages, but Go produces statically linked binaries.
  • The binding of methods to types works like object-orientation without inheritance. Some may interpret this as a lack, but it enforces simple types and the usage of aggregation and composition.
  • Like in other languages interfaces allow the definition of a set of methods that has to be defined for own types to work with special functions, e.g. for sorting.
  • The empty interface allows variables and arguments with undefined types (type can be determined during runtime).
  • A special parameter allows functions with an arbitrary number of arguments, which alows nice, powerful functions.
  • Goroutines and channels are a simple and powerful instrument for the creation of concurrent solutions.
  • Go contains anonymous functions, that's allways fine.
  • Maps as a built-in data type, no extra library needed.
  • Easy access to arrays, slices, maps, and channels using the for and range statements.
  • The switch statement can work with case expressions, not only values.
  • Functions may return multiple values. Naming them already in the declaration simplifies the return.
  • Simple and powerful reflection, not only for evaluating but also for the dynamic dispatching of method calls.
  • Without reflection a simplified switch based on a type can be made.
  • Very fast builds and - after some first benchmarks - very fast execution.
  • Rich library for this early state of the language.
  • Tools like gofmt, godoc, and gotest - beside others - support the developer, like the well prepared makefiles do.

As said above it's all nothing new, but it's a good combination. Nevertheless there are some disadvantages. I'm missing several features compared to Erlang/OTP, other features are not yet optimal implemented.

  • There's no polymorphism. Sometimes it can be simulated using interfaces, but it's not possible to implement the same function or method in the same scope more than once with a different number of arguments or different types.
  • Tuples can be simulated with slices of empty interfaces, but that's not really comfortable.
  • Together with polymorphism and tuples I'm missing guards, e.g. for separating functions and methods based on values. These are very powerful instruments.
  • Go contains no exceptions. Here the multiple return values shall be used, but already the packages of Google show inconsistencies. Smalltalk and Erlang/OTP show how exceptions can be used without contamination of the whole code. Additionally Erlang/OTP shows how both concepts can live side by side.
  • Even if the empty interface should enable the code to handle any data the same way the basic types behave different. So no real generic collection libraries are possible. One way could be the enhancement of the empty interface handling, another one the adding of generics. I would like the first one.
  • Goroutines can't be monitored, e.g. for restarting them, channel receives can't be done with a timeout, and there's no transparent communication over the network using channels. Here I'm definitely pampered by Erlang/OTP. *smile*
  • The handling of maps, arrays, and slices could be easier. If there are len(), cap(), and copy(), why are there no del(), grow(), or contains()?
  • A little embedded key/value database for the storage of nested structs in tables would also be nice, together with packages for searching, e.g. via map/reduce. For larger projects I would use CouchDBor RIAK, but smaller ones don't need this.

And now? How to go on? Continue with Go or continue with Erlang/OTP? Or even with both of them? A hard decission. On the one hand I like Erlangs clean model together with the above mentioned features. But on the other hand the productivity I've reached with Go really impressed me. And what's more important, experimenting with clean single paradigm languages or the fast realization of the list of projects that's in my mind in a language which borrowed all its features from other languages? There have been moments I decided to end the evaluation and continue with Erlang/OTP. But each time I found a quick solution, an easy workaround, a different way to handle my tasks. So I think I'll stay a little while longer with Go, realize a small isolated project - I already got one in mind - with it and then write a second blog entry with more results of my Go evaluation.

Loading mentions Retweet
Filed under  //   development   erlang   golang  

Comments [0]

First Go Programming Language experiences

I'm currently doing some first steps in Googles new programming language Go just for evaluation. The compilation on OS X is simple and there's also an integration into XCode. But even if XCode has some nice features it's such a rudimentary integration that I switched back to my favorite editor TextMate. The package provided by Google contains also an integration into this editor.

The first impression showed nothing really new, nothing spectecular. Go is a C-style language, statically typed, together with some stuff helping to write less code, with maps as first class types like in Python, with interfaces and methods bound to types but with no inheritance. Coroutines - Go calls them goroutines - can be spawned and the communication between them is done using channels. Go knows lambdas, garbage collection, run-time reflection, multiple return-values, and a very simple export of constants, variables, functions, and channels - just wirte the first letter in uppercase. Beside the basic language Google provides a set of useful packages and some tools with Go.

In many aspects my favorite languages Erlang, Smalltalk, and Scheme are more clean, somehow more elegant in their specific domain. So what makes Go anyhow interesting? Why digging deeper? It's just the mix. Not a mix of brand new features but a mix of well known features. The C-style may attract all C, C++, D, Java, C# developers, the maps and the short variable declarations are fine for users of dynamically typed languages, interfaces and type-bound methods provide a basic OO, and goroutines together with message passing are OK for Erlang or Scala developers.

So Go is not really imperative, functional, object-oriented or concurrency oriented, it's more or less a pragmatic language. I'll do a bit more with it and then write about my experiences and the comparison to other languages here.

Loading mentions Retweet
Filed under  //   development   golang  

Comments [2]

No new integration platform

I thought a bit about my idea for a next generation Tideland EAS and now made a decision. It is really an appealing idea building a new integration platform for event-driven solutions based on technologies like JSON, HTTP, and JavaScript for the service subscription. But that's not my goal. I've got real applications in mind, currently three different ones. And the EAS is just intended to be the backend framework which allows to implement them as event-driven solutions which work reliable in a 24/7 environment. So I'll continue the development as planed. Additionally I've started writing a small article about my motivation for event-driven architectures on http://www.tideland.biz which will be published soon.

Loading mentions Retweet
Filed under  //   development   erlang   tideland  

Comments [0]

Tideland EAS next generation idea

When I started the development of the Tideland EAS I had a small pure Erlang event-driven architecture in, just as the middleware for my apps. But sometimes ideas assume in an independent existence. OK, the old concept would also benefit from the reliability and scalability of Erlang/OTP, but not as much as it is in the possibilities of this platform.
 
So, while reading about and evaluating CouchDB, my concept changes. I'm currently thinking about reimplementing it as a real middleware for event-driven architectures. This draft gives a better insight:

The black steps (1) to (3) show the subscription process where a service provider sends a JavaScript filtering the subscribed events. The EAS will store some administrative data, like the ID of the subscription and the service provider, and sends the JavaScript to CouchDB as the database server. CouchDB uses the script to create a view for the subscription.
 
The red steps (1) to (6) show the event processing. A raised event sent to the EAS will be stored inside the CouchDB event table and will so also be visible in all matching views. In case of a polling service the new events will be retrieved and sent to the service. It now can process the event and send the reply or new continuing events back to the EAS. Finally - if wanted by the event source - a reply will be sent back.
 
There are still several open aspects I've got to think about. But I think it looks promising. I'll test the concept with a quick prototype.

Loading mentions Retweet
Filed under  //   development   erlang   tideland  

Comments [2]

Approaching beta step by step

During the last days I've had to stop my development on the Tideland EAS due to the migration of my root server to two new ones. Now my own projects as well as my customers do have a better environment.
 
But after that I've been able to continue the work on my small event-driven middleware for Erlang based solutions. The completion of a test business process helped to make the API for service developers more simple and consistent. Additionally the configuration and the error handling have been improved. Now there's only the configuration - and usage - of functions for the preprocessing of events and postprocessing the results is missing for a beta release. They are intended to allow the transformation of data from one format into another if e.g. two service interfaces doesn't fit.
 
After this extension the functional part for release 1.0.0 is complete. But I still have to add some functionality for reliability and scalability. So the dispatcher shall notify others if a service registers or unregisters. And in case of a restart through the supervisor they shall retrieve the registered services from other nodes. The same is needed for the configuration. So still some work to do, but that's exactly Erlangs playground. *smile*

Loading mentions Retweet
Filed under  //   development   erlang   tideland  

Comments [0]

Why there will be no dominant programming language

These days we once again have a large discussion about the next dominant programming language. Due to multi-core and distributed systems everyone is looking for a new and better approach. Old and new functional programming languages get into focus. Erlang, Scala, Haskell, F#, Clojure, just to name a few.
 
But I don't think one will be dominant. It's like before that people have different experiences, come from different environments, and have different preferences. So while Java developers may tend to Scala and old Lispers who are working with Java in their daily job tend to Clojure the Microsoft community may prefer F#.
 
But what about Cobol, what about ABAP? They may be past their peak, but they are still working in a large number of systems for many users. And they will do so in the next years. The only thing that will change is their share. Due to the immense growing number of systems new languages and environments only prevail for new solutions while the number of legacy systems slowly declines over a long time. And here I'm not only think about Cobol and ABAP, but in some cases maybe also Java and C#.
 
So what's needed for such new environments? It's multilingual knowledge, it's the knowledge about multiple paradigms, it's the knowledge about distributed systems, and it's the knowledge about integration, service-orientation, and - in my opinion - event-driven architectures. The picture of the software developer more and more converges into the picture of the zookeeper.

Loading mentions Retweet
Filed under  //   development  

Comments [0]

Refactoring is fun

Currently I'm refactoring the Tideland EAS. During the development it got too heavy, too complex, and with too many potential error sources. Additionally I improved my experience with Erlang/OTP and learned more about the OTP design principles. A good basis for a better design.
 
So the result of my refactoring is a better OTP integration as a base for later distribution and reliability in failover situations - here right now only the communication of dispatchers on different nodes is missing. Additionally I can discard lots of code, so the next step will be better maintainable. Through a better integration of worker processes together with pg2 and supervisor the system will be more reliable. And last but not least the configuration changes to external provider modules that will be passed during startup inside the application configuration. This provider module ohne has to define the callback functions init/0, fetch/1, and fetch/2 and will run inside an own process. The returned configuration value can be hard coded inside a module, e.g. for testing purposes, retrieve them out of a configuration file, or use a database backend for a distirbuted configuration.

Loading mentions Retweet
Filed under  //   development   erlang  

Comments [0]

FP vs. OOP

Dean Wampler posted a very good article
(http://blog.objectmentor.com/articles/2009/04/20/is-the-supremacy-of-object-oriented-programming-over)
asking if the supremacy of object-oriented programming is over. It summarizes the current
discussion about languages like Erlang/OTP, Scala, F#, or Clojure. Worth reading it.

Loading mentions Retweet
Filed under  //   development   erlang  

Comments [0]

On OOP, COP and the Tideland EAS

My current software project is the Tideland EAS (Events and Services) as an Erlang/OTP based platfrom for my future server-side applications. To understand the design motivation behind the EAS it may be useful to get a little insight into my software development experiences.

I'm now doing software development since about 25 years, the last 20 years the object-oriented way. So my development style is mostly characterized by my personal understanding of OOP. The bundling of attributes and behaviour is a natural way of thinking and easy to understand unless the imperative way of programming isn't etched on the memory too hard. Depending on the experience of the developer it's more or less simple to determine the right candidates for pure helper classes, for those building the foundation for the own system, and those representing the business model of an application. A large number of design patterns helps to find solutions based on a common understanding.

One of the most important parts of object-orientation is the idea of message passing between instances. When developing Smalltalk Alan Kay has been heavily inspired by Carl Hewitt's research on the actor system for massively parallel, distributed, computer systems. Unfortunately instances in languages like Smalltalk, Java, or C# aren't massively parallel. So messages sent to an instance block the caller until the work is finished. *sigh*

Think about a restaurant, where the guests have to wait for their waiter who is then waiting for the cook. The cook is then cooking the meal, one part after the other, hands it out to the waiter who is then handing it out to the guests. During this the waiter can't attend on other guests. So the restaurant would need a pool of waiters to handle every guest parallely. But additionally it would also need enough cooks to serve all orders.

To allow an environment where at least such a concurrency with pools is possible the traditional environments use threads. While those are relative lightweight from the operating systems point of view they are still very heavy on the instuction level. Sadly threads are not native for objects, they are orthogonal, a kind of meta level. So instances can talk to other instances in different threads without any problem while they are working on another task. Semaphores and synchronized blocks shall help here, but the more complex a system gets and the more a development team size grows the easier it is to confuse the system, to let it get more unstable. No good basis for reliable systems. Here I'm thinking about our waiter from the example above. Guests and cooks are calling for him while he is trying to satisfy all in parallel. It's easy to imagine how fast this poor guy gets confused.

Here I come to the concurrency oriented programming, actor systems, and Erlang. While in traditional OOP languages the default behaviour is synchronous and asynchronicity has to be added manually or through special frameworks it's different in Erlang. Function calls are also snchronous, but the exchange of messages between concurrent running processes is asynchronous. Blocking calls can be simulated through an immediate waiting for the reply sent back from the process. The OTP provides functions for this inside the standard modules. Looked at that way COP seems to be very close to the original idea of OOP. In case of Erlang this gets combined with its functional paradigm, transparent distributed environments, immutable variables, no shared data, pattern matching, guards, and the integrated database Mnesia. And even if the syntax seems to be weird for the curly braced fraction it's due to the Prolog roots more clean than the actual Java or C# standards - even though Smalltalk and Scheme are still more elegant and compelling. *smile*

Those very positive characteristics made me chosing Erlang as the base for my own development. But I want a bit more than the standard OTP provides, the reason for me to develope the EAS. The name Events and Services already unveils the idea of services implementing the functionality of business domains and communication between them in the form of events. So internally the EAS is a publish/subscribe architecture. The services subscribe to topics on channels and front ends, adapters, and services publish their business events together with a topic on a channel. Some events will be handled totally by one subscriber, others will be a flow of events, serial and parallel, between multiple services. Even typical calls will be just a flow of events. The initial event may be new_customer together with the customer data, the answering event could be customer_added together with the processed data. The publisher of this event may also be a different service than the initial receiver of the first event.

The first benefit of this approach is an extreme loose coupling - good for maintenance, very good for extensibility, and even better for scalability. But there's also a second aspect that's driving my design. Typically only one class or component is receiving a request, publish/subscribe architectures allow multiple receivers, so does the EAS. First this is interesting for automatic concurrent activities. E.g. each time a contract gets cancelled the system parallely updates the customer file, tells the financial accounting to strike a balance, and notifis the customer about the receiving of the cancellation. Or inside an order process the event order_ready_for_fulfilment could start the shipping and the generating of the invoice which do their work independently. But by far more interesting is the Complex Event Processing (CEP) with different types of analysis. Events may be checked that they always occur in pairs, with a specified rate inside a time span or a time period, their order is in a specified sequence, they happen in combination, or they are matching specific conditional expressions. Based on rules those conditions may be associated and correlated in domains, their evaluation leads to the generation of new events for an automatic reaction, alerts may be rised early due to detected signs of risks, it leads to a non-technical monitoring of the environment, the understanding of the dynamic nature of the business may be improved.

I've used the subjunctive here a lot, consciously, because the benefit isn't for free. First detecting the right business domains for the implementation as services and to not build a too fine granularity isn't easy. And second detecting the right correlation domains together with the optimal ruleset is a hard job and one has to think hard and long if it fits for the own situation. I'll see which experiences I'll make when the systems are up and running. But it definitely it's interesting and worth a try.

Loading mentions Retweet
Filed under  //   development   erlang   tideland  

Comments [0]