Live data from Hacker News

Escaping the SPA rabbit hole with modern Rails

medium.com

91–100 of 137 posts

Re: Escaping the SPA rabbit hole with modern Rails

#91
post #63

I honestly feel this article is everything that's wrong with web development and this attachment that older developers have for MVC is a ghost that really needs to be addressed once and for all. Seriously. MVC is dead and we need to let it stay dead. SPA architectures are so braindead easy to implement, maintain, and understand that it's ridiculous that developers are still clinging on to their monolithic event drive…

Isn't the problem in your rant of SPA architectures vs MVC the fact that plenty of SPA architectures are client-side MVC architectures, and most of the rest are slight variations in the MV* family (MVP, MVVM, etc.)

Re: Escaping the SPA rabbit hole with modern Rails

#92
post #6

To the author of the article- Kudos! Well written, well reasoned, with minimal hyperbole or unnecessary “X is dead” style declarations. Hope we see more writing like this bubble up to the top on HN. I’m not swayed by the argument, but that’s personal bias. I’m the technical cofounder / solo coder of a venture backed startup, and I built our platform on rails 5. I migrated our front end to Vue over the winter and coul…

How do you handle SSR for SEO? Or do you not need SEO?

I don't need SEO for what I've released so far, and the pages are properly indexed by Google, despite being SPAs. Our product is primarily B2B, so the website isn't a destination at the moment.

If I needed to have SEO friendly pages, there are SSR solutions I would look into using (like nuxt) or just pre-rendering the pages myself (I already use puppeteer for PDF rendering elsewhere in the product).

Re: Escaping the SPA rabbit hole with modern Rails

#93
post #48

Earlier quoted context omitted.

I think that prototyping your software with (insert server side software ) and jquery is a really good way to prototype. It lets you get to market and or fail faster .

Maybe for you. I write React and a web API (using Swagger in Ruby or TypeScript/NodeJS) significantly faster than I do any server-side framework I've ever used. React components are an easier way to frame HTML--here, let me not remember how Bootstrap elements are created and just invoke --and JSX is the most fluid and flexible templating system I've ever used. Dealing with stateful and rickety jQuery is why I stopped…

This is now my feeling as well, after coding in Vue for only 9 months. If I started a project tomorrow, I'd use Vue on day 0 100% of the time. Even if I'm just rendering HTML, the process of using it helps me to separate out my components and break them down into small and understandable pieces. I'm sure I'd get the same benefit from Ember, Angular, React, etc., if I knew those frameworks as well.

My feeling is that I don't experience a startup tax with using a frontend framework, like Vue. To me, it's now as natural as using Rails on day 0.

Re: Escaping the SPA rabbit hole with modern Rails

#94
post #63

I honestly feel this article is everything that's wrong with web development and this attachment that older developers have for MVC is a ghost that really needs to be addressed once and for all. Seriously. MVC is dead and we need to let it stay dead. SPA architectures are so braindead easy to implement, maintain, and understand that it's ridiculous that developers are still clinging on to their monolithic event drive…

They're in stage 3-4 of denial. Denial cycle.

Re: Escaping the SPA rabbit hole with modern Rails

#95
post #31

Earlier quoted context omitted.

Another plus to this "ramping up" of tools as necessary is when you get to a certain point where your entire UI is sophisticated enough you can cut the views out of your rails app and basically transform it just a REST API with another service responsible for serving the UI layer. Rails makes a fantastic REST framework, especially if you build your app that way right from the start.

Good point, and this is exactly what I did. I actually was running the SPA + the rails app side by side. Took me about 6 months, but I cut over every page / app one by one till I was done. And, to the parent commenter, good point. I do think the gist of the author is to use the right tool for the job, and they are not dogmatic about "never write an SPA". Thanks for keeping me honest.

I’m curious, what was the change in the UI which required the move away from Rails?

What are you accomplishing with Vue which was impossible before?

Would love to get a glimpse of the app.

Re: Escaping the SPA rabbit hole with modern Rails

#96
post #87

Earlier quoted context omitted.

Writing jQuery to accomplish a feature like hiding one element if another is checked is significantly more code and more error-prone (not to mention difficult to test) than doing the equivalent thing with a tool like Angular is.

It's 1 line with jQuery, so I guess "significantly more" is relative?

Alright, fair, you could just assign a toggle on click, but if the interaction is any more complex than that (check some other form value, see if multiple different boxes are checked, etc.) it's not.

Re: Escaping the SPA rabbit hole with modern Rails

#97
post #27

Are you building a website? The practices espoused by the author will be ideal. Are you building a web app? Will you have a mobile client alongside your web app? Using a javascript framework for your client(s) and decoupling your data from it's presentation will be a fruitful investment. All of these frameworks and their associated happened for reasons, and they didn't involve traditional MVC being good enough for ev…

> It also lead to a culture of staunch refusal to learn or do anything new in that job I find one of the most difficult aspects of software is the very powerful "local minima" of effective (but not optimal) techniques combined with entrenched knowledge. People are so incredibly biased towards what they know well, and that bias is backed by objective evidence: when they do it X-way they are objectively faster AND bett…

This is an interesting point - my limited experience has been that with successive generations of hires, each attempts to update the practices and tools used to build the application. This leads to pockets of properly functioning Y-way code and many layers of inefficient and difficult to support bridging between X-way and Y-way.

