Skip to content

Small clarification to perf results in README #8

Description

@weavejester

You have some very concise and clean code in Huff, and for that to result in a faster overall parser than Hiccup is impressive! So first, let me offer my congratulations for what looks like a great library.

However, you may want to change:

Performance: 29% faster than hiccup/hiccup

To:

Performance: 29% faster than hiccup/hiccup for runtime-generated HTML (i.e. without pre-compilation)

Or something to that effect. Hiccup uses pre-compilation when passed literal value, whereas Huff, I believe, does not. This means performance can differ significantly depending on how much literal data is passed. For example in Hiccup:

(defn greeting [name]
  (hiccup.core/html [:div.example "Hello " [:em name]]))

Is macro-expanded to:

(defn greeting [name]
  (str "<div class=\"example\">Hello <em>" name "</em></div>"))

(For hiccup2.core/html it gets a little more complex as it has to account for automatically escaping unknown strings, but overall it's the same principle.)

This is obviously very fast because it just uses string concatenation, and will outperform a runtime parser. That's not to say a faster runtime parser like Huff couldn't be more useful in general, but it is worth clarifying.

On the subject of things worth clarifying, you may also want to mention that Huff has support for both Reagent-style fragments and Hiccup-style fragments in the form of lists. i.e. it looks like:

(defn twins [x] (list
                 [:div.a x]
                 [:div.b x]))

(h/html [:span.parent [twins "elements"]])

Will work correctly in Huff, at least judging from the tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions