Live data from Hacker News

None of my projects want to be SPAs

whatisjasongoldstein.com

321–330 of 362 posts

Re: None of my projects want to be SPAs

#321

Earlier quoted context omitted.

I do machine learning consulting and I see the flip side of this. I get new clients reaching out asking me to "add some AI" with no specific use cases in mind other than satisfying their investors that they are "leveraging AI."

Had a client that wanted a machine learning solution to determine if one name that was in one list was also in another list...

lol... Train your model with the dataset of "another list" i.e. populate a lookup table. Slap a sigmoid on top of that boolean "presence" result. Perfect precision/recall!

Re: None of my projects want to be SPAs

#322
post #78

I don't use Elixir/Phoenix, but Phoenix's LiveViews brings all the butter to the monolith bread. State remains on the server, only visual state is sent over websockets, and the HTML is transformed with morphDOM. https://dockyard.com/blog/2018/12/12/phoenix-liveview-intera... I hope to see this idea brought to Rails, but the its websocket story doesn't seem there yet.

I agree - it seems like a LiveView equivalent for Rails should be doable in principle. Check out these two projects, they're sorta heading in that direction: Fie: https://fie.eranpeer.co/ AnyCable: https://anycable.io/

If you watch Chris Mccord's videos (the creator of Phoenix and LiveView), it was an attempt to build a similar system for Rails that drove him to create Phoenix. The Ruby/Rails concurrency model mean that he was patching over so many cracks to try and get it to work, and it never quite did.

Re: None of my projects want to be SPAs

#323
post #311

Earlier quoted context omitted.

Could you provide some links/keywords about these alternative solutions? This sounds very interesting but I don't know were to start.

Is unclear to me if you talk about Delphi and smalltalk?

I am interested in designs/technologies that could be viewed as alternatives to the usual tech stack for SPAs, even if these technologies are outdated but exhibit interesting properties compared to what we are used to today. That would include Smalltalk and Delphi yes. Sorry if I misunderstood your initial comment.

Re: None of my projects want to be SPAs

#324

Earlier quoted context omitted.

How is this amazing? We've been "server side rendering" since the inception of the internet. If you build your pages with CSS at the top and JS at the bottom you're already achieving most of that effect right there, no extra tools needed. The browser will load the css and content first, and then process the JS requests (Which are easily cachable by the server AND the browser).

I suspect nisten is referring to server side rendering using React.

I think so too, but my statement still stands.

There's nothing new or especially special about "server side rendering", and nothing about React rendering either.

Rendering on the server lets you do whatever you want.

Want to put the user in a specific state? Sure, go for it.

Want to use a starter or null-state? Sure, go for it.

Re: None of my projects want to be SPAs

#325
post #233

Earlier quoted context omitted.

The problem that you end up with past a certain scale in a component-based app without a state management framework (third party or your own) is that you're performing business logic inside view components. By moving your business logic into your state management framework and using something like redux-saga that is designed specifically for managing complex asynchronous workflows, you can extract your application co…

Great points all around. One question though — how many apps actually need to share state across pages? Seems like mobile apps have this problem more than desktop apps, because their screens are small and so the UI must be split into pages. Whereas a large monitor can support an expansive UI that isn’t “split up”. So if you’re making a desktop app, what would you use instead of redux? Seems like your points about spl…

If you don't have any routing to deal with, component state is all you need. You can still move your business logic out of the view components and use lifecycle methods and event handlers to coordinate it, but the use case you are describing is the ideal case for vanilla react.

Re: None of my projects want to be SPAs

#326
post #311

Earlier quoted context omitted.

Is unclear to me if you talk about Delphi and smalltalk?

I am interested in designs/technologies that could be viewed as alternatives to the usual tech stack for SPAs, even if these technologies are outdated but exhibit interesting properties compared to what we are used to today. That would include Smalltalk and Delphi yes. Sorry if I misunderstood your initial comment.

Well, Delphi is well alive and current:

https://www.embarcadero.com/products/delphi

(it have a free edition) and alzo exist Lazarus, a open source clone:

https://www.lazarus-ide.org

Is probably the most fleshed idea under more "traditional" paradigms (OOP, RAD, etc)

Smalltalk and others are less popular(?) and only know them passing, so can't give too much of that.

---

Another interesting stuff can be rebel/red:

https://www.red-lang.org

much low-level but nice way to do UIs in a apparent declarative way..

Re: None of my projects want to be SPAs

#327
post #315

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 w…