Overall, in each one of these scenarios my gut is that it would have been more efficient to attempt to optimize X-way, rather than layer Y-way on top. It always seems the goal is to incrementally migrate from X-way to Y-way, except we never seem to quite finish and frontend moves quickly enough that Z-way starts to look enticing midway through the painful migration.

I think it is extremely important to differentiate between the benefits of building a fresh application Y-way initially, and the (often extremely painful) friction of migrating from X-way to Y-way. One great example of this is the recent AirBnB departure from React Native. It seems like the majority of their complaint with the framework was that it was difficult to integrate with the rest of their app - had they built from the ground up in React Native, they likely would not have experienced such integration challenges.

Re: Escaping the SPA rabbit hole with modern Rails

#98

Earlier quoted context omitted.

> but ultimately represents a big disadvantage over time. That presumes that Y-way is inherently advantageous to X-way. There's still plenty of sites that can and are market leaders using an out-of-flavor framework like rails/spring mvc/.net. New frameworks do not necessarily supersede old ones - they are usually a response to new use cases that have cropped up. These use cases may or may not be important to your bus…

If new developers start at Y-way, we can assume they'll add more advantages to Y-way like improved tooling etc..., so maybe Y-way will eventually surpass the X-way. In tech, it's not what one particular developer thinks but the consensus among the contributors which decides which one out of X or Y will end up having more benefits.

> In tech, it's not what one particular developer thinks but the consensus among the contributors which decides which one out of X or Y will end up having more benefits.

It's always the people using the tools that decide whether X or Y will have more benefit. You don't easily get contributors without first having users. Or did I misunderstand your point of view?

Re: Escaping the SPA rabbit hole with modern Rails

#99
post #31

Earlier quoted context omitted.

Good point, and this is exactly what I did. I actually was running the SPA + the rails app side by side. Took me about 6 months, but I cut over every page / app one by one till I was done. And, to the parent commenter, good point. I do think the gist of the author is to use the right tool for the job, and they are not dogmatic about "never write an SPA". Thanks for keeping me honest.

I’m curious, what was the change in the UI which required the move away from Rails? What are you accomplishing with Vue which was impossible before? Would love to get a glimpse of the app.

I'm not the OP, but here's how my Rails app is growing after several years:

The first "complex" UI design that we came up with was creating a list view that came with all the trinkets you'd want from a sophisticated list view (pagination, sorting, filters, searching). This view needed to be able to apply easily to all the key data structures our app uses (list of users, list of things user has, list of things users do, etc) which meant due to the scale of some of the data sets most of the operation work needed to be on the backend.

Originally, it was built as a completely normal Rails view requiring a full page refresh (form submit) to perform any given operation. This certainly was "doable" but not a great experience as someone administrating lists of things in our app.

We then wrote a React component that manages all the visual state itself based on the data returned from the backend and replaced the existing Rails view with this React component. By pushing responsibility of view state to the client our Rails codebase get simplified. React fully manages visual state, but where we really benefit is the fact that it forces you to design components in such a simple way that UI abstractions become more naturally fitting. The conventions are easy to understand and result in a codebase that can have a lot of cooks in the kitchen without too many problems.

Could this be written in jQuery? Sure. If it's like most large jQuery projects I've seen with multiple hands on it, it will be hard to keep it from being too brittle.

The implementation is really part of a longer term plan to begin building out new user interfaces in React. We find that react delivers on the promise of UI reusability much better than any backend MVC frameworks view or partial system. A front-end codebase is starting to emerge with it's own developer conventions and processes that are more geared towards frontend requirements. Meanwhile, our backend is simplified to only deal with tasks related directly to data management. The split feels very natural as the codebase grows larger. There is no obvious downside to writing in React besides the minified library code payload.

As a summary: our users expect interactions with complex interfaces to respond quickly. React is designed to build interfaces that fulfill that expectation, and the implementation of React in our codebase allows to slide into a more microservices looking architecture in an organic way as the scale and complexity of our app increases.

Re: Escaping the SPA rabbit hole with modern Rails

#100
post #93
post #48

Earlier quoted context omitted.

Maybe for you. I write React and a web API (using Swagger in Ruby or TypeScript/NodeJS) significantly faster than I do any server-side framework I've ever used. React components are an easier way to frame HTML--here, let me not remember how Bootstrap elements are created and just invoke --and JSX is the most fluid and flexible templating system I've ever used. Dealing with stateful and rickety jQuery is why I stopped…

This is now my feeling as well, after coding in Vue for only 9 months. If I started a project tomorrow, I'd use Vue on day 0 100% of the time. Even if I'm just rendering HTML, the process of using it helps me to separate out my components and break them down into small and understandable pieces. I'm sure I'd get the same benefit from Ember, Angular, React, etc., if I knew those frameworks as well. My feeling is that…

I’ve used both Vue and Rails. Rails partials does meet my needs for compartmentalizing code.

Don’t really see what benefit would I get for adding the complexity of separating the front end in its own layer.

Turbolinks gives me the speed of an SPA and I get 5x the dev productivity by not adding one.

And I absolutely love Vue.

What am I missing?

Post reply on HN