4 ms·
Is the only difference really that Mithril has replaced "React.createComponent" with "m"? The limitations of creating the view in JS seem invisible, yet viscer
by undershirt 11y ago
Is the only difference really that Mithril has replaced "React.createComponent" with "m"?
The limitations of creating the view in JS seem invisible, yet visceral to us. I think the reason it is jarring is a fundamental expressivity problem of JS not being able to match templating logic of Handlebars like for-loops and conditionals, despite JS having these statement constructs.
An elegant templating solution is a result of Lisp's mixing of data and logic, something called Hiccup in the ClojureScript community, which I've written about here [1].
[1]: https://github.com/shaunlebron/jumping-from-html-to-clojurescript https://github.com/shaunlebron/jumping-from-html-to-clojures...
- notNow 11y agoJS is not a templating language and I'm pretty sure you know this already. PHP on the other hand started as a templating language for the web and then grew from there. Handlebars is an application of JS (Node) for templating engines and so is Jade. Even though I still prefer Jade over Handlebars for mostly static/frontend oriented web apps. For people big on JSX, can they tell us please what do they like most about this framework that they don't find equivalents for in Jade or Handlebars for example?
- undershirt 11y agoI'd be interested in hearing what you think about the article I linked then. Jade is so close to Hiccup, except you can use it alongside your code. Jade/Handlebars don't map to React components.
- notNow 11y agoJade can be used along with code too. I think that you mean view logic by code here as mixing business logic with your view is a big no no. I took a look at Hiccup. It looks interesting and promising but I'm an indentation oriented developer and that's why I favor Jade and Sass and the likes. Also, I like the design philosophy that they chose with Jade by absorbing JS in HTML and not the other way around like in JSX where HTML & CSS being subordinates to JS thus making the process a whole lot more tedious and time-consuming.
- undershirt 11y agoto Notnow: > Jade can be used along with code too. I think that you mean view logic by code here as mixing business logic with your view is a big no no. Code is data. Separating concerns by using different technologies to solve the same problem is not simplification. You can separate views from logic as you would separate different functions in code. We can organize that. > I took a look at Hiccup. It looks interesting and promising but I'm an indentation oriented developer and that's why I favor Jade and Sass and the likes. Not liking Hiccup because you prefer indentation doesn't make sense. Hiccup is indented by convention. If you're speaking about the delimiters, those are what keeps it from slipping into limitations shared by JS, Jade, etc. > Also, I like the design philosophy that they chose with Jade by absorbing JS in HTML and not the other way around like in JSX where HTML & CSS being subordinates to JS thus making the process a whole lot more tedious and time-consuming. You don't need to choose an absorption direction between JS and HTML if you treat HTML as what it is, a nested data tree, and realize that templating is the mixing of logic into this data tree. S-expressions in Lisp were designed exactly for this.
- Nemcue 11y agoOne big feature in my mind — and I've used both Handlebars, Mustache, and HTMLbars a lot — is the fact that it compiles straight down to a JS data structure. Especially with Handlebars it's always kind of tricky to debug, because there are all sorts of strange conventions going on, and it ends up being very hard to mentally parse. With JSX (of course the same with Mithril) you get a data structure that is very easy to reason about.
- pygy_ 11y ago> Is the only difference really that Mithril has replaced "React.createComponent" with "m"? The Mithril `m()` was designed to be used as is rather than as a serialization format. It also understands `m("input.bar[type=date]")` which is handy, and the array for children elements is optional (`m(...)` is variadic) which makes it nicer in CoffeeScript-like languages.