Live data from Hacker News

Mithril.js – A modern client-side Javascript framework

mithril.js.org

71–80 of 83 posts

Re: Mithril.js – A modern client-side Javascript framework

#71
Can someone summarize with an example that shows why this has benefits over React? I read the first few examples and it seems simple enough, but I've bought into the whole JSX benefit and don't see how those first few examples allow me to write less code and code that is closer to the HTML I'll eventually be rendering. Is it the tooling that mithril allows me to forget about? Is it something special that mithril gives me a novice who doesn't realize I'm being held back by using React?

Re: Mithril.js – A modern client-side Javascript framework

#72
post #71

Can someone summarize with an example that shows why this has benefits over React? I read the first few examples and it seems simple enough, but I've bought into the whole JSX benefit and don't see how those first few examples allow me to write less code and code that is closer to the HTML I'll eventually be rendering. Is it the tooling that mithril allows me to forget about? Is it something special that mithril give…

I've also bought into JSX. I use JSX in all my Mithril projects.

Advantages over React: Routing built in. Smaller/faster. You don't get numb to the word "dangerously" being used routinely for data that you trust.

Debatable: Mithril does not wrap native browser events. This is an advantage because what you learn about events applies outside the framework. It may also be a disadvantage; debatable.

Disadvantage: React is a more attractive keyword on your resume and in job listings.

EDIT: Forgot my example - https://medium.com/front-end-hacking/how-it-feels-to-learn-j...

Re: Mithril.js – A modern client-side Javascript framework

#73
post #71

Can someone summarize with an example that shows why this has benefits over React? I read the first few examples and it seems simple enough, but I've bought into the whole JSX benefit and don't see how those first few examples allow me to write less code and code that is closer to the HTML I'll eventually be rendering. Is it the tooling that mithril allows me to forget about? Is it something special that mithril give…

(Mithril author here)

Usually, what I hear from folks is that you come out of using Mithril with more transferable knowledge than something like React.

One example that comes to mind was when someone realized you could implement an incredibly simple atomic CSS composition framework by basically doing this:

    /* some atomic CSS */
    .primary-color-700 {color:blue;}
    .pad-700 {padding:1em;}

    /* a bog standard CSS selector string */
    const MyWidget = '.primary-color-700.pad-700';

    /* a Mithril element */
    m(MyWidget) //  in JSX
So you can get a fairly aggressive CSS optimization scheme for basically free, and you can iteratively improve the quality of your atomic CSS as you learn more about plain CSS / semantic taxonomy practices. And meanwhile, you're still just writing bog standard CSS and Mithril templates. There's no compile-time shenanigans to dedupe styles, no extra library runtime, and CSS is actually CSS so if you server-render you stay on the browser's streaming rendering happy path instead of waiting blocked on scripts.

Now compare with what one would do with most frameworks: one would pick some CSS-in-JS library, get things done and over with, but probably learn nothing interesting in the process and have little idea of what sort of code is actually getting shipped to customers.

Re: Mithril.js – A modern client-side Javascript framework

#74

Earlier quoted context omitted.

> can dive into a React project and fix an issue because I don't carry the baggage of doing things "the react way". Would they not want your solution to conform to existing solutions; which (regardless of being idiomatic to React) would be idiomatic to the codebase?

I usually find the issue, point it out, then they make sure they implement the fix in a way that is not alien to their codebase. It's not many hands on one project but everyone taking care of their own projects, so it's a bit different where I'm at right now.

Some people are way better at finding issues than others, even in other's code bases.

Another good skill to have though, that is unfortunately not super duper common either, is being able to figure out and match conventions and patterns in code bases when introducing changes.

Re: Mithril.js – A modern client-side Javascript framework

#75
post #73
post #71

Can someone summarize with an example that shows why this has benefits over React? I read the first few examples and it seems simple enough, but I've bought into the whole JSX benefit and don't see how those first few examples allow me to write less code and code that is closer to the HTML I'll eventually be rendering. Is it the tooling that mithril allows me to forget about? Is it something special that mithril give…

(Mithril author here) Usually, what I hear from folks is that you come out of using Mithril with more transferable knowledge than something like React. One example that comes to mind was when someone realized you could implement an incredibly simple atomic CSS composition framework by basically doing this: /* some atomic CSS */ .primary-color-700 {color:blue;} .pad-700 {padding:1em;} /* a bog standard CSS selector st…

This is really useful. Thank you.

Re: Mithril.js – A modern client-side Javascript framework

#76

Earlier quoted context omitted.

I'm saying Mithril is a simpler alternative to React, not React-like. Preact is react-like (same API as react); Mithril isn't.

jQuery is simpler than React. HTML is simpler than React. What a weak selling point, then.

It seems you're missing the point. React and Mithril both employ virtual DOM, both use components and both allow higher abstractions that provide ways to manage complexities that arise in front-end development. Jquery and HTML don't do that.

I tried both Mithril and React and found Mithril to be simpler than React as it 'gets out of the way'.

I invite you to read this for more detailed comparison :

https://mithril.js.org/framework-comparison.html#react

Re: Mithril.js – A modern client-side Javascript framework

#77
I recently rediscovered Mithril.

I needed to build a fairly complex tree-table in our legacy ES5 app and I initially turned to Vue to build the first prototype. I'm a big fan of Vue, but for the first time with Vue I found myself really fighting against the framework. In particular Vue's templating system and lack of template fragments make it hard to create complex HTML table elements as they require a strict structure. Another issue is our ES5 app already has its own build system so we'd either be stuck with using Vue without Webpack (which in Vue is a really inferior experience) or attempting to use both build systems which is a bit cumbersome.

While researching Vue template fragments I discovered Mithril has had support for fragments since its inception (React recently also added support for fragments). I had always discounted Mithril. I'm not sure why. Perhaps it's the simple homepage, the seemingly brief documentation, hyperscript, or the lack of HN hype. Wow was I ever so wrong. The documentation is short because the API surface area is tiny and this is a GOOD thing. I never felt like I was writing framework code or trying to figure out the Mithril way of doing things. It pretty much gets out of your way. Hyperscript, which I thought I would hate, turned out to be one of my favorite parts of using Mithril especially when I paired it with Tailwind CSS. Since Hyperscript is pure JavaScript, doesn't require a build step, and is the standard way of writing Mithril components, integrating Mithril into our legacy JS app was absolutely dead simple.

Re: Mithril.js – A modern client-side Javascript framework

#78
As web-development is not my primary trade, I found that MithrilJs was the right amount of abstraction to get into it. Small API, modular, as close to Javascript as it could get and with the help of the folks in the Gitter channel and the invaluable pearls of wisdom in Leo's blog in the earlier days of the framework, my code became more functional and much more readable. For me, it's kind of the swiss army knife of Frameworks.

Re: Mithril.js – A modern client-side Javascript framework

#79
post #8

A lighter-weight and largely API-compatible replacement for React: Preact. https://preactjs.com/

And it is even smaller than Mithrill, Preact being 3kb and Mithril 8kb.

mithril.js includes a router and an ajax helper (that is much simpler than fetch)

If you include those in preact they may have similar size.

Post reply on HN