I don't mean to knock the effort they've put in here, but this looks like all of the hand-rolled "frameworks" I saw my friends in the agency / consulting space made when they said angular 1 was "too heavy"... right down to the 'data-controller' attribute binding that everyone seemed to independently come up with.
Is there anything actually novel here? These types of things always seemed to run into composition issues (controllers inside of controllers) in terms of communication and what not. The net result was invariably far less appealing than, say, angular 1 or vue or non-SPA React.
Isn't the fact that you've seen a bunch of people already hand-roll this a good indication that there's a need for something like this, so no-one else needs to hand-roll it anymore?
It doesn't need to be novel right? It just needs to be helpful.
Honestly I don't know why I'd want Stimulus over regular old web components if I wasn't going to use a whole library like React. It doesn't look like it adds much beyond what web components already give you.
With 30KB in size, this framework might be something I can integrate into my websites to get a nice look-and-feel while preserving usability when script blockers are active.
Personally, when I work on projects I tend to develop a pure HTML+CSS solution first and then bolt on JS if needed, so this kind of stuff might make me more comfortable with writing proper webapps since it's still just basically "bolt JS on HTML".
I've been using Stimulus + Turoblinks for my current side project and I love it. Nice and simple way to add a bit of interactivity to existing HTML on your page.
I’m not very informed about intercooler, but from the examples it seems to focus on AJAX requests. Stimulus is more about DOM manipulation, things you would’ve used jQuery for (except $.ajax and related). Toggle classes to show/hide things, move things around (mostly also just by toggling classes these days), create/duplicate elements, stuff like that. Stimulus also does some AJAX, but I can easily imagine these two work together in one page for different elements.
If you already use the rails ecosystem and the mental models associated with it, this is a library which will likely feel intuitive to you and fit neatly with the rest.
The ability to think effortlessly about code has value.
I like it a lot, but I'm always afraid that I'll end up running into limitations of the framework if whatever I'm doing happens to grow in scope in a way I hadn't planned for. I tend to be bad at planning ahead for side projects, but who can blame me, they're side projects.
Anyway, just stopping by to say that Vue has struck a good balance for me. Peppering in {{template values}} in existing HTML works really well, and when things start to get more complex I can easily break my dom out into components.
Have it exactly the same way, and especially the vue components are nice to have. It seems like Stimulus would be a good fit for small applications, but as soon it becomes a medium size project it would be to complex to maintain.
I love Vue as well. The problem is that I haven’t found a good way to fit Vue in with an existing Rails app without it resorting to JavaScript hell. Stimulus looks interesting because it already fits in with Turbolinks.
This is good at first look. Because it seems to be straightforward and carefully design. I like the aesthetic and choice of using data attributes being part of the HTML standard as directives to apply the framework.
One criticism I have relates to The syntax for denoting action methods. Did you agonize over the choice of syntax uses hash and implication? E.g.
click->hello#greet
All the same this careful choice shows the effort you put into the framework . I’m just not sure this particular choice is to my taste nor works with regard to being consistent with the rest of the syntactic choices you have made.
Interested to hear thoughts of others in a discussion about this.
I know it is vanilla ES6, but at some point it starts looking more like Java than JavaScript. The boilerplate necessary to convey a simple instruction is directly proportional to the averaged speed of everything else (authorship, maintenance, execution, testing, frequency of reuse, and so forth).
Do you mind expanding on what you mean? When I look at the instructions here, they seem pretty concise.
`export` -> exports the thing
`default` -> if you require from this module, this is the default
`class` -> class definition
`extends` -> speaks for itself
`Controller` class it's extending.
You could maybe rework it so you don't export it on the same line:
```
class Foo extends Controller {}
export default Foo
```
The parallel I see here to Java is the object orientation - which is a fair criticism. There are probably ways to execute on this using other mechanisms other than inheritance. But then, sub-classing to me still feels better than assigning the prototype via direct assignment.
I've never written any java code, but I really love the module systems inspired by it. I've been using this kind of packaging in both javascript and golang, and it actually feels way simpler than in ruby where I'll always end up with `Namespace1::Namespace2::Namespace3::klass` to deal with the global scope of everything.
We wrote a pretty similar (like similar enough its kinda creepy) library[1] a while back and it's really helped speed up our front end dev. I LOVE having params set in data attributes. Makes re-usable modules, like a modal[2]
or autocomplete [3], way easier to implement.
First of all this isnt just another JS framework, The Framework is designed to work better with Rails, it is crafty in terms of how the DSL is designed. DHH is definitely the master of Designing DSL's, look at Rails and Activerecord. This too is excellent DSL design. So no its not for JS People, JS has react and what not. This is mostly geared towards Rails people.
I agree with you that this is a worthwhile comparison to make, but would also point out that you could compare Web Components to any JS framework. When Web Components reach maturity (i.e. when support is baked into browsers and you don't have to fall back on using libraries like Polymer), they'll hopefully signal the end of JS frameworks as we know them, as it'll be easy to mix and match components from multiple sources. Until that time comes, I welcome JS frameworks like Stimulus that can (supposedly) be easily retrofitted onto existing websites, even if I'd prefer to see more activity around Web Components.
zdragnar|8 years ago
Is there anything actually novel here? These types of things always seemed to run into composition issues (controllers inside of controllers) in terms of communication and what not. The net result was invariably far less appealing than, say, angular 1 or vue or non-SPA React.
jurre|8 years ago
It doesn't need to be novel right? It just needs to be helpful.
sli|8 years ago
hinkley|8 years ago
It’s likely a significant fraction of people who jumped to the same solutions had some prior exposure to jquery.
zaarn|8 years ago
Personally, when I work on projects I tend to develop a pure HTML+CSS solution first and then bolt on JS if needed, so this kind of stuff might make me more comfortable with writing proper webapps since it's still just basically "bolt JS on HTML".
SaturateDK|8 years ago
scottharveyco|8 years ago
I've been using Stimulus + Turoblinks for my current side project and I love it. Nice and simple way to add a bit of interactivity to existing HTML on your page.
franciscop|8 years ago
Edit: thanks, I found it, I was just pointing out to the typo so other people don't get confused.
victor106|8 years ago
pjmlp|8 years ago
The manual even describes how to use just a plain <script> inclusion, instead of the build tool of the day.
eropple|8 years ago
Doing so is not a great idea, because build tools solve real and extant problems, but they're very common.
keybits|8 years ago
Can anyone with experience of Stimulus suggest why I'd pick it over intercooler?
uranusjr|8 years ago
andrei_says_|8 years ago
The ability to think effortlessly about code has value.
chuckdries|8 years ago
Anyway, just stopping by to say that Vue has struck a good balance for me. Peppering in {{template values}} in existing HTML works really well, and when things start to get more complex I can easily break my dom out into components.
FrederikET|8 years ago
J-H|8 years ago
meganibla|8 years ago
One criticism I have relates to The syntax for denoting action methods. Did you agonize over the choice of syntax uses hash and implication? E.g.
All the same this careful choice shows the effort you put into the framework . I’m just not sure this particular choice is to my taste nor works with regard to being consistent with the rest of the syntactic choices you have made.Interested to hear thoughts of others in a discussion about this.
aparadja|8 years ago
As a standalone syntax choice, it makes little sense. But for a RoR developer, it’s obvious.
austincheney|8 years ago
I know it is vanilla ES6, but at some point it starts looking more like Java than JavaScript. The boilerplate necessary to convey a simple instruction is directly proportional to the averaged speed of everything else (authorship, maintenance, execution, testing, frequency of reuse, and so forth).
berfarah|8 years ago
`export` -> exports the thing
`default` -> if you require from this module, this is the default
`class` -> class definition
`extends` -> speaks for itself
`Controller` class it's extending.
You could maybe rework it so you don't export it on the same line:
```
class Foo extends Controller {}
export default Foo
```
The parallel I see here to Java is the object orientation - which is a fair criticism. There are probably ways to execute on this using other mechanisms other than inheritance. But then, sub-classing to me still feels better than assigning the prototype via direct assignment.
oelmekki|8 years ago
dawnerd|8 years ago
[1] https://github.com/firstandthird/domodule [2] https://github.com/firstandthird/simple-domodal [3] https://github.com/firstandthird/complete
SaturateDK|8 years ago
It's a super awesome pattern, that makes things super simple and it's super lightweight as well.
pankajdoharey|8 years ago
tiuPapa|8 years ago
ZenoArrow|8 years ago
diasp|8 years ago
machiaweliczny|8 years ago
dsego|8 years ago
taherchhabra|8 years ago
kimjongman|8 years ago
[deleted]
jorisbrauns|8 years ago