Vue even has a lighter alternative called Moon[1], which was on HN a while back. I'm curious as well about the performance of HyperApp. Looking at the JS frameworks benchmark[2], it's not the best, but not the worst either (pretty good for squeezing it all into 1kb).
[1] http://moonjs.ga
Hyperapp doesn't outperform DIO.js, but that was never the mission I embarked on with this project. You can see it benchmarked <https://rawgit.com/krausest/js-framework-benchmark/master/> among many other frameworks and you can see it's on the same ballpark as React.
The goal of this project is to minimize the concepts you need to learn to write a modern frontend app while staying on par with what other libraries can do; deliver good performance, but not at the sake of a clumsy or awkward API; reduce the boilerplate and still follow our "simplified" take on Flux or the Elm architecture if you prefer.
Hyperapp is unreservedly functional, we don't have stateful components, use `this`, classes or have more than one way to do the same thing.
We are not just about saving bytes either, but size and our brutally small code base is important for a few reasons. The idea behind the entire thing being 300 LOC is that _anyone_ can understand how everything works within a few hours. It's genuinely possible to understand not just what it does, but how it does it.
IMHO a normal person can't do that with React, or DIO, or most of the other large-ish frameworks out there. Even Preact, I found it too large for my taste. Yes, minified and gzipped is like 3.4 KB, but that translates to almost 800 LOC. It's an outstanding achievement considering it's just a fraction of React, but you are only getting React+ReactDOM.
Hyperapp is not perfect, but you are getting React+ReactDOM+Redux+ReduxThunk out of the box.
Just for a light (and harmless) comparison, this is a +/- counter in DIO.js:
class Counter {
getInitialState () {
return {
count: 0
}
}
increment () {
return {
count: this.state.count + 1
}
}
decrement () {
return {
count: this.state.count - 1
}
}
render () {
return [
this.state.count,
h('button', {onClick: this.increment}, '+'),
h('button', {onClick: this.decrement}, '-')
]
}
}
dio.render(Counter);
And here is the same in Hyperapp: app({
state: 0,
actions: {
add: state => state + 1,
sub: state => state - 1
},
view: (state, actions) =>
<div>
<button onclick={actions.add}>+</button>
<h1>{state}</h1>
<button onclick={actions.sub}>-</button>
</div>
})For the comparison example you did, don't post it anywhere officially :P because I can use babel with jsx preset (I am sure hyperapp is using too) and then do the stylish lambdas to make code look cleaner. That would be a fair comparison.
In my experience over the past few months, HyperApp works very well, the documentation is solid, the performance is great, and we've encountered no bugs so far.
If I had to do it over again, I would choose HyperApp again. Great work, folks.
Show HN: 2 MB JavaScript library for building front end applications with a lot of useful interactive ui components.
The fight for really small frameworks is most relevant for consumer apps, especially ones consumed on mobile.
But even on mobile, it's primarily relevant because customers get minimal value from your app or are bad at accurately assessing the value they get.
In my day job, I work on a system where business users spend several hours a day using it. Loading a MB of minified JS has such a limited effect on the overall time it takes users to get their work done, it's almost irrelevant. Though, per the point about accuracy above, I wonder how it affects our demos.
I sure missed the simple, small, usable, multi page site we used before the "upgrade" to the single page app competitor! (On top of that, the old one worked fine on mobile. The new one, not at all.)
Everything old is new again...
That code is not directly consumed by the browser, instead, it's compiled into the code below by a compiler like Babel, minified and bundled into a tiny blob of code we ship to the browser.
app({
state: {
count: 0
},
view: (state, actions) =>
h("main", {}, [
h("h1", {}, [state.count]),
h("button", { onclick: actions.down }, "-"),
h("button", { onclick: actions.up }, "+"),
]),
actions: {
down: state => ({ count: state.count - 1 }),
up: state => ({ count: state.count + 1 })
}
})
So, I used JSX for "familiarity", but you don't need to use it to build your own apps. You can just write the code shown in the snippet above and you'd do just as well. You can also minimize and bundle your code to tap into the JavaScript ecosystem, code using a modular style and still not have to use JSX at all.Hope that helps :)
Coincidentally, the h() function up there looks very similar to what we used to render HTML in a 15-year-old Perl application that I maintained at work.
The whole library would be documented on one page which is a fairly low entry barrier for new developers. Thanks for this awesome project!
Perhaps a tutorial, or some examples can be documented in that style. Hyperapp + hyperscript-helpers[2] is my favorite combo at the moment.
1. http://dave.kinkead.com.au/modelling-the-boundary-problem/
If you are interested have a look here:
https://gist.github.com/jbucaran/8dc33b7947f3193eb2ea3d5700e...
https://news.ycombinator.com/item?id=13605673
It only works in modern browsers supporting Proxy.
https://facebook.github.io/react/docs/lists-and-keys.html#ke...
(Great project, BTW!)
Site: https://audiostream.world Repo: https://github.com/joextodd/audiostream
Site: https://browses.io Repo: https://github.com/browses/frontend
Site: https://plural.video Repo: https://github.com/lukejacksonn/plural
Site: https://hyperapp-hn.deployable.site Repo: https://github.com/lukejacksonn/hyperapp-hn
There is also https://github.com/hyperapp/awesome-hyperapp which is full of much community goodness.
Hope that helps! Join us on slack if you have questions :]