Parkaby: Faster HTML Generation with Ruby
Why's Markaby is a really convenient bit of Ruby for generating HTML in your applications, rather than having to fiddle about with string interpolation or ERb, tangling together HTML and Ruby.
However, Markaby can be slow compared with other options like Erubis or HAML. Magnus Holm has been working on an alternative solution called Parkaby, which uses ParseTree for improved performance (coming out up to 20 times faster than Markaby in Magnus's tests). Parkaby uses near-identical syntax to Markaby, so you still get to write beautiful ruby code for building your HTML.
Parkaby { html { head { title "happy title" } body { h1 "happy heading" a "a link", "href" => "url" } } }
Magnus admits that Parkaby is currently only experimental, and that there's room for more optimization, but I think he might be onto something. Parkaby is available on Github.
July 9, 2009 at 9:28 pm
Why not just fork and improve Markaby?
Why's everyone out to get _why?
Why?
Why?
Whyyyyy?
July 9, 2009 at 9:36 pm
What about erector ( http://erector.rubyforge.org/faq.html ) ?
July 9, 2009 at 9:41 pm
Because Parkaby isn't a modified Markaby, it's something completely different. However, I might learn some tricks I can apply to Markaby later :-)
Expect a few Sexp-related libraries coming from here (with the help from Adam Sanderson) in the near future...
July 9, 2009 at 9:48 pm
Stephen: I think he has bigger fish to fry, so any libraries that compete with his are really just natural evolutions in their respective areas. I mean, gem installed Markaby didn't even work with Ruby 1.9 as of a month ago (perhaps it does now, I don't know).
July 9, 2009 at 9:52 pm
ERB! ERB! ERB! :D
July 10, 2009 at 12:36 am
Trying to improve on _why's work isn't the same as being "out to get him" I would guess that your question was at least partially tongue-in-cheek, but nonetheless I feel it's worth pointing out that even those who create competing technology generally give him a lot of credit for his contributions. Aaron Patterson ("Tenderlove") has said complimentary things about Hpricot's API, but set out to write something much faster.
Filling a need that is felt by many many Rubyists is not the same as making a personal attack against the creator of a similar piece of software.
July 10, 2009 at 2:39 am
Yeesh, you guys - I was being totally facetious. :)
I was trying to poke gentle fun at The Great XML Parser Battles of Yesteryear and _why's writeup about the (allegedly) biased shootouts.
More libraries to fill a common need is a great thing, and Parkaby looks very cool.
So, just joking around is all.
July 10, 2009 at 3:56 am
Stephen: You forgot to say "Why's everyone out to get Stephen?"
July 10, 2009 at 4:44 am
Yes, I thought so, but it wasn't clear to me just where the facetiousness began in your comment: at the 3rd line, at the 2nd line, or at the 1st line?
July 10, 2009 at 9:15 am
'kay but still at the end it ends up with a dozen of similar libraries that pretty much do the same thing.
"it's faster than the almost exactly previous same one [wich sucked] and look, I've done better".
Ruby/rails is really more about creativity I think than any other language, wich is cool, but sometimes I kind of feel bored to have the impression that everybody's trying to make it's thing on it's own, alone; and then give it to all saying it's more cool than the one it's totally been inspired by.
We're here with another html renderer…
Can we talk about the html/xml/whatever parser ? hoW MANY ARE THEY ?
I sure don't get fully the point right here; but also sure that it creates a wonderful mess that weaken the whole stuff.
July 10, 2009 at 3:49 pm
Just curious on how to use Parkaby on 1.9? ParseTree doesn't work on 1.9 so i don't see a reason to use Parkaby.
And we all want to use 1.9 asap, right?
July 10, 2009 at 10:44 pm
Why is everyone out to get everyone who are out to get everyone? C'mon.
July 11, 2009 at 12:48 am
@DrNic : Metapersecution FTW!
July 12, 2009 at 1:22 am
Is this faster parsing time or execution time?
=r
July 13, 2009 at 12:26 pm
to answer my own question: it's execution time.