Live data from Hacker News

None of my projects want to be SPAs

whatisjasongoldstein.com

101–110 of 362 posts

Re: None of my projects want to be SPAs

#101

Back when I was doing React, what pulled me in was that it WASN'T a framework for SPAs. What I got from it was the ability to build UI widgets (components, in React terms) that worked within a page, and were composable with other UI widgets. With that approach, you really wanted to keep every component self-contained. That meant a lot of bookkeeping with passing events back and forth between parent and child widgets,…

> Then introduce Redux and similar frameworks, and I totally lost interest. It's as if the entire React community forgot all the lessons they learned writing Python and C programs in college and went back to creating global state. What in the actual hell? Fair point. But could it be possible that there are lots of people doing React that never went to college and never wrote Python or C programs?

That's true, and possibly the source of the problem.

Re: None of my projects want to be SPAs

#102

Earlier quoted context omitted.

Redux was the solution to server side rendering state. If you don't use redux, then keeping state synced with a server side rendered application because nearly impossible.

> Redux was the solution to server side rendering state. Could you explain what you mean by "server side rendering state"?

Server side rendering mounts your application in the server and sends down html along with an initial state.

The client receives this initial state and uses it with the html to glue together a working UI on the client.

This removes the massive JS bloat into raw html and split JS for each component.

Instead of sending 3MB of JS, you send only the JS needed to render the current page... and send additional JS as a user navigates through your website.

Here's an example with Create React App: https://github.com/cereallarceny/cra-ssr

Re: None of my projects want to be SPAs

#103
post #2

Wtf is an SPA?

If you have Javascript disabled, all you should see is a blank white screen, and if you're lucky a small note saying 'This site requires Javascript to work correctly'. That's what a SPA is

React Server Side rendering takes care of this... but most people don't know how to do it.

Without JS, Server Side JS defaults to good old school MVC.

Re: None of my projects want to be SPAs

#104
post #80

I feel as if many sites that used to be fine and work well have regressed in usability and features and introduced unexpected behaviors and bugs since the SPA paradigm seems to have taken over. This seems especially true for many corporate, bank, shopping brand sites, etc. An example is the Capital One 360, Chase, and AMEX sites and even Reddit. Even JustWatch.com seems like it's fairly polished, still has it's quirk…

Fellow JustWatcher here, care to elaborate which quirks exactly you mean? Back when SPAs were still pretty new, we took the bet to make one with a pretty large surface area and despite a lot of issues (SEO especially) so far we're pretty happy with that decision.

Re: None of my projects want to be SPAs

#105

Back when I was doing React, what pulled me in was that it WASN'T a framework for SPAs. What I got from it was the ability to build UI widgets (components, in React terms) that worked within a page, and were composable with other UI widgets. With that approach, you really wanted to keep every component self-contained. That meant a lot of bookkeeping with passing events back and forth between parent and child widgets,…

> Then introduce Redux and similar frameworks, and I totally lost interest. It's as if the entire React community forgot all the lessons they learned writing Python and C programs in college and went back to creating global state. What in the actual hell? Fair point. But could it be possible that there are lots of people doing React that never went to college and never wrote Python or C programs?

Or people who went to college but not for Computer Science.

Re: None of my projects want to be SPAs

#106
post #92

Back when I was doing React, what pulled me in was that it WASN'T a framework for SPAs. What I got from it was the ability to build UI widgets (components, in React terms) that worked within a page, and were composable with other UI widgets. With that approach, you really wanted to keep every component self-contained. That meant a lot of bookkeeping with passing events back and forth between parent and child widgets,…

I'm surprised you dislike Redux simply because it's a form of global state. Sure, global variables make debugging difficult when you don't know which function changed them where and when and why. But that doesn't happen if you keep your functions pure and only make changes from within reducers – at least that's my experience. (Boilerplate, yes, Redux adds that. But at least it's all in one place, and not scattered th…

Anecdotical comment: While studying computer science, I almost fail a test because I used global variables. Since then I avoid them like the plage, and I get rashes when I see them.

And I thank my teacher for knocking the bad habit out of me. So when I see global variables beyond the initialization of core objects, I take it as a bad code smell.

Re: None of my projects want to be SPAs

#107
My favorite pattern right now is server rendered html shell including static parts of the page, and then invoking a view-only js framework with all the server data required sent in the initial page load for the dynamic client bits, which runs immediately on page load.

so, basically a "functional" front-end view-framework for client-side behavior, but with no routing.

Re: None of my projects want to be SPAs

#108
This may be a mean thing to say, but basically I think SPA's are massively overused, because developers want to demonstrate that they can do them. Why? Because big companies like Facebook and Google use them. Why? Because they actually are doing things that require them. 99% of the SPAs in production are things that should have been done the old Rails/Django/Laravel way, but that would not set you up as a developer who can do SPA's.

I have also witnessed discussions where management admits that they want something done in an SPA so that they can show that work to their investors, as a means of getting funding to do other projects. So basically the same reason, except for managers to impress investors instead of developers to impress potential employers.

Not saying all SPAs are mistakes; some uses clearly are not. But most of them are.

Re: None of my projects want to be SPAs

#109

Earlier quoted context omitted.

Then add a polyfill per api call to support anything but the most recent browsers, if you happen to want your site useable by people with old systems or who are at work.

...which you can selectively serve only to the old browsers :)

That sounds trivial.

Re: None of my projects want to be SPAs

#110
post #92

Back when I was doing React, what pulled me in was that it WASN'T a framework for SPAs. What I got from it was the ability to build UI widgets (components, in React terms) that worked within a page, and were composable with other UI widgets. With that approach, you really wanted to keep every component self-contained. That meant a lot of bookkeeping with passing events back and forth between parent and child widgets,…

I'm surprised you dislike Redux simply because it's a form of global state. Sure, global variables make debugging difficult when you don't know which function changed them where and when and why. But that doesn't happen if you keep your functions pure and only make changes from within reducers – at least that's my experience. (Boilerplate, yes, Redux adds that. But at least it's all in one place, and not scattered th…

> Sure, global variables make debugging difficult when you don't know which function changed them where and when and why. But that doesn't happen if you keep your functions pure and only make changes from within reducers – at least that's my experience.

Sticking to reducers IS a good idea and it does make things a bit better. The problem with global state goes deeper than that, though.

Often, as you learn about the structure of the data, it becomes useful to change how the data is structured and stored. In global state, you can change that in reducers, sure, but then all the places that render that data have to be updated. You don't have the option to represent the same data in different ways that might be more suitable for different parts of the application. You either have to change them all at once, or synchronize a bunch of states that really contain the same data (which is even worse).

With independent components, you do spend some time synchronizing data across components, but each component has the option of how to represent its data internally, so the effects of changing data representation in one area are usually very local, and each area of the code gets to represent the data in a way that's reasonable for what it's doing.

I'll also add that with independent components, you sometimes get components whose only real job is to manage data. That's actually sort of like a Redux! But you can spin up multiples of them without having to manage an array, and compose them or even nest them without issues.

> (Boilerplate, yes, Redux adds that. But at least it's all in one place, and not scattered throughout your app.)

To be clear, I don't really care about boilerplate. It's easy to generate that stuff, but even if you write it by hand it's faster than debugging implicit, hidden complexity. Boilerplate ISN'T the problem with Redux, as far as I'm concerned.

Post reply on HN