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, March 01, 2008

When to use Ruby and when not

Just read this interesting article by Zed Shaw about Ruby, Ruby in the enterprise, Ruby on virtual machines and more ...

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.

Friday, February 22, 2008

Dojo theming tutorial and more at dojocampus

Ever wanted to know how to create flexible-size background images for rounded corners or other CSS effects specifically for custom-theming Dojo widgets ? Unless you have already intimate knowledge of the Sliding Doors technique and CSS sprites, you should checkout the "Rounded tabs" tutorial on the recently started DojoCampus site. There is also other great stuff there such as a video about the dojo grid and Firebug tips.

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.

Thursday, February 14, 2008

Django Template Language - the dojo implementation

Beside of Erlang based ErlyDTL (by Evan Miller and myself) there exists (at least) one other non-Python project which implements the Django Template Language: the dojo Javascript version: dojox DTL (documentation) for creating dynamically and template-based HTML layouts inside the Web browser (opposed to traditional approaches of creating HTML layouts at server-side). Today dojox DTL reached feature completeness, implementing all original Django tags and filters, at least that is what I guess from reading the SVN changes for the README:
--- This aims to be a 1:1 match with the Django Template Language as outlined in
+++ This is a 1:1 match with the Django Template Language as outlined in
While dojox DTL is a very interesting concept and brings new possibilities to separate client-side logic and presentation, I haven't seen yet a killer example. Maybe I just haven't looked far enough. But one thing is sure: if you use a template language at server side and at Javascript client side, and it can be the same template language, that's a huge benefit.

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.

Friday, February 01, 2008

New book "Mastering Dojo" - beta PDF now available

For those who prefer to learn new Javascript stuff by reading a real book, Mastering Dojo (500 pages) has been announced today. It will be relesed in June, but the beta PDF is already available. Alex Russell, one of the initial developers of dojo, is a co-author of that book.

Update: I ordered the PDF version, right after writing this post, but haven't received the e-mail with the download-link yet, so all what is really available right now, are the two example chapters at the publisher's site.

Tuesday, January 29, 2008

More on serverside Javascript - Rhino on Rails

Dion Almaer has recently interviewed Steve Yegge about his project of porting Rails to Javascript, you can listen to it right here:

Tuesday, January 22, 2008

Serverside Javascript with Jaxer

Today Aptana (mostly known for their eclipse based Ajax IDE) launched Jaxer, an open source based Ajax server for using Javascript as server side scripting language. It is built on top of the Apache Web server and and the Spidermonkey Javascript engine and has an API which covers most developers needs: File and database access, logging, email and all kind of other utility functions.

So what are Jaxers major selling points ?
  • Write entire applications or presentation layers in Ajax.
  • Share code between browser and server.
  • Database and file access from JavaScript.
  • Integration with Aptana Studio (their Ajax IDE).
The most important question for me of course is how it compares to erlyjs, my Javascript-to-Erlang compiler project with main purpose of running Javascript at the serverside for Ajax web applications. Obviously Jaxer is available today and now and erlyjs is work-in-progress far from being ready to use yet. Both share the same vision and both use Spidermonkey. But while on Jaxr the Javascripts really run within the Spidermonkey engine, erlyjs uses Spidermonkey only for parsing the Javascript, then compiles the parsed Javascript to Erlang beam files, for running on the Erlang virtual machine. I believe my approach gives significant performance and scalability advantages (and integrates better with the rest, in those rare cases where the rest is written in Erlang as well ...)

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.

Sunday, January 13, 2008

CodeMirror - an AST aware in-browser code editor

I have been following for a while now the development of Javascript based code editors and web IDEs (see here and here), I even started to build one myself, because I thought there is no such AST aware editor out there, at least until I discovered codemirror, which comes with support for Javascript and HTML, and with support I mean it has a real parser (and a CSS file for syntax highlighting) for those languages. Marijn Haverbeke, the author of this masterpiece of functional Javascript programming has released today a new version, which makes it easy to integrate it with a different Javascript libraries (codemirror itself uses MochiKit).

Codemirror has the following features:
  • syntax highlighting
  • automatic code indentation of current line on pressing TAB or RETURN
  • if some code it selected, automatic indentation of current selection on pressing TAB
  • works with all common modern browsers
  • highly configurable: additional languages, performance settings, etc.

Sunday, January 06, 2008

Zed Shaw on Rails (Ghetto)

The new year started with an explosion in the Rails community: Zed Shaw's Rails rant, where he points to some well known Ruby/Rails-people, explains why they are "assholes" and brings up some "general thoughts" such as:
This is exactly what makes Rails a ghetto. A bunch of half-trained former PHP morons who never bother to sit down and really learn the computer science they were too good to study in college.
Zed is the author of Mongrel, that made him well known and highly respected within the Rails community. But now I see people from the whole software industry blogging about him and his famous rant. Zed got mentioned on techcrunch and today I saw even a post from Rickard Oeberg about Ted's rant. A few years ago, Rickard was blogging in a very similar style, highly informative but also entertaining about the nasty things around the JBoss community (Rickard was the most important initial developer of the JBoss application server).

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.

Wednesday, December 26, 2007

Gmail insecurity - check your filters - you may have been hacked

David Dairey's .com domain name got stolen by an online criminal, exploiting a gmail security vulnerability (now fixed). The scary thing about this is that the exploit added a filter to gmail, so even after Google fixed the security whole, any malicious inserted filter continues to do its evil actions. Read the entire story and check your filters !