by scarface74 · 8y ago · 0 comments
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.
My other rule of thumb when choosing a framework is what would happen if things go south, will I be asked by management why I chose X? The old "no one ever got fired for buying IBM". With a pedigree like BaseCamp has, I could justify it by saying it came from them. Just like I justified using Hashicorp's Nomad, even though no one had ever heard of it before I introduced it.
I suspect if you're in a situation where you need bureaucratic approval or "CYA" you don't have one of the main problems stimulus is trying to solve - helping small teams or single developers create apps that can keep up with apps written by larger teams with more specialities/ists.
Doesn't mean you can't or shouldn't use it, but it does mean you've got options others might not. I do freelance development from time to time by myself. There's a limit to how big/complex of a stack I can be responsible for. Rails has been a great tool for me even though in my "real" job we use a much more robust toolset - in my real job I work with a team. I'm pretty excited about what I (by myself) could do with stimulus. :-)
I'm very cognizant though if things went south because of major architectural decisions I made - not minor code bugs - or that they didn't give the scaleability, reliability, Security, etc. that was required it would be a major blow to my reputation.
From a more practical standpoint, I'm hiring mostly contractors. Good contractors want to gain skills that will help them on their next gig. It's a lot easier to recruit people when I can tell them we are using the latest, greatest, stable technology (mostly backend work). Also, as a developer, I always "keep my running shoes around my neck". So I balance my decisions on what's the best for the company (highest priority) and what's best for my own career for my next job.
Which brings us to - "scaleability, reliability, Security, etc." - valid concerns! Depending on your context's risk tolerance brand new technology might not be an option at all, ever. You've already pointed out elsewhere the reasons to give Stimulus "the benefit of the doubt." So maybe it's within your context's tolerance? Maybe not.
But here's two distinctions I think are important. First, for many businesses and applications the biggest risk vector isn't scalability, or reliability, or even security - it's existence and viability. Can this be made (within X constraints) and do people want it? Will they pay for it? Will it turn a profit? If the answers are "no" no amount of technology will help. Rails (and Turbolinks and Stimulus, etc.) should certainly allow your app to be scalable (etc), but are optimized for the productivity needed to answer those questions - including on limited time with a tight budget. My freelance rep depends just as much on my abilities in that domain as it does on my more technical chops (a somewhat unintuitive realization for a developer). The second distinction is most important, and the piece I often think is missing - just because X technology is scalable, reliable, and secure doesn't mean any implementation of it is. What's cool about the "Rails/Basecamp way" is that it puts scalability, reliability, security, performance, etc. within reach for a wider range of people/teams. Stimulus seems like another step in that direction.
I think the companies who built a framework can be instructive though. Frameworks and libraries tend to reflect the companies who created them. In React / Angular's case, the frameworks are built to work well for large teams that deal with many moving pieces. Basecamp has always been a comparatively small team who values simplicity when appropriate, which I think this tool reflects.
Nomad is nowhere near as popular as Kubernetes, but Consul has been around for awhile as has Hashicorp's dev ops tools (Vagrant, Packer, and Terraform) and are all reasonable popular. You can tell people for everything except Nomad - go watch a PluralSight video.
https://github.com/stimulusjs/stimulus/blob/master/ORIGIN.md...
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();
})
}
})This might be a subjective matter of taste, but I find the React solution much uglier, harder to read, and less intuitive despite the fact that I've been writing React for a while now, and have never written Stimulus.
Here's my guess on why: React syntax has to be able to simultaneously account for JS syntax, HTML syntax, and its own API - all within one syntax that can't be optimized for any one of those use cases. Stimulus allows (forces?) you to leverage more focused HTML syntax where applicable, and javascript syntax where applicable while also letting you leverage your preferred flavors as you see fit (say HAML and CoffeeScript).
That being said, I do have to worry about memory leaks.
None of the criticism mentioned feel like an honest reflection of my last two years working with React (4 years total). Universal rendering is mainstream, there are plenty of options for vastly simplifying initial setup and overall complexity (eg Next.js). From what I understand, similar is true of Vue and Ember.
I can genuinely see the value in tech like Stimulus and Pjax as a way of augmenting an existing traditionally-coded app without needing a total rewrite. But this document seems to be arguing for its place in the world of 2-3 years ago, rather than the present-day.
This is definitely not software for you then.
> arguing for its place in the world of 2-3 years ago, rather than the present-day.
Basecamp pays particular focus to productivity, developer happiness, and staying small. It is through these tenants that they use tools and develop new ones. They are dismissive of frontend JS frameworks because they run counter to their tenants. They embrace the fact that with the web, there are a multitude of ways to deliver a webapp - there is no linear progress but simply an increase in options to suit needs.
But, if I were to do another project where server side rendering made more sense, I would definitely do a proof of concept with Stimulus + TurboLinks.
Right now, my preferred light weight solution is JQuery+Handlebars+WebAPI (c#)
JQuery - a simplified syntax to access the DOM, do ajax, and add events to elements.
HandleBars - if you don't want a heavyweight framework but you do want a simplified templating system. Handlebars is simpler.
My usual MO for front end development when I don't want to implement a full SPA framework:
1. Create a template with Handlebars
2. Use Ajax to get the model.
3. Render the template.
Or.
Create the view with Handlebars
Assign events using JQuery to the rendered elements.
Adjust the model based on the events.
Re-render the template based on the model.
But at some point, it makes sense to use a full fledged framework because at a certain level of complexity, you are reinventing the wheel. But even then, I can use Ember that uses Handlebars.
But it doesn't make sense to use Handlebars and Angular.
Bootstrap is for layout whether you use Handlebars or Angular.