3 ms·
It's very interesting and neat and I hope they keep making progress, but one big question that I'm left with is why this is better than using an embedded DSL.
by mattfenwick 12y ago
It's very interesting and neat and I hope they keep making progress, but one big question that I'm left with is why this is better than using an embedded DSL.
This is supposed to be addressed on page 2, but the example is kind of a strawman:
> 1 let webpage : HTML = HTMLElement(Dict.empty(), [BodyElement(Dict.empty(),
> 2 [H1Element(Dict.empty(), [TextNode("Results for " + keyword)]),
> 3 ULElement((Dict.add Dict.empty() ("id","results")), to_list_items(query(db,
> 4 SelectStmt(["title", "snippet"], "products",
> 5 [WhereClause(InPredicate(StringLit(keyword), "title"))]))))])])
Although they claim that it's "too cognitively demanding for comfort", there are many ways that it could be improved without resorting syntax extensions, for example:
> 1 let webpage : HTML = HTML({}, [Body({},
> 2 [H1({}, ["Results for " + keyword]),
> 3 UL({"id": "results"}, to_list_items(query(db,
> 4 ... etc. ...
Another reason to prefer an EDSL over syntax extensions for writing HTML is that an EDSL won't require that you write the close tags!
This isn't to say that they're wrong, it's that I think they need to do a better job of comparing their approach with EDSLs.
----
EDIT: does anybody know how to do code formatting in HN posts? It looks so ugly the way I did it.
- tempodox 12y agoOne of the many obscurities here: https://news.ycombinator.com/formatdoc I used Google to find that.
- mattfenwick 12y agoFormatting thanks to @tempodox: ---------------- It's very interesting and neat and I hope they keep making progress, but one big question that I'm left with is why this is better than using an embedded DSL. This is supposed to be addressed on page 2, but the example is kind of a strawman: let webpage : HTML = HTMLElement(Dict.empty(), [BodyElement(Dict.empty(), [H1Element(Dict.empty(), [TextNode("Results for " + keyword)]), ULElement((Dict.add Dict.empty() ("id","results")), to_list_items(query(db, SelectStmt(["title", "snippet"], "products", [WhereClause(InPredicate(StringLit(keyword), "title"))]))))])]) Although they claim that it's "too cognitively demanding for comfort", there are many ways that it could be improved without resorting syntax extensions, for example: let webpage : HTML = HTML({}, [Body({}, [H1({}, ["Results for " + keyword]), UL({"id": "results"}, to_list_items(query(db, ... etc. ... Another reason to prefer an EDSL over syntax extensions for writing HTML is that an EDSL won't require that you write the close tags! This isn't to say that they're wrong, it's that I think they need to do a better job of comparing their approach with EDSLs.