12 ms·
Stimulus: A modest JavaScript framework for the HTML you already have
- ghostbust555 9y agoSo... knockout?
- bruncun 9y agoDamn, they're actually a lot alike. The differences I see are subtle - Stimulus seems simpler in practice, scopes controllers, state stored in document, uses native APIs, etc. but there's definite overlap.
- gedy 9y agoYeah was my initial thought. I suppose Knockout is perceived by many to be old/legacy, though. On the up side Stimulus might help Rails apps minimize adding piles of jQuery.
- startupdiscuss 9y agoI said the same thing and noticed you had said it 4 hours earlier. Whatever happened to knockout? If it failed, why?
- titusjohnson 9y agoIt's not dead, it still receives updates (as recent as 4 days ago). There's an overhaul in progress called TKO (https://github.com/knockout/tko https://github.com/knockout/tko) that is supposed to bring Knockout up to date with ES6, a better plugin API, and other nice stuff.
- ghostbust555 9y agoMy company still actively uses it in production and development
- maxehmookau 9y agoThis feels like it has a whif of Angular about it. Controllers in HTML attributes... Are we likely to see this in Rails 6? I'm a full-time Rails dev these days and I struggle to keep up with all the new things that are coming through that I'm not using day-to-day on older apps! Webpacker, Action Cable, just to name a couple.
- bruncun 9y agoReminds me too of AngularJS. Rails has dramatically changed how it handles front-end, but it would be tough to compete without doing so.
- scarface74 9y agoFor context, I'm in no way, shape, or form a modern front end maestro. I'm good with ES6, Jquery, Handlebars, and Bootstrap. I've done a little with the Angular 2. From that perspective.... What does this buy me over the other more popular frameworks? What are the chances that this won't be abandoned if it doesn't gain traction? It's also easier to recruit developers if you say your stack is built on the more popular frameworks. On the other hand, even though I've never used Ruby on Rails, this is written by BaseCamp so I do give them a slight benefit of a doubt. Just like I would give Kotlin the benefit of a doubt based on my experience with JetBrains' products.
- yojex 9y agoI believe this section attempts to answer that question: https://github.com/stimulusjs/stimulus/blob/master/ORIGIN.md#how-stimulus-differs-from-mainstream-javascript-frameworks https://github.com/stimulusjs/stimulus/blob/master/ORIGIN.md...
- nailer 9y ago> Stimulus also differs on the question of state. Most frameworks have ways of maintaining state within JavaScript objects, and then render HTML based on that state. Stimulus is the exact opposite. State is stored in the HTML, so that controllers can be discarded between page changes, but still reinitialize as they were when the cached HTML appears again. It really is a remarkably different paradigm. One that I’m sure many veteran JavaScript developers who’ve been used to work with contemporary frameworks will scoff at. And hey, scoff away. If you’re happy with the complexity and effort it takes to maintain an application within the maelstrom of, say, React + Redux, then Turbolinks + Stimulus will not appeal to you. The complexity of React + Redux is completely orthogonal to having a virtual DOM. Ractive, vue, and the like are similarly easy as Stimulus. Making state management easier is a matter of having simpler APIs, not moving state into HTML. Quick Ractive version (at work so just ad-libbing): new Ractive({ el: '.greeter-ui', template: ` <div> <input value="{{ name }}> <button class="greet">Greet</button> </div> `, data: { name: 'Alex' }, oncomplete: function(){ var Greeter = this; var greetButton = document.querySelector('button.greet') document.addEventListener(greetButton, 'click', function(event){ var name = Greeter.get('name') console.log(name) event.preventDefault(); }) } })
- dsego 9y agoI think this is the library mentioned in the recent rails podcast. Relevant HN discussion: https://news.ycombinator.com/item?id=16021808 https://news.ycombinator.com/item?id=16021808
- holydude 9y agoIt is becoming more and more apparent that with every piece of technology that is not really turn on/turn off you have to justify the investment.I get that this is an opinionated piece of software and solves basecamp's kind of issues but I do not see it being widely adopted. That said I wish people behind RoR would actually work on better integration with things like React and Vue.
- cmwoodall 9y agohttps://github.com/rails/webpacker#integrations https://github.com/rails/webpacker#integrations
- danmaz74 9y agoDefinitely agree. What would be really great is an easy way to symc the status between client and server, with generators for the api and a client library to manage the status which could then be used with react or any other similar front end framework.
- meesterdude 9y agoRails is an open source web development framework that excels in productivity by coming with smart defaults for people to use to get up and running quickly. Rails already integrates with webpack, and you can certainly implement your own integrations to further advance things - and you can turn around and make this a gem for others to use, or contribute it to core if its something more fundamental. But for the most part, the people behind RoR are pretty happy using RoR for their development, and don't need to use React or Vue for a majority of what they do.
- bromuro 9y agoReact and vue are great for creating interactive widgets (no flash anymore). it doesnt’t mean necessarily to change how we code :)
- gedy 9y agoThey have improved the integration with Webpacker, but also bear in mind if you don't use the HTML/UI type functionality in Rails, it's a lot less compelling. I'm assuming DHH/RoR is sensitive to that hence these solutions like TurboLinks, Stimulus, etc that still use server rendered HTML.
- throwme_1980 9y agololz..... please
- bruncun 9y agoTo anyone wondering why they should care about Stimulus, I offer this TLDR, straight from DHH himself: "Above all, it’s a toolkit for small teams who want to compete on fidelity and reach with much larger teams using more laborious, mainstream approaches." Give it a whirl, I'm sure you'll find it delightful. But if you're looking for the next Big Thing™, I'm afraid you might be sorely disappointed.
- sparaker 9y agoLooks simple and self explaining framework. Would work well for legacy and small projects that don't need a lot of state to work with.
- fiatjaf 9y ago"A modest JavaScript framework for the HTML you already have" is a great headline. I haven't read anything and love this already.
- sheraz 9y agoI think this, along with its sibling Turbolinks [1], is filling a much needed gap with regards to complexity in these javascript frameworks. Myself, I've been playing with intercoolerjs [2] for a few weeks, and it is quite refreshing. These are great libraries for small full-stack teams who do not want to get lost in the complexity of front-end stuff like react, webpack, etc. [1] - https://github.com/turbolinks/turbolinks https://github.com/turbolinks/turbolinks [2] - http://intercoolerjs.org/ http://intercoolerjs.org/
- triskweline 9y agoIf you enjoy working with intercooler.js but are looking for a bit more power, check out Unpoly [1]. [1]: https://unpoly.com https://unpoly.com
- cyberferret 9y agoThanks for the heads up. I've worked with Intercooler before and while it is a really nice framework, I've always felt it was missing a few critical things. Unpoly looks cool. Do you know if it has a dependency on jQuery still, like Intercooler does? Or does it run independently?
- triskweline 9y agoUnpoly currently depends on jQuery. Work is being done to remove that dependency eventually, but that will take time.
- NoGravitas 9y agoSmall correction: intercooler works with either jQuery or zepto.
- edwinyzh 9y agoHello, I've been watching intercoolerjs also, and thinking of using it in a future project. What are the few critical things missing have you experienced ?
- 9y ago
- sadiqmmm 9y agostimulusJS looks really awesome framework :) Thanks Basecamp and DHH.
- xrd 9y agoWhat's the testing story here? Anyone know?
- amorphid 9y agoFor a quick & dirty look, I did `git grep test`. In there, I noticed circle.yml in the root directory, which I'm guessing is for testing on Circle CI. From this... https://github.com/stimulusjs/stimulus/blob/master/circle.yml https://github.com/stimulusjs/stimulus/blob/master/circle.ym... Until you have a better idea of how to proceed, try this: $ curl -o- -L https://yarnpkg.com/install.sh https://yarnpkg.com/install.sh | bash $ yarn $ yarn test I'm completely guessing here. I've never used Yarn before just now, but I suspect you'll find some of your answers in there.
- itwy 9y agoIn essence, Basecamp has a well-maintained legacy system that they keep patching up because it doesn't make sense businesswise to rewrite it from scratch using modern methodologies. Good for them, I do that myself but be careful going down that path if you are starting a new project and you have the resources/experience to have a more solid/correct foundation with proper separation of concerns.
- simple_sally 9y agoHmm not so sure. I may be wrong but I am pretty sure every major version of Basecamp has been a ground-up re-write of the app.
- meesterdude 9y agoJust because they have different ideas and opinions than yours, does not make them in any way wrong or legacy, or unsolid or incorrect. Also, basecamp has been rewritten 3 times.
- itwy 9y agoTry to discuss the idea not my personal opinion.
- learc83 9y agoThe central argument of your post appears to be based solely on personal opinion because you provided no evidence to back it up. meesterdude provided evidence that runs counter to that opinion. I'm not sure what you're complaining about.
- itwy 9y agoHe's parroting what they said. "rewritten"... more like revamped.
- meesterdude 9y ago
- jaredcwhite 9y agoAs a Rails dev, I find this very interesting. I've already jumped on the Vue bandwagon and have had a pretty good time using it. That being said, I recently started a new small-ish Rails project and loaded Vue in via 5.1's Webpack integration...and ended up just hacking together some jQuery stuff for minor front-end dynamism. It just was easier/faster for me to do that in this particular context. However, I could definitely see myself using Stimulus instead because it's just so incredibly simple to "sprinkle" (DHH's word) some JS onto the page and get dynamism quickly. I look forward to putting Stimulus through its paces and see if it is a good option for projects where Vue is overkill.
- bphogan 9y agoThis has been my experience on the last two small things I built. I just reached for the jquery (or even just regular JS) because I didn't need that much. Isn't it cool to have choices? I don't care if it's not cool to use jquery anymore. I shipped stuff and I'm not even sorry.
- crescentfresh 9y ago> Vue is overkill The number of projects where something as small and simple as Vue could be considered overkill has to be remarkably small, I feel. I've used Vue in single pages (i.e. a single page of a large application) inside a single div as needed. In my case attaching behavior inside a modal dialog (ie the modal was managed by some other framework). It is very small and lean as is.
- jaredcwhite 9y agoI should have worded that better...in this context, it's not that Vue the library is overkill, but the overall paradigm. Vue's not well-suited to server-rendered HTML that has some dynamic features after the fact.
- andrei_says_ 9y agoSpeaking of rails and Vue, how do you manage authentication? Can you point me to an example of a Vue-powered page in a larger rails app consumes json data after authentication?
- Tloewald 9y agoI do like the brief and to-the-point introduction. Stimulus seems somewhat similar, or at least similarly motivated, to a framework I've been creating as I go -- https://bindinator.com/ https://bindinator.com/ (It's gotten quite a bit bigger than stimulus as it's been used. Such is life.)
- startupdiscuss 9y agoThis reminds me of knockout. http://knockoutjs.com/ http://knockoutjs.com/ Whatever happened to knockout?
- philippnagel 9y agoThe devs seem to be mainly working on an updated version without a lot of the legacy code: https://github.com/knockout/tko https://github.com/knockout/tko
- startupdiscuss 9y agoThanks. A better home page? How could they possibly improve on that homepage. It is the envy of front-end JS package homepages.
- weego 9y agoThis has alot of similarities with Lift snippets, part of a Scala web framework (https://liftweb.net https://liftweb.net), which has been a goto of my company for many years
- Touche 9y agoI don't understand the example. How does: // hello_controller.js import { Controller } from "stimulus" export default class extends Controller { greet() { console.log(`Hello, ${this.name}!`) } get name() { return this.targets.find("name").value } } get connected to the <div data-controller="hello"> element? I would expect something like `stimulus.register("hello", HelloController)`...