I don’t get the hate against SPA’s. An SPA done right offers amazing interactibily and instant navigation to new views. You already have the templates cached. They probably load from a cdn with good caching policy. If done well you can totally run offline. Sure you can build with php, laravel, django. The promise of SPA is a clean separation of UI from the APIs. The same REST APIs that external customers use is the s…

> An SPA done right offers amazing interactibily and instant navigation to new views. You already have the templates cached. They probably load from a cdn with good caching policy.

Most of the time I find the initial delay loading/parsing the js to be more problematic than the often tiny speed increase of subsequent loads.

Furthermore, these days it takes minimal to no tweaking to get server-side rendered pages to load fast enough to barely notice the difference (in particular if the client-side is retrieving and parsing JSON in the background through an API request). Perhaps non-webdevs are even less likely to notice this stuff.

> If done well you can totally run offline.

That's definitely an advantage, but most SPAs I encounter don't offer offline functionality, or it's entirely unnecessary to offer it.

> Sure you can build with php, laravel, django. The promise of SPA is a clean separation of UI from the APIs. The same REST APIs that external customers use is the same API you develop on. See travis-ci as an example. It’s the same api that the mobile apps can use.

In some cases that's definitely an advantage. But it's entirely feasible to build an API-based backend and use that API internally for server-side rendering. If you want an app that plays nice with search engines you have to do this anyways.

> This separation allows the api to return very lightweight stateless responses. You can scale much better when there is less state kungfu.

That doesn't make sense to me. One of the biggest issues I have with SPAs is that you now have to deal with the backend state (DB) and a subset of this state on the client, which dramatically increases complexity (state management, sync, etc.). I rather like the old-fashioned approach where all state remains in the backend, except perhaps for the tiny bits you'd put in a cookie (and I suppose the URL could be considered client-site state too).

> The UI can manage the state in very responsive manner. No round trips, instant 60fps render.

How many apps do you use where you really need anything below say, sub-second rendering? Frameworks like Phoenix and/or caching can be much faster than that even (in the order of microseconds).

> And no JavaScript is not slow. It’s just that people don’t know it well and end up loading megs of bloated libs with a 1000 ad tracking libraries.

Clearly if so many SPAs are bloated Mb-size messes, it's not trivial to solve. And it's a problem you can almost entirely avoid if you keep the rendering on the server. After years of agonizing over bundle sizes, I find it incredibly liberating to not have to think about this anymore (much of the time, anyways).

> Don’t throw the baby with the bathwater.

I do agree that there are plenty of use cases for SPAs, but I also agree with many here who say they're very over-used.

I'll add that there are some interesting initiatives to have 'old-fashioned' applications that also get to be dynamic enough for many if most use cases. Phoenix LiveView [1], for example, takes advantage of very fast server-side rendering, websockets, and sending subsets of the templates as HTML snippets to the client, where morphdom simply diffs the HTML string with the element it's supposed to replace. With great performance.

[1]: https://dockyard.com/blog/2018/12/12/phoenix-liveview-intera...

Re: None of my projects want to be SPAs

#328
post #325

Earlier quoted context omitted.

Great points all around. One question though — how many apps actually need to share state across pages? Seems like mobile apps have this problem more than desktop apps, because their screens are small and so the UI must be split into pages. Whereas a large monitor can support an expansive UI that isn’t “split up”. So if you’re making a desktop app, what would you use instead of redux? Seems like your points about spl…

If you don't have any routing to deal with, component state is all you need. You can still move your business logic out of the view components and use lifecycle methods and event handlers to coordinate it, but the use case you are describing is the ideal case for vanilla react.

If making global state accessible is all you need Redux for, then I don't see why that state shouldn't be: 1) persisted to a back-end and re-fetched on route 2) Persisted to localStorage

If there some kind of state that doesn't neatly fit into these solutions? I know that passing around signed-in user objects is one popular use case for Redux, but in my opinion that could be easily placed into localStorage, or assigned to a window.global_state variable.

Re: None of my projects want to be SPAs

#329

Earlier quoted context omitted.

What about tabs? SPA can make tabs troublesome. If I can't open a site in tabs it is broken to me.

I'm not sure when/why tabs should be an issue... it depends. To me it's a difference between localStorage and sessionStorage for the most part.

If links don't fully address an item then opening it in a tab won't work.

Re: None of my projects want to be SPAs

#330

Earlier quoted context omitted.

I'm not sure when/why tabs should be an issue... it depends. To me it's a difference between localStorage and sessionStorage for the most part.

If links don't fully address an item then opening it in a tab won't work.

That isn't a limitation of SPA or browser based apps though. For that matter, even having an option to open an app multiple times is often a limitation of desktop apps. That doesn't make them somehow deficient as a platform.
Post reply on HN