Earlier quoted context omitted.
Is niché a portmanteau of niche and cliché?
It’s pronounced “NEE-chuh”.
Hyperapp – A tiny framework for building web interfaces
171–180 of 198 posts
Re: Hyperapp – A tiny framework for building web interfaces
#172Re: Hyperapp – A tiny framework for building web interfaces
#173Earlier quoted context omitted.
If you are doing back compat for old browsers, Babel is necessary anyway. Typescript is a choice independent from anything else. There are alternatives to Webpack, none of which have gained traction, possibly because developers appreciate other features that webpack provides out of the box. But, you are complaining about the developer tools, why? The source code size of emacs/vscode/vi is just as relevant, or the siz…
> But, you are complaining about the developer tools, why? The source code size of emacs/vscode/vi is just as relevant I think you have a fair point that if it's not making the build artefacts larger in size it shouldn't be criticized for that. Where the problem arrives is really about cognitive load: If my tools are emacs/vscode/vi or even visual studio or webstorm, I can use these tools, and come back to them in 18…
Or - a much easier tradeoff - just don't use Sass. I mean, Sass isn't without its merits, but if you're already compiling something else down to CSS, you may as well go full CSS-in-JS and get the benefit of a real programming language instead of whatever sharply limited DSL Sass has, that I've totally forgotten about because I haven't needed to touch it in years and I'm honestly a lot happier for that. Yeah, you'll have to look at and vet some new tools, and you'll have to get used to thinking a little differently about how you write stylesheets. But on top of learning the ins and outs of an entire new tooling stack, how much extra cognitive effort is that, really?
There's always going to be tradeoffs. You make the ones that are right for you. And if you find yourself, while investing in a new paradigm, trying so hard to stick with an old familiar tool to the point where it's compromising your efforts to get productive with the new tools - that's a signal to start looking at whether it's time for the familiar old approach itself to be replaced with something that not only composes better with the new paradigm, but, as with CSS-in-JS versus older approaches like Sass or Less, might prove to be a lot better in its own right.
I mean, don't get me wrong, I see a lot of merit in sticking with proven, familiar technologies in which I'm quickly able to be productive. I don't expect I'll ever stop using Emacs, for example, and that's almost as old as I am. Platforms change considerably faster, though, especially in web dev. I started with Emacs eleven years ago, and at that time the frontend "framework" of choice was jQuery - even AngularJS was still a year in the offing - and the closest you could come to a standard backend stack was Rails. But you were more likely to be using something written in PHP, or a hoary old pile of Perl 5, or the like. We've come a very long way since then.
The pace of change has slowed considerably in recent years, I think, and I expect it will continue to do so. But it's not going to stop, and individual tools and stacks will continue to develop regardless. There's always going to be new features, new approaches, better ways of doing things, and some of them are going to be breaking changes. Keeping up with that kind of change, and knowing how to recognize and take advantage of the good, is one of the things it's an engineer's job to do.
Re: Hyperapp – A tiny framework for building web interfaces
#174Earlier quoted context omitted.
> But, you are complaining about the developer tools, why? The source code size of emacs/vscode/vi is just as relevant I think you have a fair point that if it's not making the build artefacts larger in size it shouldn't be criticized for that. Where the problem arrives is really about cognitive load: If my tools are emacs/vscode/vi or even visual studio or webstorm, I can use these tools, and come back to them in 18…
So...don't use CRA? You don't have to, although it does make a lot of things easier, and it's kind of a surprise to see the claim that Webpack encourages its use. I've never run across anything like that in the docs, and I have found those docs to do a good job of covering how to set up and use Webpack, with CRA nowhere involved. Or - a much easier tradeoff - just don't use Sass. I mean, Sass isn't without its merits…
Sure, I can get by fine without that, but then I've got to educate 2 other members of my team, both who can program in numerous languages but are quite inexperienced with web development, how to correctly set up each project using the React/Redux/Sass/Typescript/Jest. I can do it myself and hand them a project template, but then no-one else will learn how to do it. The reason for CRAs existence is (more than any argument I might make) an implicit acknowledgement that setting up new webapps is a far more painful experience than it should be.
> it's kind of a surprise to see the claim that Webpack encourages its use.
It was React that recommended CRA, not Webpack recommending CRA, apologies for my misleading description.
> Or - a much easier tradeoff - just don't use Sass.
I'm already quite familiar with plenty of reasons to not use -or to use- SASS. The point is that as a tech choice it's hardly a minor player, and yet the experience of setting up / migrating a project using easily recognisable tech (React/Redux/Sass/TypeScript) is a long way from a straightforward. In my example, I already had SASS on existing related projects. My team members were already familiar with it. Create-React-App was at the time was also actually already built to include support for SASS - the problem IIRC was that the fork of CRA that added Typescript support was forked from a CRA version before SASS was supported, so (at the time) it was a "one or the other" situation before I forked it and fixed it myself.
> Keeping up with that kind of change, and knowing how to recognize and take advantage of the good, is one of the things it's an engineer's job to do.
It's also part of our jobs to look at processes and procedures identify areas of inefficiency, and to ask questions about what a better way of doing things would look like.
Finally, the trajectory of this discussion is pretty absurd. I'm offering examples of what happens in web development to illustrate that there is a massive difference between treating developer tools like Webpack / CRA as though they're similar to text-editors that you don't have to invest a bunch of time to understand and keep up to date with (a point that if I'm understanding you right, you likely agree with). My comment above's central claim is: that while critiques on size of dependency chain of developer tool like CRA or WebPack might be misguided, they are hardly lightweight cognitively, and the choice to use these tools (or not use them) isn't something to just take lightly because we clarified that our deployed artefacts didn't balloon in size.
Re: Hyperapp – A tiny framework for building web interfaces
#175Earlier quoted context omitted.
It's my fault for not fully understanding the functional universe I was getting into when I first started working on Hyperapp. The latest Hyperapp is more strict, but it's all in good measure. Lifecycle events are impure, that's why they're no-good. I can tell you that Hyperapp is not for everyone. If you want to write pure, immutable, functional JavaScript and think hard about client side app architecture (unidirect…
If we talk about functional API, did you consider providing a push method, like with a Promise, to express the updating of an effect or a subscription ? (the function 'update' in the code below) app({ init: 0, view: state => h("div", {}, [ h("h1", {}, state), h("button", { onclick: (state, event, update) => { window.setTimeout(() => update(state => state - 1), 1000); } }, "subtract"), h("button", { onclick: state =>…
import { h, app } from "hyperapp"
import { delay } from "@hyperapp/time"
const Decrement = (state) => state - 1
app({
init: 0,
view: (state) =>
h("div", {}, [
h("h1", {}, state),
h("button", {
onclick: (state/*, event*/) => [state, delay(100, Decrement)],
}, "subtract"
),
h("button", { onclick: (state) => state + 1 }, "add"),
]),
node: document.getElementById("app"),
})
See how you never actually called setTimeout as that would be a side effect.Instead, we have "controlled effects" in Hyperapp. This `delay` function doesn't even call setTimeout itself, but return an object that tells Hyperapp how. Just like how `h("button")` or `` with JSX doesn't actually create a button, but an object representation of it.
Finally this part: [state, delay(100, Decrement)], only placed here for convenience (as you'll usually want that in its own action) is how you tell Hyperapp to do the effect when the button is clicked. This is the same (model Cmd) continuation pattern used in Elm.
Re: Hyperapp – A tiny framework for building web interfaces
#176Earlier quoted context omitted.
Not sure of the reason, but it's a godsend comparatively. The reaction against JSX I find to be largely by people who've never actually used it. If you keep your components small, as is best practice, whatever gut reaction one feels to it (which IMO is misplaced to begin with) is minimized, and quite readable.
If you keep your components small, then using this `h` function instead of JSX doesn't make a lot of difference from readability perspective. Also, don't forget that `h` is just a function, so nothing prevents you from creating your convenience functions, which allow more concise/readable code, eg: const div = (...args) => h("div", ...args) const span = (...args) => h("span", ...args) (or something along those lines)…
const define = (componentDefinition) => (props, ...children) => isReactNode(props) ? React.createElement(componentDefinition, {}, props, ...children) : React.createElement(componentDefinition, props, ...children);
const elements = new Proxy({}, {get: (target, tagName, _) => define(tagName)});
// ...
const {div, h1, button, input} = elements;
But although I really disliked JSX at first, once I tried it a little, I realised that it's about making the code describe what you want rather than how to get it. That mind set shift is actually valuable, even if underneath it's still turning into function calls.Re: Hyperapp – A tiny framework for building web interfaces
#177Re: Hyperapp – A tiny framework for building web interfaces
#178Bit of a Hyperapp fanboy here, so bare with me. First, I think Hyperapp can make both small and big applications, opposed to u/PufPufPuf's opinion. A lot of people have this opinion because they are more familiar with v1's wired-in actions, which can become quite unruly. In the latest version, actions are decoupled, and can be organized/extracted however you see fit. I've made a handful of applications in both v1 and…
Your mobtime app does not look like it was built with hyperapp, but instead is using ferp.
Re: Hyperapp – A tiny framework for building web interfaces
#179Bit of a Hyperapp fanboy here, so bare with me. First, I think Hyperapp can make both small and big applications, opposed to u/PufPufPuf's opinion. A lot of people have this opinion because they are more familiar with v1's wired-in actions, which can become quite unruly. In the latest version, actions are decoupled, and can be organized/extracted however you see fit. I've made a handful of applications in both v1 and…
> "A lot of people have this opinion because they are more familiar with v1's wired-in actions, which can become quite unruly." u/PufPufPuf only mentions the lack of ecosystem, nothing about the wired-in actions/etc, so it's odd that you defend v1 vs v2 instead of the lack of ecosystem here. This should probably have been a reply to that thread as well because otherwise it's two very unrelated comments in the list.
Re: Hyperapp – A tiny framework for building web interfaces
#180Earlier quoted context omitted.
If we talk about functional API, did you consider providing a push method, like with a Promise, to express the updating of an effect or a subscription ? (the function 'update' in the code below) app({ init: 0, view: state => h("div", {}, [ h("h1", {}, state), h("button", { onclick: (state, event, update) => { window.setTimeout(() => update(state => state - 1), 1000); } }, "subtract"), h("button", { onclick: state =>…
We built it into the framework, if you happen to be familiar with Elm, this should make sense right away, but here's how you'd write something like that using Hyperapp: import { h, app } from "hyperapp" import { delay } from "@hyperapp/time" const Decrement = (state) => state - 1 app({ init: 0, view: (state) => h("div", {}, [ h("h1", {}, state), h("button", { onclick: (state/*, event*/) => [state, delay(100, Decremen…
But there is worst, the problem with the pattern [state command] is that it doesn't work well with async method, because at the time the command is called, the state which is passed alongside the command and the state maintained by Hyperapp may be different.
With your example, the issue is that Decrement may be called on a previous state and not on the actual state.
The idea of the updater is to provide the function that takes the transition function as parameter, so delay will be written that way
function delay(updater, timeout, fun) {
window.setTimeout(() => updater(fun), timeout);
}
If you want to decrement the state after a delay using the state at that time h("button", {
onclick: (state, _, updater) => delay(updater, 100, Decrement),
}, "subtract")
(from the Hyperapp perspective, the event listener return undefined so you don't have to update the state at the time the event listener is called)and if you want to decrement the state using the state at the time the user click
h("button", {
onclick: (state, _, updater) => delay(updater, 100, _ => Decrement(state)),
}, "subtract")
The other benefit is that because delay() takes an updater as first argument, it's clear that the function delay does a side effect.
Conceptually, the idea is that instead of trying to hide the side effect, you make it clear to the developer (more like Haskell does).