background preloader

Learn You Some Erlang for Great Good!

Learn You Some Erlang for Great Good!
Hey there, it appears your Javascript is disabled. 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) Recursion Higher Order Functions Errors and Exceptions Functionally Solving Problems A Short Visit to Common Data Structures The Hitchhiker's Guide to Concurrency More On Multiprocessing Errors and Processes Designing a Concurrent Application What is OTP? Clients and Servers Rage Against The Finite-State Machines Event Handlers Who Supervises The Supervisors? Building an Application With OTP Building OTP Applications The Count of Applications Release is the Word Leveling Up in The Process Quest Buckets Of Sockets EUnited Nations Council Bears, ETS, Beets Distribunomicon Distributed OTP Applications Common Test for Uncommon Tests Mnesia And The Art of Remembering Type Specifications and Erlang Conclusion Postscript: Maps

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. 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. 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. Anyway, what we are interested in today is the actual process of getting data from the request and putting it on the disk, so let us move along and see what is going on here.

Erlang App. Management with Rebar Introduction Rebar is a build and packaging tool for Erlang applications. 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. 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: h2. To see what Rebar offers just execute . $ . I won't be using all of the commands listed above for the sample application, so if you get more interested in it take a look at the source code. 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. ebin/mysample.app - Application descriptor ebin/mysample.app:

Domain Specific Languages in Erlang People are talking about 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

Related: