Showing posts with label erlang. Show all posts
Showing posts with label erlang. Show all posts

Friday, May 23, 2008

New Erlang web framework by Torbjorn Tornkvist

Tobbe just announced the very first release of a new, very simple Erlang based web framework fully integrated into erlware. It has support for sgte templates. Tobbe also has a collection of other highly interesting web related projects in his git repositry, including domerl, a simple, yaws and JQuery based Comet lib.

Wednesday, April 09, 2008

Erlang R12B-2 released - with native PNG drawing

It's a bugfix release and I had no big expectations when scanning through the release notes, but then I spotted this:
--- percept-0.7 ------------------------------------------------------------

OTP-7162 Percept no longer depends on external c-libraries. The
graphical rendering is now done via erlang code.
Thats huge, if you are interested in generating PNG images and don't wanna have dependencies on c-libraries (as you would have using my cairo wrapper erlycairo). Egd won't win any speed competition and has a limited feature set, but runs out of the box on any Erlang supported platform !

Wednesday, March 26, 2008

Crary - A new Erlang lightweight web server

Beside of featherlight iserve and battle proved mochiweb (at MochiMedia), there is now an additional choice for lightweight Erlang HTTP servers: Crary, which shares similar design goals but provides a different interface. According to its author Scott Parish:
Crary, a HTTP server for the REST of us.

The intention is that its small enough and flexible enough to be used for most any HTTP server need. While it isn't a stand-alone system, nor does it have its own web-framework, these things can easily be built on top of crary. Crary should be easily embedded into the release of a larger application to provide a web interface or to create a web service interface.
Below a tiny little snippet illustrating how to write a hello world program with crary:
start() ->
crary:start(8080, {?MODULE, handler, []}).

handler(#crary_req{method = "GET", uri = #uri{path = "/favicon.ico"}} = Req) ->
crary_dir_listing:write_file(Req, filename:join([my_doc_root(), "favicon.ico"]));
handler(#crary_req{method = "GET", uri = #uri{path = "/test"}} = Req) ->
crary:r(Req, ok, [{"content-type", "text/html"}], <<"hello world">);
handler(#crary_req{method = "GET"} = Req) ->
crary:not_found(Req);
handler(Req) ->
crary:not_implemented(Req).
To get your copy of crary just clone it from its git repository, or install it via erlware.

Sunday, March 23, 2008

Erlang processes benchmarked against threads of other languages

We all know that the result of benchmarks are only significant for that specific piece of code which is getting tested, and usually the benchmark authors favorite products are tuned to outperform its competitors. Nevertheless, below a summary of a benchmark recently discussed on reddit. The benchmark itself is just a few lines of source code (at least in Erlang), spawning a bunch of processes and doing some simple message passing between those processes. Thread implementations in other languages:
  • C (pthread - GNU gcc): 8.5 times slower
  • Python: 15 x slower, 1.4 x more memory
  • Java: 20 x slower, 5.8 x more memory
  • Ruby: 282 x slower, 3.4 x more memory
More numbers, details and the benchmark source code in all the different languages at the language shootout site.

Wednesday, March 12, 2008

Podcast: Joe Armstrong on Erlang

I am currently listening to this Podcast by Joe Armstrong, creator of Erlang. It's a great overview and has lots of historic and other background information.
In case you are new to Erlang, and need something more entertaining and haven't seen yet the classic, "Monty Python" Erlang video, you must see it !

Saturday, March 08, 2008

ErlyDTL now has date and time formating

ErlyDTL, the Erlang version of the Django Template Language is progressing nicely. Most of the common tags and filters are implemented. Recently Colm Dougan joined the development team and added date and time formating.

Let's take a look at some examples with fictive dates:

Template: {% var1|date "r" %}
Rendered Output: Thu, 21 Dec 2000 16:01:07 +0200

Template: {% var2|date "jS F Y H:i" %}
Rendered Output: 27th February 2008 01:24

Template: It is the {% var3|date "jS o\f F Y" %}
Rendered Output: It is the 4th of September 2007

Friday, March 07, 2008

Diving into Core Erlang

Inspired by Robert Virding's LFE - Lisp flavored Erlang, I recently started to evaluate Core Erlang as base for ErlyJS, the Erlang Javascript compiler I am working on. The current approach is based on Erlang Abstract Syntax trees. Erlang Core is more low level and looks more like a LISP dialect than Erlang. Following a short summary about Core Erlang's design goals (copy pasted from the spec):
  • Core Erlang should be as regular as possible, to facilitate the development of code-walking tools.
  • Core Erlang should have a clear and simple semantics.
  • Core Erlang should be straight-forward to translate to every intermediate code used in any Erlang implementation; similarly, it should be straightforward to translate from Erlang programs to equivalent Core Erlang programs.
  • There should exist a well defined textual representation of Core Erlang, with a simple and preferably unambiguous grammar, making it easy to construct tools for printing and reading programs. This representation should be possible to use for communication between tools using different internal representations of Core Erlang.
  • The textual representation should be easy for humans to read and edit, in case the developer wants to check what the Erlang source looks like in Core Erlang form, inspect – or modify – the results of code transformations, or maybe write some Core Erlang code by hand.
You wanna see how Core Erlang looks like ? Take any Erlang source code and compile it as binary and with the to_core compiling option and with core_pp:format/1 you can pretty-print the output. Core Erlang is an intermediate step between Erlang AST representation and VM internal representation. So far I see the following advantages by using Core Erlang for ErlyJS:
  • It is less tied to Erlang the language and therefore just a more natural choice.
  • There exist `let` expressions which seem to provide a cleaner way to handle Javascript variable reassignments (you can't directly reassign variables in Erlang).
  • And last and least, Ecmascript 4 Reference implementation is written in Standard ML, which is more similar to Core Erlang than to normal Erlang. Maybe this point will have relevance one day in the future.
Unless I will discover a show stopper, there will be soon a complete rewrite of ErlyJS to Erlang Core (but I am using git now and only pushing to googlecode SVN major changes in bulk).

Thursday, March 06, 2008

Erlang and Fuse

The Dukes of Erl guys have created an Erlang implementation of FUSE called fuserl. From reading their blog, it seems they need it for interacting with RRDtool, a open source software for realtime data logging and the ultimate goal for fuserl is a distributed filesystem based on mnesia: walkenfs (the idea is not new, Ulf Wiger has something similar as part of erlhive). Now I just read about another possible use case for fuserl:

The advanced strategies of internet marketing are employed by the different internet marketers to promote E-businesses. The web site design and web development programs are organized by the different IT companies. The cheapest domain name registration services are very useful for the medium kind of entrepreneurs who can’t afford expensive rates. The cheap hosting services of various web hosts are available to facilitate the individuals who run small businesses.

Saturday, February 23, 2008

ErlyJS - translating Javascript to Erlang

I have lately invested many hours of coding in ErlyJS, my open source attempt of writing a Javascript compiler for the Erlang virtual machine and crossed today the barrier of 100, for the number of commits and also for the number of test cases. There is still a long way to go, because nobody (including myself) will actually use the compiler in a real project, unless it is 100% Javascript compliant. But at least, most of the basic stuff is now halfway implemented:
  • Literals
  • Global / local variable handling
  • Operators (except of dot operator, for objects)
  • Functions
  • Built-in global functions
The next big task will be object handling (and implementing the built-in objects and their functions)

I am not targeting the Erlang VM directly (beside of the Erlang compiler source code, there doesen't exist any formal specification or at least documentation about the Erlang VM internals in general and specifically the VM opcodes). What I do is transforming the Javascript source code AST to an Erlang AST. This involves a lot of trickery, because Erlang doesn't allow variable re-assignments (this is good and also necessary in the context of Erlang concurrency), but most Javascript code is just a bunch of variable re-assignments, so I have to model it somehow and I have choosen to model it differently for global Javascript variables (Erlang process dictionary) and local variables (normal Erlang variables). One interesting thing about having an Erlang AST of Javascript source code is the possibility of pretty-printing Erlang source code. Let's take a look at a Javascript example from the test cases:
function test() {
var a=0, b="Bananas";

switch (b) {
case "Oranges":
a = 1;
break;
case "Apples":
a = 2;
break;
case "Papayas":
case "Bananas":
a = 2.5;
a = 3;
break;
default:
a = 4;
}

return a;
}

If I pretty print the AST (just before compiling it, and this is even done automatically at verbose ErlyJS compiling settings) I get the following Erlang source code:
js_test() ->
V78 = 0,
V80 = "Bananas",
{V152} = case V80 of
"Oranges" -> V170 = 1, {V170};
"Apples" -> V88 = 2, {V88};
X when X == "Papayas"; X == "Bananas" ->
V270 = 2.5, V288 = 3, {V288};
_ -> V32 = 4, {V32}
end,
V152.
This kind of source code translation is extremely useful while developing and debugging the ErlyJS compiler and analyzing test cases.

Tuesday, February 19, 2008

Discontinuing ErlyMate

My attempt of better integrating Erlang with TextMate has been an interesting trip into foreign territory (Objective C and Desktop applications), but I never considered it as a serious project, it was more a kind of overreaction to my inability of mastering all Emacs key bindings even at sleep. And I also don't like to put lots of time into an open source project to erlangify a proprietary, Mac-only software from a one-man-company. Anyway, if this are non-issues for anybody who wants to resurrect the project, I will be available to answer initial questions. Ok, this was probably my last post about ErlyMate here.

Erlang – The CEO’s View - by Gordon Guthrie

An interesting article about Erlang from the business point of view, by Gordon Guthrie the CEO/CTO of hypernumbers.net.

Saturday, February 16, 2008

Interfacing Erlang with C - explained by Joel Reymont

Great tutorial on how speeding up Erlang with linkedin C code. But hopefully you won't have to do it because it makes your software hard to maintain and the C part might crash your program. But if you have to interface with C, then first check whether a C-node (as for example done in ErlyCairo) has enough performance, a C-node uses it's own memory space and doesn't crash your Erlang program, in case things go wrong. But if your C code is very robust, and you really need the performance, Joel's tutorial is a great introduction to that topic.

Wednesday, February 06, 2008

Erlang Style Concurrency - explained by Ulf Wiger

That is probably all you ever wanted to know about Erlang style concurrency, put into a great summary by Ulf Wiger, who has been using Erlang since 1992.

Thursday, January 17, 2008

Hypernumbers whitepapepr: comparing Erlang and LAMP web stacks

Using Erlang In A Web Start-Up is a whitepaper (PDF) by Gordon Guthrie, pointing to advantages from the business point of view when choosing Erlang.

Tuesday, January 15, 2008

ErlyDTL - the Django template language in Erlang

I have been working on a new template language called ErlyDTL. Let's compare it first with the other, established players in the Erlang open source template languages field:
  • ErlTL by Yariv Sadan. ErlTL is used in ErlyWeb and therefore probably the most popular Erlang template language. It exposes the full Erlang language to the template author, that is good, if the template author is an experienced Erlang developer, but bad, if the template author does not know Erlang. ErlTL compiles templates to beam files.
  • sgte by Filippo Pacini. An Erlang implementation of StringTemplate. Enforces separation between model and view. Templates get evaluated at runtime. Used at erlware (if you install the erlware launcher, sgte is one of the core packages used internally for the various erlware templates)
  • ErlyDTL by Evan Miller and myself: based on the Django template language. It does not expose Erlang to the template author, it compiles templates to beam files, pre-renders as much as possible at compilation time and supports a lot of features such as template inheritance, presetting variables at compilation time, automatic HTML escaping and lots of Django tags and filters. But it is not feature complete yet, just the more important tags and about half of the django filters are currently implemented.
If you wanna learn more about ErlyDTL, check out the code or take a look at the examples, there are a bunch of ErlyDTL demo and test templates at he googlecode project and also the resulting, rendered output files.

Update: There are more Erlang template engines out there: seethrough which is specifically for XML/XHTML and internally uses xmerl to do its magic. It is rather simple compared to the others, but depending on the use case that can be an advantage.

The search engine optimizers are very much expert to manage ppc productivity in an efficient manner. The main function of web hosting service provider is to help the individualistic web sites to have direct accessibility to worldwide immediately. The website design templates are designed by the professional web designers which can be downloaded from different web directories free of charges. The internet service providers offer their latest services of dsl which are reliable and affordable for internet users.

Friday, December 28, 2007

Erlang on Javascript

While I am working on a Javascript to Erlang compiler for running Javascript code on the Erlang virtual machine, others do the opposite: Alex Graveley has written Er.js, a Javascript library for using Erlang-style concurrency with JavaScript, even with an Erlang like syntax !

Javascript does not support natively any kind of threads, therefore a lot of tricks (like using the asynchronous timer callback) went into this and other narrative Javascript based threading libraries to make it look and feel like real multithreading.

Friday, December 14, 2007

ErlyComet article and screencast

Today my article "Getting started with Comet on Erlang" got published at CometDaily, there is also a screencast there (scroll down there, to the ErlyComet section) if you prefer to watch and listen ...

Update: Some users could not load the screencast / did not like to get asked for upgrading the flashplayer. I halfway expected this. It's not that I haven't put in efforts to avoid that kind of bad user experience, but my efforts apparently failed. Let me explain in detail: the video is encoded in h264/HE-AAC and that only works on flashplayer 9.0.125. If the flashplayer is not the very latest one, a dialog should inform the user (and provide direct link) to upgrade the flashplayer, if he wishes to watch the video. Uploading the original QuicktTime screencast to youtube or google video results in bad, mostly unreadable text quality, similar to all those RubyOnRails screencasts which have been originally recorded in QuickTime.
Nevertheless, here is the google video version (bad quality).

The web hosting services of different hosting companies include the most additional features of domain registration free of charge. The web site design of varied websites is developed by the professional web designers who have artistic touch of Excellency. If you want to have direct and fast internet access, you should subscribe reliable broadband service providers. The website development services are offered by the different IT companies to boost up the significance of web site into the main search engine.

Thursday, December 13, 2007

Erlang TextMate integration - Documentation lookup

I have made some progress with ErlyMate, my pet project for adding first class Erlang support to TextMate. Based on a new architecture with an Erlang background server (starts and stops together with TextMate, wrote a Cocoa plugin for that) I implemented a very first and highly experimental approach of edoc lookup. More technical details can be found at the googlecode project page.

And here a screencast to show you how it looks and feels like (requires latest flashplayer, and asks you to upgrade to it, if you don't have it, because video is h264/HE-AAC encoded):



To view the ErlyMate screencast:




Get Adobe Flash player





Sunday, December 09, 2007

Benchmark - ErlyWeb vs. RubyOnRails

Yariv Sadan, the author of ErlyWeb, has benchmarked his Erlang MVC web framework against RubyOnRails 2.0 and according to his results, ErlyWeb is outperforming RubyOnRails by factor 47. [Corrected: it's 6 now, see Update]

If Ruby is on Rails, than ErlyWeb is on rocket engines !

Update: This number is far too good to be true ! In fact, Yariv had Mongrel running in non-production mode, in his corrected version the ErlyWeb outperforming factor went down to 6.

Thursday, December 06, 2007

Erlang R12B-0 on Leopard

Yesterday Erlang R12B-0 was released. Compilation on Leopard (with XCode development tools installed) was straight forward, except for one Erlang application: the new profiling tool percept, which got disabled because of missing libgd library at the ./configure step.

So I installed it via macports:
sudo port install gd2
unfortunately ./configure continued to complain. Finally today a solution for how to run ./configure was posted on the Erlang mailing list:
./configure --with-gd=/opt/local
and everything went without further problems ...

There a lots of new features and improvements, and I look forward to explore them one by one in the next weeks and months. Just the troublemaker percept I had to inspect immediately. It seems to be a powerful tool for performance analysis and it ships with a module called edg which wraps libgd and serves for creating 2D vector graphics (to visualize the percept profiling results), similar to my own erlycairo, but it produces*.gif files (erlycairo only outputs *.png files).