News for hackers. Stuff that matters.
Re:Escaping the SPA rabbit hole with modern Rails by peteforde on Sunday July 08, 2018 @02:22AM (#17482435)
I have nothing against SPAs for complex UI interactions. It's sort of like taking anti-biotics; there should be a moment of reflection when you should justify your true need, lest the cure be worse than the disease. Most developers of a certain age have come up when it's SPA by default, and can't truly defend why they need it.

In this thread, there are several claims that it's impossible to write well-organized jQuery. That sounds an awful lot like dogma to me. Also, your inability to write well-organized code says more about your coding and team-management skills than it does about any one approach. Any tech is only as good as the team using it.

A few years ago, Sam Stephenson (who originally wrote the Prototype library, before jQuery was a thing) gave an excellent talk on Turbolinks at RailsConf. I recommend the whole talk (turn it up to 1.5x speed, of course) but at 4:12 he does an amazing job of showing how the SPA path leads to insanity.

https://www.youtube.com/watch?v=SWEts0rlezA

Here's a mental exercise for you: the next time you start a new project, instead of deciding which SPA framework to use, start with an assumption that an SPA is wild overkill for the first iteration of your application - especially if few people on your team have working expertise with the SPA in question. Then see if you can argue FOR the tech. It's much harder to justify something you don't need if you start with an honest conversation about how you probably don't need it. (This works for throwing out CDs, too: start with the assumption that they are all garbage, they all go. Then force yourself to make logic-based arguments for each one you keep. Your outcome will be night and day from if you start with everything in a keep pile.)

Re:Escaping the SPA rabbit hole with modern Rails by cm2187 on Sunday July 08, 2018 @04:21AM (#17482703)
As a user my main beef against SPA is that most of the time they break basic browser functionalities, like the ability to open links in a new tab, or using the back button. When the UI doesn’t simply break with part of the content off-screen.
Re:Escaping the SPA rabbit hole with modern Rails by thesephist on Sunday July 08, 2018 @08:40AM (#17483486)
Having built some SPA's, I'd argue that at least those two things that you mentioned are the fault of whoever built bad SPA's, rather than issues with SPA's as a whole. It's possible to build an SPA that works well with the browser controls because modern browsers expose a lot of their functionality to JavaScript (like it or not). You can use <a> tags for buttons and links in an SPA (and keep the link functionality) -- you can just intercept the clicks when the link is being opened in the current tab, and you can always hook onto pushState/popState to make the back/forward button work.
Re:Escaping the SPA rabbit hole with modern Rails by acdha on Sunday July 08, 2018 @09:42AM (#17483747)
It is an issue with SPAs as a concept because part of that concept is that you’re taking on responsibility for things the browser traditionally did for you.

That’s not a bad thing but it’s extra work which someone has to be responsible for, similar to how e.g. using a complex custom widget means you’re on the hook for accessibility rather than the browser vendors.

Re:Escaping the SPA rabbit hole with modern Rails by baddox on Sunday July 08, 2018 @06:31PM (#17486640)
Surely most creators of SPAs are using some routing library, and I’m not aware of any routing libraries that don’t handle this anchor tag click behavior by default. It’s really a trivial amount of “responsibility” to take on.
Re:Escaping the SPA rabbit hole with modern Rails by acdha on Sunday July 08, 2018 @11:19PM (#17487745)
Perhaps, but it’s something I encounter fairly regularly, especially when an unreliable network connection or other JavaScript failure breaks something with poor error handling. Again, not a showstopper but it’s a decision point: if you aren’t committed to testing this kind of thing on every release, you don’t have the resources to build an SPA.
Re:Escaping the SPA rabbit hole with modern Rails by emodendroket on Monday July 09, 2018 @10:13AM (#17490283)
It's no different than stuff like not trusting browser input or avoiding a massive session when you're working on a Web app: it's simply basic best practice stuff that you don't even have to think about if you have an idea what you're doing.
Re:Escaping the SPA rabbit hole with modern Rails by temporaryacc62 on Sunday July 08, 2018 @09:39AM (#17483735)
Would you say Youtube works better now as it is fully SPA?
Re:Escaping the SPA rabbit hole with modern Rails by fny on Sunday July 08, 2018 @10:19AM (#17483911)
There's an army working on YouTube, and it has the traffic levels to justify the investment. They can actually put in the required effort to ensure the application functions seamlessly and meets accessability standards.
Re:Escaping the SPA rabbit hole with modern Rails by Rjevski on Tuesday July 10, 2018 @04:25AM (#17496256)
It does not. The SPA is so sluggish I’ve learned to just force a page refresh after clicking on anything because a full page load is actually faster than their bullshit SPA.
Re:Escaping the SPA rabbit hole with modern Rails by emodendroket on Monday July 09, 2018 @10:07AM (#17490237)
That's exactly the reason to use a SPA framework where all these problems are solved for you.
Re:Escaping the SPA rabbit hole with modern Rails by GordonS on Sunday July 08, 2018 @11:07AM (#17484113)
At my day job, I mainly build web apps for enterprise customers, and for maybe 90% of them we use ASP. NET MVC or ASP.NET Core MVC, with a smattering of jQuery and vanilla JavaScript on the client side. This is a tried and tested stack that works well, has a huge ecosystem, and has great development and debugging stories.

There seems to be an awful lot of devs now that only know and use JavaScript, consider server-side technologies to be 'old skool', and prefer to use whichever SPA library is the new hotness - but IMO, most web apps just don't have UIs that are complex enough to warrant using a SPA.

Re:Escaping the SPA rabbit hole with modern Rails by emodendroket on Monday July 09, 2018 @10:09AM (#17490252)
.NET is just as well suited for SPAs as any other technology.
Re:Escaping the SPA rabbit hole with modern Rails by mercer on Monday July 09, 2018 @05:49PM (#17493731)
I generally agree with you, and as a front-ender-first that feels kind of uncomfortable to say. In my personal projects I do often go for a more conservative server-side first approach.

That said, it really feels like a chasm that quite often I choose to cross simply because it'll be easier down the line. I've been bitten more than once by server-side-first projects where going full-on client-side with the server-side as an API would've probably been better.

Whether it was because I needed a mobile app to communicate with said API, or whether the complexity ended up being more of a client-side thing, the result was often that I had to focus on the back-end as as API and go for the full complexity of a front-end app anyways.

I'm enough of a fan of my preferred back-end languages (Ruby, but mostly Elixir these days) that I try to find ways to keep the complexity there, but truthfully I often opt for going for the full complexity of a client-side JS/TS stack because I'm likely to end up needing it eventually anyways.

I've looked into things like Drab (https://github.com/grych/drab), but ultimately there are many reasons why 'going with the flow' seems like the better solution (even if just because it's so much easier to find JS devs than Elixir ones).

So far I'm not confident enough to make any sweeping statements, but from that lack of confidence I tend to opt for the 'safer' option, which seems to be the SPA route much of the time.

Re:Escaping the SPA rabbit hole with modern Rails by noxecanexx on Sunday July 08, 2018 @08:25PM (#17487119)
+1 for the last paragraph. I used that technique to quell my desire to use event sourcing everywhere
Re:Escaping the SPA rabbit hole with modern Rails by pier25 on Sunday July 08, 2018 @06:32PM (#17486641)
Thanks for sharing the video. It's really good.
Re:Escaping the SPA rabbit hole with modern Rails by divs1210 on Sunday July 08, 2018 @04:17AM (#17482694)
Sounds like you haven't been introduced to reagent.

https://reagent-project.github.io

Re:Escaping the SPA rabbit hole with modern Rails by peteforde on Monday July 09, 2018 @02:55AM (#17488419)
Okay, I admit it: I honestly can't tell if you're joking or not.

I think that you're joking, but if you're not joking, well, we have different definitions of simple.

Re:Escaping the SPA rabbit hole with modern Rails by divs1210 on Monday July 09, 2018 @04:11AM (#17488692)
I'm not joking. Spend some effort. Challenge me. You build a UI in your favorite framework. I'll use reagent. Document the code. Compare the code then.
Re:Escaping the SPA rabbit hole with modern Rails by peteforde on Monday July 09, 2018 @04:26AM (#17488739)
Dude, I've got work to do.

You threw down a URL to a framework I don't know that is apparently similar to a framework I don't use and runs on Clojure, which I don't work in and none of my codebases run in. You did that with no context or even taking the time to explain why I would do such a thing.

Objectively, there's nothing simple or expressive about the samples on their homepage. Their demos are simplistic (todo?! seriously?) and do nothing to convey why someone would express a complex web app in this manner.

It seriously looks like Matrix code to me.

Re:Escaping the SPA rabbit hole with modern Rails by divs1210 on Monday July 09, 2018 @07:50AM (#17489524)
So just because you don't know German and I ask you to read some German text, you will say this looks super complex, even if it's a simple line saying "Good day!".

Wow! Indeed our definitions of simple are different.

Re:Escaping the SPA rabbit hole with modern Rails by peteforde on Monday July 09, 2018 @03:47PM (#17492889)
If you want to spend your days learning flavor of the minute web frameworks instead of actually building stuff, knock yourself out.

If you have anything more substantial to add to the conversation that actually relates to my original comment, I'll be here.

Re:Escaping the SPA rabbit hole with modern Rails by divs1210 on Tuesday July 10, 2018 @07:57AM (#17497251)
Well, I've built stuff in reagent, enjoyed it immensely, and been paid for it. Enjoy your jquery! (and your ignorance!)
Re:Escaping the SPA rabbit hole with modern Rails by y4mi on Sunday July 08, 2018 @09:30AM (#17483694)
sounds like you didn't actually understand the parents point.
Re:Escaping the SPA rabbit hole with modern Rails by peteforde on Monday July 09, 2018 @02:52AM (#17488414)
I'll give it a shot if there's a stable build of the Reagent<->BrainFuck transpiler working.
Re:Escaping the SPA rabbit hole with modern Rails by hashkb on Sunday July 08, 2018 @11:20AM (#17484183)
Or that you need to be introduced to Reagent. Simple doesn't even begin to describe it.