I just think more languages should support an idiomatic form of quasiquoting [1], then we may finally begin to stop seeing new JSX implementations everywhere.
For Ruby it's strange somebody would prefer to write JSX instead of something like dhtml [2] or [3], are there any other advantages of writing xml directly in the code instead of a small html DSL?
I’m not sure other languages can do “quasiquoting” very easily. Like, JS has template strings, but that’s not “quasiquoting” because the string content is unstructured. Lisp, though, can do this quite easily because it can still parse the unevaluated content with enough structure, and indeed can get you the same benefits I discuss in my article (like making wrapper component functions that directly access the list of children).
As for preferring to write XML directly in my code…95% of my goal is to just deliver XML to the browser. I’d rather just write XML. And honestly the way text nodes are handled in other DSLs seems quite bad to me. I’d much rather write `long paragraph, <strong>emphasis,</strong> long paragraph` than HEREDOC-style long strings that I have to start and end every time I want some inline formatting.
All the examples I see of HTML DSLs are heavy on structure but conspicuously lacking text. For me the text is _the whole point_. I don’t want to worry about string escaping when writing a blog post.
Hi, saw the post on Lobster [1] but didn't have an account there even if that post was more active.
I'm sure it was fun porting the Lua parser to Go and all but I wanted to let you know that Lua is very powerful on its own for making very nice DSLs, for example it can be used to make an HTML Builder DSL akin to JSX within the language itself (and by the way I think it's far more readable than JSX or XML) [2] and also some build tools use it as a base language [3]
4 comments
[ 2.9 ms ] story [ 20.6 ms ] thread- Javascript / Typescript
- Lua (this)
- Go ( https://templ.guide )
- Ruby ( https://github.com/camertron/rux )
Any others?
For Ruby it's strange somebody would prefer to write JSX instead of something like dhtml [2] or [3], are there any other advantages of writing xml directly in the code instead of a small html DSL?
[1]: https://xelaso.net/blog/jsx-quasi-quoting/
[2]: https://github.com/hi5dev/dhtml
[3]: https://stackoverflow.com/questions/23469834/ruby-metaprogra...
As for preferring to write XML directly in my code…95% of my goal is to just deliver XML to the browser. I’d rather just write XML. And honestly the way text nodes are handled in other DSLs seems quite bad to me. I’d much rather write `long paragraph, <strong>emphasis,</strong> long paragraph` than HEREDOC-style long strings that I have to start and end every time I want some inline formatting.
All the examples I see of HTML DSLs are heavy on structure but conspicuously lacking text. For me the text is _the whole point_. I don’t want to worry about string escaping when writing a blog post.
I'm sure it was fun porting the Lua parser to Go and all but I wanted to let you know that Lua is very powerful on its own for making very nice DSLs, for example it can be used to make an HTML Builder DSL akin to JSX within the language itself (and by the way I think it's far more readable than JSX or XML) [2] and also some build tools use it as a base language [3]
[1]: https://lobste.rs/s/oubncm/i_made_jsx_for_lua_because_i_hate...
[2]: https://leafo.net/guides/dsl-in-lua.html
[3]: https://xmake.io/#/getting_started