background preloader

Erlang

Facebook Twitter

Domain Specific Languages in Erlang. People are talking about Erlang.

Domain Specific Languages in Erlang

This talk is disproportionately about concurrency rather than any of the other powerful properties of the platform, such as reliability. This article is about a property of Erlang which does not get the credit it deserves - Erlang is a fantastic workbench for Domain Specific Languages. The domain I have chosen is investment finance. You will see how easy it is to translate plain English at runtime and execute it in the Erlang Runtime System. You may also learn a thing or two about functional programming. Let's begin with a high level run through of how this DSL can be used and move into a step by step detailed discussion of the implementation. Implementation The first three echo commands create the file biz_rules.txt, populating it with three rules.

Buy 9000 shares of GOOG when price is less than 500 sell 400 shares of MSFT when price is greater than 30 buy 7000 shares of AAPL when price is less than 160 Spawning a Broker One Way to Load Business Rules. Tsung. Reading Erlang: CouchDB - From REST to Disk in a few function calls. As you can probably figure out from the title, the purpose of this post is to track how CouchDB is saving a document on the disk.

Reading Erlang: CouchDB - From REST to Disk in a few function calls

We have already tracked how much of CouchDB works, including some fascinating pieces such as btree:lookup and btree:query_modify. Now it is time to dig ourselves from the trenches and have a slightly higher level view of what is going on. We start with the recently refactored couch_httpd_db module. The fun starts with handle_request. It took me a few seconds to realize what is going on here.

As we can see, the create_db_req and delete_db_req have different disposal semantics than do_db_req. do_db_req will just open/close the database and then execute the function in the cotext of this database handle. This is quite a common pattern in functional programming, and it used frequently in Ruby. This is where we are handling with a request for a specific document. couch_util:dict_find is where we need to look now... couch_doc:from_json_doc is interesting, though.

Learn You Some Erlang for Great Good! Hey there, it appears your Javascript is disabled.

Learn You Some Erlang for Great Good!

That's fine, the site works without it. However, you might prefer reading it with syntax highlighting, which requires Javascript! Introduction Starting Out Starting Out (for real) Modules Syntax in Functions Types (or lack thereof) Erlang App. Management with Rebar. Introduction Rebar is a build and packaging tool for Erlang applications.

Erlang App. Management with Rebar

It is implemented in Erlang and the only dependency is the Erlang Virtual Machine, so it can work as a stand-alone escript in your project. Rebar was created by Dave Smith from Basho, creators of Riak. In this tutorial I'll be creating a sample application, building it and generating a release for it, all of this with Rebar. Application Requirements Rebar expects that your applications follows the OTP Design Principles. . - *src* - Contains the Erlang source code. - *ebin* - Contains the Erlang object code, the beam files. Don't worry about this, Rebar can create applications with this kind of directory structure automatically. Installation To install Rebar is very easy, just download it at: After getting it just run a chmod u+x rebar. h2. To see what Rebar offers just execute . $ . Getting Started To get started off I'll go step by step on creating a new project with rebar. This was pretty easy to follow.

OTP

Clustering.