Live data from Hacker News

Alternative lightweight UI library to modern day frameworks

mithril.js.org

71–73 of 73 posts

Re: Alternative lightweight UI library to modern day frameworks

#71
post #15

Earlier quoted context omitted.

Mithril author here. Curious what version you were using. There have been some notable internal changes to the engine over the years. The 1.0 release was a complete rewrite of the previous codebase, and included a very aggressive optimization inspired by inferno.js (called node recycling) that turned out to cause issues in some edge cases and didn't materialize significant enough performance benefits given the added…

Hey Leo, Yeah we reported a few bugs over the years and many of them got fixed. We were using Mithril 0.x. We did get the product to a point where it was very stable, but there were patterns that we had to avoid (for example, at the time IIRC we had spooky bugs with children cycling between an element, a list of elements, or an empty array []). In the end, the reason that we moved away from Mithril.js was that as a 3…

> We were using Mithril 0.x

Ah, yeah things have improved a lot since the 0.x days.

> I built a MVP prototype in Angular and the performance was so bad

I hear you. Having issues with Angular.js performance at work was the reason I started Mithril.js.

It's always interesting to hear war stories :)

Re: Alternative lightweight UI library to modern day frameworks

#72
post #41

I used to use mithril for almost every new project I'd start, but I've switched over to using React w/ Hooks for just about everything for two main reasons: - toolchain support is a lot less finicky and better supported (you can use parcel and it "just works") - should I need to bring in a obnoxious third party library, it's far more likely to exist in a react world than mithril If you're just building something smal…

I dunno, I see a lot of react codebases at my day job, and my experience is that libraries are all over the place. The really popular libs are often framework agnostic (e.g. lodash, date-fns, etc), but there's also a long tail of questionable quality libs: some react packages only work with webpack, some use unusual idioms (e.g. having to reference a node_modules path for some css, which doesn't fly with yarn 2), som…

Hi Leo. Thanks for creating Mithril.

Likewise at work I currently have to deal with React and its challenges. I have previously built other applications in Mithril (and still do in my spare time). I much prefer Mithril and lobbied for its use at work. But sadly React has so much mindshare which was persuasive to management. The only plus to that situation of using React was that I increasingly saw firsthand how much better the developer ergonomics are for Mithril over React -- and eventually wrote the essay about that linked below called "Choose Mithril". :-)

As an example on libraries and React patterns, the emphasis on Redux for React in particular can rapidly create messy bloated codebases that are hard to maintain. That is due to the accidental complexity in React by its premature optimization of requiring use of setState() on components to queue redraws -- which Redux then tries to hide to support global state. Mithril by contrast makes it possible for developers to store state however they want by the brilliance of (by default) just assuming any time the user touches the UI (via anything with an added event handler like for a button press) that the UI needs to be rerendered (unless the developer choose otherwise).

Here's a longer list of reasons why I prefer Mithril to React: https://github.com/pdfernhout/choose-mithril "tl;dr: Choose Mithril whenever you can for JavaScript UI development because Mithril is overall easier to use, understand, debug, refactor, and maintain than most other JavaScript-based UI systems. That ease of use is due to Mithril's design emphasis on appropriate simplicity – including by leveraging the power of JavaScript to define UIs instead of using an adhoc templating system. Mithril helps you focus on the essential complexity of UI development instead of making you struggle with the accidental complexity introduced by problematically-designed tools. Many popular tools emphasize ease-of-use through looking familiar in a few narrow situations instead of emphasizing overall end-to-end simplicity which -- after a short learning curve for Mithril -- leads to greater overall ease-of-use in most situations."

And a key point from the conclusion: "The fact that Leo Horie's Mithril -- a project started by one brilliant, kind, and generous person and now supported by a few volunteers -- can attract as much interest and support as it does relative to Facebook's React and Google's Angular (both backed by millions of dollars of paid development and free publicity) implies a lot about Mithril's technical advantages and developer ergonomics."

As another example, over the winter vacation, I helped my kid make an interface in Mithril+HyperScript+Tachyons as a graphical memory monitor for Windows with a simple Node.js backend. He had essentially never used JavaScript before but had previous used Lua for game scripting, C++ for the Arduino, and a bit of Java for Minecraft. And while he still would have a lot to learn about HTML/CSS/JavaScript to do Web UI stuff entirely on his own, now at least he knows he could build more such interfaces -- including for embedded devices. Mithril+HyperScript+Tachyons essentially just was so easy to use and explain that it got out of the way -- and so almost all our time was spent discussing JavaScript issues, and the application design, and other libraries the application needed. That ease of learning Mithril shows how it is a mistake for management to choose React on the assumption that they need to pick the most popular platform to have the easiest hiring of developers. Mithril's short learning curve means even if you need to hire UI developers who have never used Mithril, any reasonably competent developer can get up to speed quickly.

In short, Mithril+HyperScript+Tachyons(OrOtherAtomicCSS) is an awesome combination that is much more fun to develop in than React.

You rock, Leo!!! Thanks again for making the programming world a better place.

Re: Alternative lightweight UI library to modern day frameworks

#73
post #32

Earlier quoted context omitted.

I’ve seen Alpine, and it is interesting, but another bullet point in my wish list is vanilla JS; no new template language. JSX is just a small bit of sugar on top of vanilla JS, in my mind, so it is acceptable.

From the brief glance I've taken at Alpine I didn't think it did have a template language - unless you refer to it's use of custom html attributes?

Alpine has directives like x-if and x-for. For a lightweight templating library I would recommend https://pure-js.com. It's been around for ages. The PureJS directives take some time to get used to, but are quite powerful once you do.
Post reply on HN