Earlier quoted context omitted.
> One of the huge advantages of Maud is that it keeps code and markup close together I'd say it's actually a disadvantage. Front end engineers will work with HTML with embedded logic (as little as possible - values, iterators, conditionals). Generating HTML from Rust code is nice for simple things, but won't work with complicated HTML templates when those are required and will be harder to integrate with front-end ap…
My projects have no front-end engineer, however. The frontend is written in Rust as well and also uses Maud for HTML templating. And I dispute it not working with complicated HTML templates, that's handling it fine and integrates very well since I share code between frontend and backend anyway.
Maud: A Rust macro for writing HTML
31–40 of 86 posts
Re: Maud: A Rust macro for writing HTML
#32Earlier quoted context omitted.
My projects have no front-end engineer, however. The frontend is written in Rust as well and also uses Maud for HTML templating. And I dispute it not working with complicated HTML templates, that's handling it fine and integrates very well since I share code between frontend and backend anyway.
I get that, but Maud is not the first of its kind and the absence of similar engines in web development is a telltale sign it's not the optimal approach.
So even if it's not the "optimal approach" as you title it, it's the ergonomic approach for me because it doesn't get in my way.
Re: Maud: A Rust macro for writing HTML
#33People like to hate everything related to JS these days. But when I see libs like these I'm just very grateful for the person(s) who invented JSX [1]. And evenly for MSFT implementing it into TS as a first-class citizen. It's just so much more readable. Scala is the only other language I know of which has some kind of XML/HTML syntax support (scala.xml). (But it looks like it got removed. [2]) [1] https://reactjs.org…
IIRC php/hack had it before jsx existed: https://docs.hhvm.com/hack/XHP/introduction https://github.com/phplang/xhp
XHP was launched in 2010 (https://www.facebook.com/notes/10158791323777200/)
The first version of FaxJs (the precursor to React) was launched in 2011, being directly inspired from XHP (https://github.com/jordwalke/FaxJs)
React was made in 2012 by the same person who made FaxJs, taking the best ideas from FaxJs and creating React.
So yeah, JSX actually comes from the idea of XHP :)
Re: Maud: A Rust macro for writing HTML
#34Earlier quoted context omitted.
IIRC php/hack had it before jsx existed: https://docs.hhvm.com/hack/XHP/introduction https://github.com/phplang/xhp
That's actually the heritage of JSX! XHP was launched in 2010 ( https://www.facebook.com/notes/10158791323777200/ ) The first version of FaxJs (the precursor to React) was launched in 2011, being directly inspired from XHP ( https://github.com/jordwalke/FaxJs ) React was made in 2012 by the same person who made FaxJs, taking the best ideas from FaxJs and creating React. So yeah, JSX actually comes from the idea of XH…
The concept was popular at Facebook, so it made its way into HPHP, HHVM, and later ReactJS.
Re: Maud: A Rust macro for writing HTML
#35Maud is wonderful for small things like a stats page or dashboard. But once you start getting to a few pages it's so much less cognitive overhead to separate concerns out into proper html files/templating. It seems quite daunting to have a large project where all your html is inside rust files and a lot harder to find people who can work on it proficiently.
One of the huge advantages of Maud is that it keeps code and markup close together, so you can do things like having rust control structures determine what markup is used later on (for snippets or widgets, for example). Plus, Maud has a definitive speed advantage from what I've noticed. Sadly, there isn't any great alternative for making performant HTML templates in Rust from what I've seen, a lot of the other HTML t…
https://djc.github.io/askama/creating_templates.html#the-tem...
Regardless, it's good to see some variety and experimentation like Maud in software design
Re: Maud: A Rust macro for writing HTML
#36People like to hate everything related to JS these days. But when I see libs like these I'm just very grateful for the person(s) who invented JSX [1]. And evenly for MSFT implementing it into TS as a first-class citizen. It's just so much more readable. Scala is the only other language I know of which has some kind of XML/HTML syntax support (scala.xml). (But it looks like it got removed. [2]) [1] https://reactjs.org…
Re: Maud: A Rust macro for writing HTML
#37Earlier quoted context omitted.
I find that very interesting, I have the opposite reaction to JSX. Not wanting to use it has been one of the biggest reasons I have moved into using ClojureScript/Hiccup for front-end applications. I find JSX extremely hard to read and work with and reason about.
After you get a taste of the free world of hiccup/reagent where it's just vectors and maps to create HTML, its really hard to imagine going back to anything else. Being able to use the same programming language in your "HTML template" (which are just core data structures in a specific shape) as for the rest of your programming is just icing on the top. Small example for people to understand the difference: // HTML &…
In JSX you might be struggling with expressing certain things, because JS has a statement expression syntax. So you have to circumvent that. In Clojure everything is an expression already.
In JSX you can manipulate components with HoCs. In Clojure it’s just data, no special ceremony needed.
On the client, if you’re using React, you might use hooks to keep travk of state, which are a special construct that don’t exist in JS. In Clojure, if you use something like reagent, you just use atoms, they have a special purpose implementation, but they look and feel like regular old atoms.
However I have to say, JSX and React are very productive even with those limitations, simply because the tooling around it is so good.
Re: Maud: A Rust macro for writing HTML
#38Earlier quoted context omitted.
Totally agree, macros are the worst Rust feature for me, they are way too powerful and break the tooling, e.g. fmt or language server. https://rust-analyzer.github.io/blog/2021/11/21/ides-and-mac...
It ultimately depends on how they're written. println! is a macro, and doesn't "break the tooling". on the other end of the spectrum, using a crate like demonstrate (unit testing) produces hard to understand errors and slows down the IDE. I don't remember experiencing Rust Analyzer crashes for a long time, though (I do remember some in the past).
The declarative macros aren't too head-twisting for tools, they just expand as declared, this can sometimes have a few surprising effects but generally it is very manageable. Procedural macros have essentially unlimited power and thus are sometimes entirely impossible to analyse.
Re: Maud: A Rust macro for writing HTML
#39The main problem with macros like this (aside from being yet another language to learn) is that they don't work nicely with IDEs.
Re: Maud: A Rust macro for writing HTML
#40People like to hate everything related to JS these days. But when I see libs like these I'm just very grateful for the person(s) who invented JSX [1]. And evenly for MSFT implementing it into TS as a first-class citizen. It's just so much more readable. Scala is the only other language I know of which has some kind of XML/HTML syntax support (scala.xml). (But it looks like it got removed. [2]) [1] https://reactjs.org…
I don't think JSX is very readable. If you squint it may look like HTML, but when you try to actually read it, it's all off. Different attributes, bizarre templating, blurred line between rendering and code. The latter in practice is always a complex mix of view/state/ callbacks with react.
This is a very common confusion because most people approach JSX via React, and as such never really grasp that JSX is a separate, independent thing. If you're interested in learning it standalone, I'd highly recommend working with either the Typescript `jsxFactory` compiler option, or the `@babel/plugin-transform-react-jsx`