What is twf ?
Tiny Web Framework is a very web framework written in Erlang I started working on out of frustration with Nitrogen.
Why not Nitrogen?
I enjoy Nitrogen but I don't use most of its features and I am annoyed by some of its internals.
For example, I don't like to have every DOM object created with Nitrogen to be given a random id or that they automatically have their names added as class like:
<table class="table wfid_temp34325 wfid_temp34892"> … </table>
I've started to patch Nitrogen on github to fit my needs.
In erlang, strings are lists. That's handy but it has a cost on memory and concatenating strings means concatenating lists which is an O(n) operation where n is the length of the first string, that gets longer each time a string is appended.
There's a solution to solve that issue: use lists of binaries aka IoList. Binaries can be viewed as C-strings. Want to append an IoList a to an IoList b? Simple! Just create a new list with 2 elements: a and b! Most IO apis accept IoLists.
I was not confortable to change all that in Nitrogen and since I don't use a lot of Nitrogen's features, I decided to created a Tiny Web Framework.
What's done yet?
Not much! I only worked on it few hours on my free time.
The current features are:
- create HTML using lists of records almost like in Nitrogen
- simple templating system
- api to get QueryStrings
- based on cowboy: well-documented, fast, handles IoLists…
Here are the features I need that I should implement for a 0.1 version:
- session handling
- create more DOM elements
There is already a TODO-list for v0.2 which aims at optimization and documentation:
- have a template cache
- add spec
- add documentation
- do not use the process registry to store the context