34 ms·
If Not SPAs, What?
- bgdkbtv 6y agoI'm building an app with a TALL stack now (Tailwind, Alpine.js, Laravel, and Livewire) and I am incredibly productive. Very little build step required (to compile Tailwind to reduce the size based on which classes are used in .blade.php files). CRUD, Image uploads etc are so easily done I am such a fan. I was skeptical at first, but now I love this way of building web apps. No idea how well it scales, but for a simple MVP I couldn't have asked for a better stack.
- yagodragon 6y agoSeriously, after all these years of JavaScript,SPA,react,redux craze, we're back at PHP, css and minimal js all over again. None of those new js frameworks allow you to build custom web apps faster than Laravel or Rails. I'm really curious about what kind of side projects all these people are building with e.g. next.js alone. Is there any kind of web app that doesn't need authentication, authorization and database access?
- bgdkbtv 6y agoI write full SPAs at work, professionally. We use React, Apollo, GraphQL, Webpack etc. the TALL stack is such a breath of fresh air. I can't even begin to explain my joy. Just joy. I now dread the time I have to write those infinite lines of JS, conflicting dependencies, slow build times, React hook state management etc. When I speak with my colleagues about tech, they all seem to love the entangled mess of JS dev and willing to jump on any new framework that gets released. I always push for good old reliable SSR. Often get called the weird one for being young, yet favoring old school tech, though. I guess I prefer a better developer experience and shorter time to production/market, rather than spending days trying to setup a project and figure out weird quirks and issues with such a complicated mess of a "serverless, modern day web application".
- bgdkbtv 6y agoRegarding auth and db, the ones I've spoken with that prefer JS way of doing things like to combine a bunch of existing offerings into one, eg Auth0 for Auth, Prisma for DB and so on. The more potential points of failure, the more attractive it seems to them. When saying that Laravel/RoR gives you all that by running one simple command, I get blank stares. Hard to believe, I know.
- Scarbutt 6y agoRails doesn't give you auth* though.
- bgdkbtv 6y agoAh, sorry. I don't have much experience with RoR. Laravel, mostly, and Laravel auth is one command away. I assume RoR won't be too far away from that, too.
- d3nj4l 6y agoI can imagine people thinking Devise is Rails' own auth, given how popular it is.
- gremlinsinc 6y agowell, whenever I did rails, that was pretty standard. Laravel's baked in auth, is probably why it's so much better than rails, that and queues, telescope, etc... all the nice to haves that come standard in laravel that are extra in rails apps.
- BilalBudhani 6y agoI agree on this. But, you could add a few gems to Rails and it comes at par with Laravel.
- yagodragon 6y agoWe've come to the point that being able to run code and render html on a server is considered a new feature (aka SSR and serverless functions). I recently watched the Next.js conf and i couldn't help but giggle. -Do you want functions? Use our proprietary platform -Do you want to store content? Use cloudinary, aws - Authentication? Auth0,firebase - Database? Use FaunaDb and our super cool new query language that nobody knows and cares about. > Congratulations. You've built your new webapp on Jamstack. Now you have to manage large bills across hundreds of 3rd party services, vendor lock-ins. Also good luck trying to reproduce all that on a development machine or organize your code. On the other hand you can just: laravel new project-name --jet and deploy on a single linux machine or heroku and you get: -Robust and customizable Auth, password reset, 2fa -A serious db like PostgreSQL and an orm -SSR by default with 0kb bundle size! -Any css tool you need -Easy APIs, tokens and permissions -Truly open source.You have full control of your code and data So yeah it's just a command but yikes, who uses PHP in 2020, right?
- cutler 6y agoFor all the speed bumps PHP 7 delivered Laravel typically scores lower than Django and Rails on Techempower benchmarks. This and the reality that PHP roles typically pay 20% less than Ruby, Python or Node has led me to ignore Laravel.
- bgdkbtv 6y agoI haven't built anything that requires significant performance tweaking other than some caching and SQL optimisations. Maybe PHP 8 will bring an even better performance when it gets released > HP roles typically pay 20% less Yeah, true. Hence why I am a React dev professionally
- cutler 6y agoI'm not saying any of Django, Rails or Laravel are fast compared with Node, ASP.Net or Spring but what surprised me was how PHP 7, which is a lot faster than Ruby or Python, somehow managed to fall behind when Laravel was added into the mix. It's as if PHP's performance gains only really apply to raw PHP or lightweight frameworks.
- winrid 6y agoTechempower is neat, but there are plenty of companies making tens of millions with less than 100 rps...
- rawoke083600 6y ago
- rochak 6y agoI saw this SPA performance issue when interacting with Azure and GCP console. AWS console, on the other hand, is mostly non SPA and responds super fast. It didn’t feel jarring and loaded very quickly. It had a questionable UI, but I feel that AWS might have noticed that SPA would ruin the UX of navigating consoles. It is a small thing, but a big reason why I prefer developing with AWS. GCP comes close second in terms of performance with a SPA. Azure just shits the bed and seems like a pile of mess. What has your experience been like?
- jlokier 6y agoThe Phoenix LiveView pattern is one that I thought was the near-ideal interactive page architecture 20 years ago, long before Elixir and even before XHR was standardised. (We had other methods for AJAX and server-sent events to achieve it in those days.) It surprises me that there are so few implementations using this pattern today. The Meteor pattern is another good one for the user, if you like things better optimised for user-visible latency (as user interactions happen at the client first), but it hasn't ended up with much mindshare now. Perhaps because it's more complicated to use, and perhaps because JavaScript isn't ideal for this. Svelte's precompiled diffs and minimal client-side code is another pattern I like. For an application I worked on, I developed a combination of those three patterns. It had a nice and very efficient combination of server-side rendering and client-side immediate interaction, without needing custom JavaScript. This made it fast, user-friendly and pleasant to develop in. Like LiveView, the client would send user events to the server, which would update affected component model state (which could be shared among different clients too). Server would re-render any visual components which used the model data (using automatic dependency tracking from previous renders), and then send an async event to each affected client containing an efficient diff of all rendered changes. If there was much network latency or too much queued, multiple updates would be batched together, merging their diffs efficiently. The result was the update could be worst-case the size of a page replacement for any number of updates, and at best the size of a few DOM edits in place. But, a little bit like Meteor (but without custom JS), the server could also push "client event-handling hints" in the rendered model to the client. If an event pattern-matched one of these hints, the update could be applied immediately on the client as well as the event sent to the server. The server knew what update would have been applied, and could account for it in the diff. So if the server's new rendering matched the client's immediate rendering, the diff was empty and didn't need to be sent! But if the server got a different result, for example the event caused an operation which failed, the diff caused the client to receive an appropriate correction. The diffs were calculated efficiently too, not by rendering components and comparing trees, but by precalculating diff trails from state change patterns where those could be recognised. For example when one model value changed, if the diff would always be just a string change in the DOM, it already knew and emitted that diff directly. This meant diff calculation time was as fast as possible in simple cases (event to output in O(1)), and reduced to a reasonable diff time in the most complex cases (such as merged diffs). Keeping it always perfectly in sync and always efficient, throughout network outages, reordered requests, lost events etc was quite technical, but it wasn't application specific. Only the framework needed to deal with the technicality. This was lovely, because it always stayed in sync, it was always efficient for any combination of initial loads, reloads, and sync events, both on slow and fast networks, it worked without JavaScript if needed, had client-side immediate updates for simple logic of a general-purpose nature specified by the server-side, could share model state among different clients and pages, and still didn't need any custom JavaScript for the application. As the server side was written in async coroutines and Perl, it didn't seem worth the effort of packaging and publishing that implementation as Perl's popularity declined (and indeed coroutines seem disfavoured there as well, even though they work brilliantly). I still think that's a lovely interactive webpage model, possibly the best. Nicer than client-side SPAs and nicer than server-side rendering. It's pleasant to develop for, pleasant as a user as well, very fast in many different scenarios including poor network connectivity, and great for sharing live state that appears in multiple pages or documents. I'd like to implement that again in a modern language, but I haven't had any compelling reason to work on a webapp lately.
- tomhallett 6y agoMy goal is to write a demo app with: - Rails - StimilusReflex - view_component (https://github.com/github/view_component https://github.com/github/view_component) - Web components With these 4, it divides responsibilities very cleanly/pragmatically: Rails is your app framework. view_component is how you divide your view into an organized/flexible structure. StimilusReflex is the "reflexive" bridge between the 2. What happens when you need just a sprinkle of javascript to re-render a component when websockets/StimilusReflex are too slow (ie: user interacting with a color picker or something)? You could use Stimilus.js to sprinkle this interactivity... BUT you might end up with duplication between your view_components and your Stimilus.js controller. If you use webcomponents, then you can follow the open/closed rule: Your view_component can only interact with your custom webcomponent and then your webcomponent knows how to render/re-render those custom bits. So it doesn't matter if that webcomponent is rendered from: initial page load, StimilusReflex, or rapid js events (before they are throttled to StimilusReflex), it's all goes through the webcomponent "front door".
- dchuk 6y agoIf you’re going to use view components, maybe check this out: https://github.com/unabridged/motion https://github.com/unabridged/motion
- brainbag 6y agoI've been thinking about this setup a lot but never have time to try it. Is there somewhere I can follow to be notified when you accomplish this?
- nickjj 6y agoI've always been a fan of Turbolinks. Especially since it works with every tech stack with pretty much no code changes required to your existing app. The next iteration of Turbolinks will also work for form submissions without any server side code according to what's been publicly discussed from Basecamp employees. That and partial page changes will be possible with Turblinks frames which is a huge upgrade. A while back I made a video on the benefits of using Turbolinks and how to set it up if anyone is interested https://nickjanetakis.com/blog/improving-your-page-load-speeds-on-any-site-with-turbolinks https://nickjanetakis.com/blog/improving-your-page-load-spee.... Just be mindful that Turbolinks alone isn't enough to replace a SPA. It's typically paired with Stimulus but you can pair it up with jQuery, Alpine or whatever you want when you want to do more than page transitions, form submissions and swapping content in a specific area of a page.
- ng12 6y agoIf you can do server side great: do it. The difficulty is accurately predicting how much JavaScript you'll end up writing. If your client-side JavaScript is comparable in complexity to your SSR you'll eventually end up with the worst of both worlds.
- mattmanser 6y agoIs it really that difficult? If a client tells me what they want built, I bet I'd be able to roughly guess how much js there's going to be, probably within a few hundred lines for a, say, 3 month project. The larger the project, the large the margin of error, but still, it's really not that hard for the vast majority of work we do. Or at least I do, e-commerce, enterprise apps, etc.
- sgarman 6y agoThat sounds logical if you are doing client work with a defined scope. From personal experience working in the startup world, which I imagine a lot of posters on here are, you don't always know what you are building or what the end game is.
- blakehaswell 6y agoI'm not sure that's such a huge problem. HTTP routing provides a wonderful architectural seam so that we can use different solutions for different domains like `/profile` and `/document-editor`. We can create rich client-side experiences without creating a monolithic SPA. And as long as we make sure we have those architectural seams we have the flexibility to decide.
- ng12 6y agoOrganizing my HTML into pages is the easy part. The hard part is the rich client-side experience: things like building a sortable/filterable table with a rich datetime picker where the data is displayed dynamically in a chart with zoom/pan capabilities. That's why I build SPAs: I've already bit the bullet to get highly dynamic client-side code, it's just as easy to construct my pages client-side as well.
- jimbob45 6y agoAn actual app? I’d love for container-sandboxed native apps to make their “comeback”.
- EGreg 6y agoI am going to advocate the other way: https://qbix.com/blog/2020/01/02/the-case-for-building-client-first-web-apps/ https://qbix.com/blog/2020/01/02/the-case-for-building-clien...
- randompwd 6y agoThe fan on my thin laptop are nearly always on when browsing the web. Something that wasnt the case even 3 years ago. Too much JS being executed on every page.
- kqvamxurcagg 6y agoHaving mostly used Angular and React with APIs, I recently wrote a small app with server-side templating and a very small amount of jquery. It was an absolute joy. Especially with webpack it feels like the front-end has become needlessly complex and I'm not sure it has improved quality for users.
- k__ 6y agoIsn't Next.js (and in turn React, on which Next is built) the answer to that question? It can do client side rendering, server side rendering, and static site genration.
- yokto 6y agoIt was my first thought, but mope. Read the article and check out a few of the mentioned frameworks, it's eye opening.
- k__ 6y agoI did. I know the other frameworks and to me they all seem to have given up and go back to SSR. I'm much more interested in what's coming from the Snowpack/Skypack direction.
- xiaomai 6y agoI think Phoenix Live View is maybe the most compelling story around this (https://github.com/phoenixframework/phoenix_live_view https://github.com/phoenixframework/phoenix_live_view). I'm moving a side-project from React/SPA to Phoenix live view and it's kind of amazing to get the dev ergonomics of a server-rendered page with the UX benefits of a SPA. This course is a pretty great intro: https://pragmaticstudio.com/phoenix-liveview https://pragmaticstudio.com/phoenix-liveview
- PopeDotNinja 6y agoWhat is Live View not good at?
- AlchemistCamp 6y agoIt's not suitable for using the client's computer to mine crypto currencies, doing graphics processing on the client, doing numerical processing on the client or doing anything purely on the client without server interaction. For things where you generally need a trip to the server anyway, like validations, it's great.
- IggleSniggle 6y agoYup, exactly. If you’re mostly building a client application (or a p2p client-server application!) but it happens to live on the web platform, PLV does not seem like a great fit...at least not this year. Honestly BEAM seems great it ought to be great for that generally! Maybe if you ran the server portion of PLV in the browser...but then you’re just back at React anyway I suppose.
- thejosh 6y agoYou wouldn't use it for an offline app, but that's not what it's being marketed towards.
- dugmartin 6y agoI've been playing with LiveView myself for personal projects and it is very nice. One interesting thing is that it makes you consider memory issues again since all your rendered data structures are held in memory in the LiveView process unless they are explicitly cleared after the render with "temporary_assigns". For apps that would have to hold and transfer a lot of data up and down the channel I've ended up using a hybrid of LiveView with divs set to phx-update="ignore" in which I mount React components.
- stevebmark 6y agoThe future is Next.js with SSR first and selective client side hydration. Ignore the jamstack, it's going to lose and go away. Requiring a JS download first to show a dynamic site is a recipe for bad performance.
- Griffinsauce 6y agoIsn't SSR (or even better SSG) the M in JAM? It's a marketing term anyway and it doesn't really need to "lose", we can just talk about the technologies instead. Next.js gives you a great toolbag to choose from for each challenge, it's definitely going to stay around and keep growing like crazy.
- k__ 6y agoI thought so too. JAMStack is Next.js with SSG+CSR.
- stevebmark 6y agoI believe the M is static HTML, not dynamic SSR HTML
- eyelidlessness 6y agoI would also prefer something like Next.js with partial hydration. But what I want in that is probably a much bigger ask: I want the partial hydration to be performed automatically with static analysis. Something like Svelte (real DOM codegen, no need to ship a library to the browser) would be especially nice, but I don’t want to give up JSX. In the end, this is probably well outside the scope of a framework coupled directly with React, and I suspect that if I want it badly enough it’s something I’ll need to build myself.
- stevebmark 6y agoI'm not sure if we're saying the same thing, by partial hydration I mean only wiring some specific client side components for interactivity. As in only shipping the react components over the wire that need to be rendered on the client for user interaction. Meaning the overall page is vanilla HTML, but some subtrees are React wired components. Complete with state management that can work between all of them. In which case I'm thinking it would be fine to mark components individually as server/client.
- zmmmmm 6y agoMy argument for SPAs rests on the completely subjective yet I feel incredibly powerful impact of latency. When anything takes more than 50ms to react, it becomes mentally jarring to the user. Whether it is typing in an SSH session, clicking a menu with a mouse, auto-completing a box, etc - all these things generate a completely different human response and relationship with the application if they get below that threshold of latency. In my experience, it's nearly impossible to get non-SPAs across that threshold for large sections of their functionality, while for SPAs it becomes more or less the default. So people can make all the technical arguments they want, but to me the human factor of that subjective feeling trumps it all.
- cblconfederate 6y agoThat's not possible for SPAs outside localhost. Every single SPA i know is clunky, including gmail which is probably one of the most barebones. The lack of visual indication that something is happening or downloading alone is infuriating with SPAs. Most of them reinvent the browser in a very poor substitute that invariably fails to both be practical , and to mimic a native mobile app (i think the latter is the reason for so many SPAs. Almost never had a problem with HN either
- dralley 6y ago>including gmail which is probably one of the most barebones. And yet, it still uses 130 flipping megabytes of RAM, more than Youtube does, as well as more CPU than Youtube does at idle, as well as requiring several seconds to "start up" when first opening a tab. Ridiculous.
- taeric 6y agoI think gmail is a bit of a parody of itself nowadays. For extra hilarity someday, try pressing "c" for compose as the site is loading. Literally seconds to get a compose window showing.
- buzzerbetrayed 6y agoSPAs are like CGI.. you only notice it when it is bad. I can assure you, you use many SPAs that are not slow and clunky, you just don't realize they are SPAs
- candiddevmike 6y agoOur app (https://domestica.app/login https://domestica.app/login) is a pretty good (IMO) example of a blazing fast SPA. It uses Mithril and copious amounts of chunking to make the bundle size extremely small.
- vmception 6y agowhile breaking my back button nothing to do with the SPA of course
- candiddevmike 6y agoWhich part breaks your back button?
- vmception 6y agoon ios safari when I click that link, and then swipe back or press back, instead of showing me this hackernews thread it shows me that site again
- ceejayoz 6y agoOn my browser (Firefox, on OSX) it loads /loading then /login. When I go back, that takes me back to /loading, which forwards me to /login again immediately. Going back requires holding down the back button so I can skip that history record. Illustrated: https://imgur.com/a/zFaGw4a https://imgur.com/a/zFaGw4a (Quite a few sites screw this up. It's very annoying.)
- candiddevmike 6y agoThis is great, thank you for sharing. We primarily test in Chrome which doesn't seem to display this for whatever reason. Should be an easy fix to remove the history for the loading page.
- ceejayoz 6y ago
- dnautics 6y ago> they also wholeheartedly embrace the thing everyone tries to avoid: mutable state on the server. For most apps in Phoenix LiveView, it's probably best to think of this as a "relatively smart caching layer". Keeping state on the client invokes distributed state concens anyways, and in the case of the Phoenix, at least the VM is well-equipped with the relevant primitives to make distributed state easy, especially. Basically the only cost you have to pay is if latency is a big deal, you are making a trip back and forth to the server, which could be 100s of milliseconds or more in bad situations... Or even really bad situations, like driving under a tunnel, or being in some stretches of subway.
- merb 6y agowell there is also React.NET which actually can use razor pages to include react components. pretty neat. also there is blazor which works with websockets and pushes html to clients.
- ckorhonen 6y agoI used Turbolinks for the first time on a new Rails app about 2 years ago and was floored by the impact - it felt like a SPA in terms of no page loads and overall speed. I'm convinced that this is the solution for the majority of use-cases, combined with selective usage of either React components or something like Stimulus where you need more sophisticated UI components.
- ForHackernews 6y agoIs there an equivalent of Turbolinks for something like Django? Or even for MVC PHP apps?
- deefour 6y agoTurbolinks isn't specific to rails.
- cutler 6y agoI think the more generic term is Pjax.
- bojanz 6y agoIf you're a Laravel user you'll want to look into Inertia.js[1]. [1] https://inertiajs.com/ https://inertiajs.com/
- raihansaputra 6y agoAs mentioned, you can use Turbolinks with django. There's also Intercooler/htmx, and Unpoly.
- gremlinsinc 6y agomost people using livewire on laravel also use turbolinks, it's just a javascript plugin, it's not rails specific.
- rogem002 6y agoYou can use Turbolinks on any front end project (I use it on my static sites), it has a standalone JS library.
- treis 6y agoThe missing link, IMHO, is the lack of client side SQL and a sync mechanism. IndexDB is okay, but nobody is going to use it server side. So you kind of always have to end up writing things twice.
- nullsense 6y agoYou want a web browser talking directly to an RDBMS of some kind?
- treis 6y agoYes, like we had with WebSQL until it was deprecated. Basically a SQLite db per site.
- knubie 6y agoI think the idea is that IndexedDB acts as a more lower level store that you can build higher level abstractions over, for example PouchDB.
- throw_m239339 6y ago> I think the idea is that IndexedDB acts as a more lower level store that you can build higher level abstractions over, for example PouchDB. AFAIK, the problem was that vendors couldn't agree on which version of SQL/Sqlite they would have to support and nobody wanted to write a SQL spec. MS wanted to use SQL Compact, but it's mainly Mozilla's fault if the spec was dropped. The same Mozilla that dragged its feet for years when it comes to implementing some aspects of web components... But it was a terrible decision IMHO because indexedDB doesn't do what a relational database does and it considerably hurt the development of complex mobile web apps, and now Safari on IOS AFAIK removed support for WebSQL. WebSQL was a fantastic tool for web apps that could be entirely cached on a mobile device (SQL can do a lot). There is no realistic replacement. Even using Sqlite compiled to WASM has a lot of issues (mainly performances and data persistence). To this day I don't know a single efficient and performance RDBMS equivalent to Sqlite built on top of IndexedDB. Mozilla certainly didn't build one.
- dfabulich 6y agoIMO, TurboLinks + service workers are the way to go. Not many people know this, but a service worker (previously called "local server") allows you to run a little web server in the user's browser that intercepts requests to your own web site. (There's no open IP port.) The service-worker web server can proxy requests to the remote server, and even build/store entire pages on the client side, enabling offline support. Service workers also have access to a local database, IndexedDB, running in the user's browser. You can build a very fast web experience this way. You can easily cache individual pieces of a web page and glue them all together. For example, you can easily implement server-side includes https://en.wikipedia.org/wiki/Server_Side_Includes https://en.wikipedia.org/wiki/Server_Side_Includes or edge-side includes https://en.wikipedia.org/wiki/Edge_Side_Includes https://en.wikipedia.org/wiki/Edge_Side_Includes but running on a server that's running on the client.
- untog 6y agoStrongly agreed that service workers have a ton of potential here. But I’m still waiting for there to be some kind of killer framework that crosses the bridge between worker and window, saving lots of main thread processing, etc... MessageChannels are quite low level so I imagine it would need some abstraction. But still, very powerful. I’m imagining some kind of Svelte-like thing that creates the whole page worker-side, then generates minimal window-side JS to hydrate the components that’ll actually change. Of course I’d make it myself, but... oh, look over there... (IMO they should still be called local servers, or server workers perhaps. Service worker is too vague)
- nymanjon 6y agoI'm working on something like this. Not really a framework though. More of a hodgepodge of JS that I've written and the front end logic would be something like HTMX/Behavior.js style of coding. It will be a progressively enhanced approach to writing a SPA so you could have no JS and it would still work! Or, if you have a modern browser it would work offline. We'll see if I ever finish it :-) I'm doing a bit of a rewrite right now so this flexibility will come soon. https://github.com/jon49/MealPlanner https://github.com/jon49/MealPlanner Right now it only works offline.
- firefoxd 6y agoMaybe this is more suited to stackoverflow but, how do you load with turbolinks when the two pages use different assets? Let's say each page have different js script tags.
- kej 6y agoTurbolinks gives you a few options, depending on if you want the script evaluated once or each time that page is loaded: https://github.com/turbolinks/turbolinks#working-with-script-elements https://github.com/turbolinks/turbolinks#working-with-script...
- cateye 6y agoI've always felt this problem from the first time I touched Angular. It was just so much more complex and fragile without actually a lot of benefit unless you wanted to make a really interactive async application like Google Docs or Facebook Chat. When SPA's became the norm and even static web pages needed to be build with React, developing became more and more inefficient. I saw whole teams struggling to build simple applications and wasting months of time, while these used to be developed within a couple of weeks with just 1 or 2 developers, on proven server side opinioated frameworks. But that was no longer according to best practices and industry standards. Everything needed to be SPA, micro services, distributed databases, Kubernetes etc. These components and layers needed to be glued together by trial and error. I am really happy that common sense is starting to return and more developers are starting to realize that integrated end to end frameworks are very useful for a lot of real life application development scenario's.
- throw_m239339 6y ago> I've always felt this problem from the first time I touched Angular. It was just so much more complex and fragile without actually a lot of benefit unless you wanted to make a really interactive async application like Google Docs or Facebook Chat. It sounds crazy to say that now but Angular became big because it was actually quite lightweight compared to other JS frameworks of this era, declarative 2 way databinding was cool, it was compatible with jQuery (thus its widget ecosystem) and it was also developed with testing in mind. So it was easy to move jQuery projects to Angular ones, and developers cared about this aspect and it helped organize code quite a bit. Angular 2 on the other hand never made sense and it was a solution looking for problem. React and JSX came along and allowed developers to use JS classes when a lot of browsers didn't support them. And unidirectional dataflow was all at rage. It was always the right solution of course, but I never heard about DOM diffing before that which to me is the main appeal to React. To this date, HTML API still do not have a native(thus efficient) DOM diffing API which is a shame. > When SPA's became the norm and even static web pages needed to be build with React, developing became more and more inefficient. I saw whole teams struggling to build simple applications and wasting months of time, while these used to be developed within a couple of weeks with just 1 or 2 developers, on proven server side opinionated frameworks. But that was no longer according to best practices and industry standards. Everything needed to be SPA, micro services, distributed databases, Kubernetes etc. These components and layers needed to be glued together by trial and error. IMHO the problem isn't React and co or even SPA. In fact writing an REST/Web API should be easier than writing a server-side generated HTML website (no need for templating language, ugly form frameworks,...). The problem is the horrible and complex NodeJS/NPM backed asset compilation pipelines and build tools that these framework often require in a professional setting, which incur a lot of complexity for very little gain.
- vanburen 6y agoThe hydrogen client for matrix.org (1) has an interesting approach using vanilla JavaScript and indexeddb. From a previous this week in matrix(2): "Hydrogen tries to be the lightest Element. It is written entirely in vanilla javascript (no React, no Webpack) for complete control, structured as an MVVM app, leveraging the raw performance of indexeddb." (1) https://github.com/vector-im/hydrogen-web https://github.com/vector-im/hydrogen-web (2)https://matrix.org/blog/2020/08/14/this-week-in-matrix-2020-08-14#hydrogen https://matrix.org/blog/2020/08/14/this-week-in-matrix-2020-...
- jolux 6y agoOne entry in this space that doesn't get a lot of attention is ASP.NET Blazor [1]. Blazor gives you the option of writing views in C# that will actually compile to WebAssembly and run in the browser, or run on the server and send DOM updates over a SignalR connection, a lot like LiveView. [1] https://docs.microsoft.com/en-us/aspnet/core/blazor/ https://docs.microsoft.com/en-us/aspnet/core/blazor/
- catmanjan 6y agoLast time I looked it couldn't run in the browser, and there was no ETA, has that changed?
- unsignedint 6y agoAnd best of all, both Server and WebAssembly has a lot in common, so it is possible to make that movment as needed. (I often prototype in server, as it's a lot easier to debug, too!)
- kumarvvr 6y agoIf you are using Blazor Server, you don't have to even think about REST APIs. Depending on your app, that might be good or bad. But if you primarily target browsers on Desktop, you can tremendously improve productivity, because you can directly use C# POCO Models for UI and backend data services.
- ablekh 6y ago
- ForHackernews 6y agoI guess it's still targeting the client-side SPA case, but I think Svelte[0] is worth a shoutout for taking a different approach than React/Vue/Angular/etc. The Svelte "framework" is really just a compiler that produces a small bundle of vanilla JS that updates the DOM directly (no virtual DOM). [0] https://svelte.dev/ https://svelte.dev/
- swanson 6y agoI've had great success with the Turbolinks + Stimulus approach. There are a couple of common patterns that you'll reach for, namely, lazy loading content (basically a <div> with a URL attribute that you have Stimulus load via AJAX) and really leaning into Rails remote-link / server javascript responses for modals and little page updates. It's so great to still be super productive and be able to crank out several pages of an app in a few hours vs most of the React / SPA codebases where you might send the whole day on one little component.
- aledalgrande 6y agocurious how you would implement refresh of a single row in a table after a job has completed? have enjoyed this combination too, but I feel like you'd have to subscribe to multiple ActionCable channels to do this?
- brainbag 6y agoStimulusReflex can do something like this quite easily. It re-renders the entire page (suggesting that you do a lot of fragment caching so this is fast) and then diffs it on client side with morphdom (IRC). I believe you can do partial rendering now, but I haven't tried it.
- tpetry 6y agoI am using the combination too. You really get a very near SPA feeling with a lot less effort. BUT basecamp libraries (turbolinks, stimulus) are horrible open source libraries. There are not any changes or bug fixes for months now (for both) and nobody does know whats the actual state, whether they are abandoned or basecamp is working on something new. Then hey.com released and people found new features in both frameworks, so one day they will release (again) completely reworked versions of these libraries they have been working on in their private repositories. Both libraries are really good together, but they would be better if developed more open by the community. They are basically abandonware the day they are released, until one day a complete rewrite and major version bump is released.
- JeremyNT 6y ago
- camgunz 6y agoI've been building a site with Svelte/Apollo/Hasura. It's been pretty amazing so far. I think if you can get away with not needing SEO it's hard to beat. That said, something that requires a lot of thought is not just constantly displaying spinners. When I look at projects built by experienced FEs it seems like there's a lot of patterns to work around this that I'm not aware of.
- ZephyrBlu 6y ago> That said, something that requires a lot of thought is not just constantly displaying spinners. When I look at projects built by experienced FEs it seems like there's a lot of patterns to work around this that I'm not aware of I'm not sure what patterns you're thinking of. To me this just sounds like implementing caching and background fetching.
- camgunz 6y agoYeah, it's mostly that--generally also some design stuff to hide it. It's just so tedious, or you can buy into a big framework with all the downsides that implies (big bundle size or a lot of tooling for code splitting).
- brylie 6y agoHTMX https://htmx.org/ https://htmx.org/ LiteDOM https://litedom.js.org/ https://litedom.js.org/ Stimulus https://stimulusjs.org/ https://stimulusjs.org/ Turbolinks https://github.com/turbolinks/turbolinks https://github.com/turbolinks/turbolinks
- rolae 6y agoStimulus Reflex https://docs.stimulusreflex.com/ https://docs.stimulusreflex.com/ Laravel Livewire https://laravel-livewire.com/ https://laravel-livewire.com/ Phoenix LiveView https://github.com/phoenixframework/phoenix_live_view https://github.com/phoenixframework/phoenix_live_view That's where I see a lot of potential. With Stimulus Reflex I have the convenience and development speed of Rails and I can enhance it with StimulusJS sprinkles and reflexes to create great experiences for the user. The interactivity I get is enough for 90%+ of the webapps out there and the complexity to do it is far less.
- tapvt 6y agoI am quite a fan of HTMX and am using it for multiple projects now. I hope it continues to gain traction.
- edwinyzh 6y agoMe too! As a developer mostly with desktop software development experiences, htmx is so much straightforward to understand and easy to code, it's a perfect chose for me to implement pages such as 'License Upgrade', 'License Renew', and so on: https://docxmanager.com/miscpages/upgrade-to-standard-from-basic.html https://docxmanager.com/miscpages/upgrade-to-standard-from-b...
- dinkleberg 6y agoHow do you handle things like menu pop-ups and toggling/hiding content? I keep wanting to use htmx and it's like, but there always seem to be very common tasks like having an expandable menu on mobile that don't have a great solution in these libraries and I have to write vanilla JS. I've settled on Alpine instead for the time being because it has some data management built in. I'm thinking I'm going to have to switch to Vue on my current project because I feel so much less productive with Alpine.
- lexx 6y agoI think there is another layer to that conversation. Frameworks become bureaucratic and boring because they are developed by large teams for large teams. Most developers are working on small projects and need more fun and less maintaining huge amount of boilerplate code that recreates the browser. The framework that I feel makes development less ugly is svelte. But still, I really don't like the idea of heavy client side websites. It really makes everything more complicated and the user's device slower. I love the simplicity of Turbolinks, I love how clean svelte code is and I am trying to figure out the "glue"
- banashark 6y agoI went down this route recently. There are a couple of different options depending on your preference: • Write the glue code yourself if you only need svelte on a few pages • Inertiajs if you want to replace your view layer with svelte
- lexx 6y agoI agree with you. I did give a look at Inertiajs just because Laravel was friendly towards it. Looks sweet. Right now the "glue" I came up with is a silly connection between the server side router and the "Entry" component of Svelte. It works, it's 10 lines of code, it's clean and the website is super fast. But, both Inertia and my solution feel somehow "hackish". Not a proper pattern. But really, anything to avoid client side routing, state management and auto-magic code splitting.
- brainbag 6y agoWow, InertiaJS looks like exactly what I've been wishing for. Component-driven SFCs in Vue are the best tool I've used for interfaces in 20+ years, but I don't love having an API layer between the client and server. This is really interesting. Do you have experience with it and know how it handles frequently live-updating pages?
- Existenceblinks 6y agoThe only weak point for Svelte is there is no inline template composition (yet; already has a rfc). Anything that doesn't look like function is weak compossibility. Imagine recursively calling template itself with a bunch of condition logics, each branch renders different nested templates, and each of those calling its own ancestor root. Svelte is a joke to this thing.
- ChicagoDave 6y agoMicro front-ends and packaged business capabilities. Build encapsulated domains (views, events, apis, data store) with their own dependencies (not shared with umbrella app) and pluggable with meta data.
- throw_m239339 6y agoI genuinely understood nothing to that comment. Are you talking about frames? Please develop.
- EpicEng 6y agoYou're not the only one. Sounds a lot like a former CTO of mine who couldn't write a line of code to save his life, but made sure to randomly toss out buzzwords and make sure you were aware of what he recently read in what I assume was an edition of Programming for Dummies.
- Multicomp 6y agoMy company talked about using micro front ends for a while. basically there was one microservice that actually served the web page itself and all of the controls and widgets on the web page were pulled from other microservices via API calls that each handled their own internal state.
- ChicagoDave 6y agoI'm definitely not a mindless CTO. ;) Micro front-ends is the concept of breaking apart a front-end monolith. SPA's are usually built in one framework like Angular or React. Over time, this can get very convoluted and turn into a bad monolith (there are good ones). The second part is that instead of building screens, you design features (like invoices or customers or catalog) and develop the set of views that encapsulate the targeted domain. This is all built in a separate project with a well-defined set of meta data. You deploy the feature-set into your integrated environment and the managing app is constantly on the lookout for new features-sets. Then in some admin portion of your umbrella app, you provide access to API's to other feature-sets, and to users. One of the key elements is to keep front-end dependencies separate. So the manager app might be Angular 9, the customer feature-set might be in Angular 10 with its own dependencies. Nothing is shared between the manager app and each feature-set and nothing is shared between feature-sets. This provides a front-end that is malleable and reduces dependency creep. This can also benefit from Domain-Driven Design, where you've segregated your domains and their API's, Events, and Data Storage. So you should be able to "publish" a feature-set without any dependency on a central database, API mesh, or Event manager. The key is to define your boundaries well and that is no small thing.
- recursivedoubts 6y agoWell, we could go back to the original model for the web, using REST & HATEOAS without arguing or even really thinking about it, by building hypertext-based applications. Of course, the hypertext we have, HTML, wasn't completed, and it leaves a lot to be desired. I have tried to fix that with htmx: https://htmx.org https://htmx.org
- 542458 6y agoHey, this is super cool. Thanks for building it! One quick question: How should I be handling server side errors with this? Like, normally I’d check the status code coming from the server and throw up an error modal if it’s an error - what’s the equivalent mechanism here?
- Deimorz 6y agoI haven't looked into htmx much yet, but am using its predecessor intercooler-js, and this is my code for handling server responses and displaying an error message when it's needed: https://gitlab.com/tildes/tildes/-/blob/master/tildes/static/js/scripts.js#L29-85 https://gitlab.com/tildes/tildes/-/blob/master/tildes/static... I wouldn't consider it particularly elegant, but it's straightforward and has worked well. It uses the "complete.ic" event to trigger whenever an intercooler request finishes, and then uses the response status/code/text to display an appropriate message.
- recursivedoubts 6y agohtmx triggers a bunch of different events based on various request life cycle events. For server errors you'd use htmx:responseError: https://htmx.org/events/#htmx:responseError https://htmx.org/events/#htmx:responseError You could write some code like so: htmx.on("htmx:responseError", function(evt) { GrowlNotification.notify({ title: 'Request Error', description: evt.detail.xhr.responseText }) }) And that would show a growl notification in the event of an request error. Or however you wanted to display it.
- tonetheman 6y agoI think if Chrome changes to the omnibox really click. The need for SPA in general will dwindle. You cannot see the URL so if it is ugly who cares. And if the page refreshes fast enough most end users will not be able to tell you are on a SPA or not.
- buzzerbetrayed 6y agoWhat is displayed in the URL has nothing to do with SPAs. Go to Twitter. It is an SPA. The URL changes on every click, just like basically all modern SPAs.
- dragonwriter 6y agoSPA has nothing to do with URL. If your SPA uses a routing/history solution so deeplinks and history and the back button work properly (and it should), it's exactly, in terms of URLs, like what you'd naively expect from a non-SPA app.
- baybal2 6y agoYou can achieve near SPA performance with XSLT in the frontend, and stitching multiple XMLs using it. - No JS fallback by default - Naturally friendly to XML database backends - Huge cache hit improvements - Effectively, you get the functionality of the now abandoned "seamless" iframe attribute
- untog 6y agoYeah but then you have to use XSLT. (Jokes aside, I tried this years ago hoping for it to be a magic bullet. Gzipping meant that the bandwidth savings weren’t anywhere near what I hoped and XSLT is a PITA to deal with)
- mpmpmpmp 6y agoA certain fortune 500 finance company did their entire website this way using java 6 EE and serving up the data layer with XML -> Hibernate -> DB2 mainframe queries about 10 years ago. Probably still vestiges of that now.
- ssawyer06 6y agoIf not SPAs, and hear me out on this one, how about... Native applications
- Volundr 6y agoFor the last time Twitter, I am not installing your damn app!
- superkuh 6y agoYup. The web is for documents.
- ng12 6y agoYeah, no thanks. There's a reason we abandoned them in the first place. I've never heard of anyone who's itching to go back to Swing.
- buzzerbetrayed 6y agoAre you referring to Java Swing? Because Java is not native. But please let me know if there is another Swing that is.
- ng12 6y agoI mentally parsed it as a desktop application: going full native is three steps backwards rather than two.
- 1337shadow 6y agoI'm replacing my StimulusJS with Web Components (and my webpack with snowpack). Turbolinks you can have with an SPA codebase that will just request/load on clicks, and post/load on forms, not a big deal either.
- rizpanjwani 6y agoI should have just stuck with Asp.Net Webforms all those years ago :p
- waheoo 6y agoPure php, html, js, css, works ok.
- rajeev-k 6y ago> SPA pattern has failed to simplify web development The SPA pattern is fine, it is React Router and Redux that has overcomplicated things. Here's an example of an app written using the MVC pattern that is way simpler than the React stack: https://github.com/Rajeev-K/eureka https://github.com/Rajeev-K/eureka It uses two very simple libs: A 500-line router: https://github.com/Rajeev-K/mvc-router/ https://github.com/Rajeev-K/mvc-router/ A 200-line templating library that uses JSX syntax: https://github.com/wisercoder/uibuilder/ https://github.com/wisercoder/uibuilder/
- dsiegel2275 6y agoI suspected things were getting too complicated in this space when I read that someone wrote a 150 page book on React Router
- JMTQp8lwXL 6y agoThis hasn't been my experience. 10 to 15 minutes of looking at React Router's documentation was enough to get started with it. The major version bumps, however, have been a little taxing. If it takes six major releases to get the paradigm right, you should've done more research before moving onto the implementation phase.
- mercer 6y agoA while back I was faced with using whatever god-awful backwards-incompatible version of react-router to use, or instead to go for a routing solution that wasn't as insane. I don't remember what I picked, but I think it was page.js. Something that's been around forever. It was astounding to me how much it simplified the whole project. I truly can't figure out what react-router actually brings to the table, considering it's version history, compared to the myriad of alternatives.
- ausjke 6y agonobody really does MVC with react these days, it's all about components
- Multicomp 6y agoI love working in the SAFE stack since I'm a fan of F#. Being able to develop for the web using one programming language that gets transpiled to the needed JavaScript and uses the model view update pattern with elmish makes so much sense to me. Granted, I am allergic to developing any JavaScript myself because of how many anti JavaScript comments I have read on hacker news ;)
- phaedryx 6y agoI've seen a lot of SPA vs. "JavaScript sprinkles" arguments lately and I think it is a false dichotomy. You can add JavaScript interactions to a page, to existing HTML, (take a look at Vue for example) without committing to JavaScript taking over the entire page.
- kumarvvr 6y agoI found Blazor to be a good middle ground between SPAs and frameworks like Django or RoR. The problem with frameworks like Django is that they have no real concept of UI Components. They have glorified ways of copy pasting html code. The cognitive burden when creating a fairly complex app, like a set of dashboards, is very high in Django. The reason people flock to React is because, once they develop a component, it's easy to re-use. And that is the drug that fuels them. However, the learning curve is high. I found Blazor to be a good middle ground, because it has the concept of Pages (Razor pages), which are linked to URLs' and those pages can contain re-usable components. The framework is setup for basic site structures with a lot of options for customization. For example, you have default layout pages, that are included in every output. Great to put a basic menu and footer system. Those working on ASP.NET MVC and like would find it a breeze to work on Blazor. Couple that with the option of using C# for the whole application, it is very enjoyable to develop with. I have used Angular, React and Django. Angular, for me, is too much complication for simple stuff, but perhaps works well with complex apps. However learning TS, as good as it is, was a turn-off for me. React is easy to start with, but as your app grows in complexity, it becomes hard to manage and think about various stuff like state management, routing, etc. Given choice between React and Angular, I would definitely choose React. Django is very good for sites like blogs or info pages, basically wherever there is a large amount of static content, pulled from database. Of all the above, I found Blazor to be very productive. I can also mix and match different paradigms and Dependency Injection is a god send.
- pier25 6y agoThe fundamental problem is not that the SPA pattern is bad, is that it takes a lot of skill and effort to make a proper SPA. Obviously, skill and time are scarce resources and the result is that most SPAs are crap. OTOH all these component based frameworks have definitely brought us a much better way to produce interactive experiences compared to the jQuery days. This is not related to SPAs at all. You can use React/Vue/etc in a multipage application. The problem is that to hydrate (make interactive) the server rendered HTML you now need to duplicate your markup between your server language and front end framework. The solution is to use the same framework in the backend and the front and write the components just once.
- postpawl 6y agoThis discussion has happened a million times on HN and this is the most succinct explanation I’ve seen so far. Bravo
- 1ark 6y agoRecently I got to work with hybrids.js (webcomponents) which makes the hydrate part nice. Because it is normal markup with whatever data you have on your SSR-pages. It simplified quite a bit.
- pier25 6y agoVery interesting! Thanks for the recommendation.
- austincheney 6y agoNo, it doesn’t take that much skill. I think this is the source of the problem. The stupidity and hostile fear of originality I detect in this these comments is a very real reflection of my professional experience. This, dependence on frameworks and inability to imagine anything beyond the common SPA, really scares the shit out of me knowing I will be coming home from a military deployment soon and returning to the corporate world are scared to write code. Whenever non programmers ask me what programming is like I tell them it’s full of the most insecure people you can ever meet. People are afraid to do their jobs, need a framework for everything, and always talk about how hard it is (when it isn’t).
- bob1029 6y agoOn the spectrum of client-server rendering, I am leaning very far into the server-side philosophy. Right now, we use Blazor with server-side rendering for our internal dashboards. This feels almost perfect to me. There are still some rough edges and I still have to ultimately deal in terms of HTML/JS/CSS. I've got a side project that takes the Blazor server-side concept to the absolute extreme. But, I haven't had much time to work on it this year considering... Hoping to get back into the crusade in early 2021. Looking to pilot it as a replacement for one of our Blazor server-side apps in 2H 2021. One of the bigger objectives is to develop a web application that is perfectly auditable and secure as possible. If you render final client views on the server, you can DVR precisely what each client is experiencing. The client source can be ridiculously lightweight and betrays nothing regarding the business. My prototype currently serves a ~50kb single-file HTML payload that runs the entire show for each client. I am looking at things as deep as server-side rendering of the mouse cursor. Looking at each client as a simple event stream from the server's perspective is a really neat way to organize this problem.
- kumarvvr 6y ago> This feels almost perfect to me This. This is the sentence I am going to use to describe Blazor Server from now on.
- mercer 6y agoMy experience with LiveView has been similar. I can highly recommend looking into Tailwind (and Tailwind UI). For me, it solved some of the pain of still having to deal with CSS and various preprocessors for it. I can now create entire working apps using just Elixir code and the utility-style Tailwind classes within my server-side templates. I still need to write some js and css, but where LiveView reduced the need for custom js to a minimum, Tailwind did the same for css.
- hnick 6y agoIt's interesting to me that in video games we talk less about frameworks than we do engines. Doing a few tutorials, I was shocked at how little code I had to write these days with something like Unity or Godot. Breakout indie success stories are often lead by artistic types, since it seems harder to teach a typical programmer to draw than to teach an artist enough code to get by. And I think the scene is richer for it. Is there a good reason the web isn't like this? Engines, rather than frameworks, that have done the hard optimisations and made the best practice decisions for us?
- solipsism 6y agoHow often do you deal with blitting textures into vram when working on your web applications? If not very often, that means you're building on top of a stack of software that includes a rendering engine, equivalent in many ways to Unity or Godot.
- hnick 6y ago> you're building on top of a stack of software that includes a rendering engine Yes that's pretty much a web browser, isn't it? There are many types of engines, such as a business logic engine. The distinction between engine and framework is a little vague but what I'm getting at is the low-code interacting-components design approach, rather than code first. I'm wondering why that hasn't taken off. People use Godot to create GUI apps, which has problems with the final product but in terms of workflow it works to make something functional.
- TeMPOraL 6y agoGames aren't low-code. Even with UE4, people end up learning C++ because there's only so much you can do with the Blueprint flowcharts before it becomes an unmaintainable mess that grinds your development speed to the ground. It's also pretty much a law of nature that every nontrivial game eventually develops a scripting language (unless it's already written in one, e.g. Python). But it's absolutely true that you can teach artists to code - within the limited domain - much easier than you can teach programmers to draw or write stories. A personal opinion: I'm not entirely sure that being entirely art-driven is necessarily a good direction for games either. You can build a pretty game out of default UE4/Unity/Godot building blocks, but it'll be rather quickly recognized as a cookie-cutter game with custom art. If you want to innovate on, or even carefully tune, the gameplay itself, you need to code your way out of engine defaults.
- x3haloed 6y agoTurbolinks... so it’s a less elegant implementation of [Portals](https://web.dev/hands-on-portals/ https://web.dev/hands-on-portals/)?
- irrational 6y agoI have a theory. In the old days web development was looked down upon by "real" programmers. But then the WWW really took off and people started moving over from the C/Java world into the world of JavaScript. These are the people that insanely complicated web development when they tried to make it as complicated as the development world they came out of.
- CameronNemo 6y agoDo you have evidence? Vue and Svelte, IIRC, were authored by designers. Not C or Java programmers. Perhaps React has a different history.
- muzani 6y agoJS is quite a hacky language. Trying to turn it into Java neuters some of the benefits of being hacky (I'm looking at you, Typescript). But at some point, it's neither a hacky Lisp like language, nor is it stable like Java or C++. It's just a middle ground that does these things poorly. It would be nice to have a new programming language from scratch built to handle all the async/reactive mess. But until then JS is our best bet.
- brendanmc6 6y agoI hear this so often, so as an exclusively js/ts dev I have to ask... what about this is “done poorly”? ``` try { return await fetch(url); } catch (e) { handleError(e) } ``` Because that (metaphorically speaking) is 90% of what I write. Throw in the occasional closure, `map()` or `reduce()` My day to day headaches are never from TS, and always from unpredictable DOM api/layout/style behavior. I guess I just don’t have any frame of reference for how “nice” a language can be. Is it just that JS has so many “bad parts” and footguns that I’ve gotten good at ignoring?
- obiefernandez 6y agoThis recent hype piece I wrote about ReactiveRails is at around 30k views and counting. In the right hands (experienced full-stack dev like yours truly) the productivity gains are off the charts. https://medium.com/@obie/react-is-dead-long-live-reactive-rails-long-live-stimulusreflex-and-viewcomponent-cd061e2b0fe2 https://medium.com/@obie/react-is-dead-long-live-reactive-ra...
- brainbag 6y agoThis stack is very appealing though I'm not sure it's quite fully ready for primary use. Has StimulusReflex-CableReady figured out pushing new data to the client outside of the request cycle? Last I looked there was no way to trigger a client page update from a background job for example.
- hopsoft 6y agoThis is exactly what CableReady was built for... to update the DOM from any Ruby process (in the request cycle or not). It was designed from the beginning to update the DOM from out-of-band non-request based workflows like background jobs.
- yuskii 6y agoReal software.
- lmm 6y ago> How do they do this? Well, a lot of WebSockets, in the case of Reflex and LiveView, as well as very tightly coupled server interactions. As you can see in the LiveView demo, which I highly recommend, these frameworks tend to operate sort of like reactive DOM libraries on the front end – in which the framework figures out minimal steps to transform from one state to another - except those steps are computed on the server side and then generically applied on the client side. They also do a lot more data storage & state management on the server-side, because a lot of those interactions which wouldn’t be persisted to the server are now at least communicated to the server. Reminds me of Wicket's AJAX support, which is still the best web development experience I've ever had. You keep the state in the server-side session, when the user pushes a button you update that state and re-render those parts of the DOM that changed because of it. It dovetails nicely with the whole framework being properly component-oriented - rather than the page-oriented MVC style, you make encapsulated, reusable widgets that know what their own state is and how to render themselves based on it, and the actual top-level page becomes almost an afterthought.
- devasiajoseph 6y agoI use Clojuresript with a react interface to create SPAs for data analytics UI at work. It is much simpler and easy to manage. For me developing applications with javascript tend to get complex over time as the app grows. State management is really simple in Clojurescript. I was able to create reusable components which can be ported over to new projects with little effort. I now find it much more easier to develop the front end in SPA format with CLojurescript rather than rendering the UI structure with server side stack. The app tends to act a lot more faster with SPA as you see in this video https://www.youtube.com/watch?v=islPRG2_1vU https://www.youtube.com/watch?v=islPRG2_1vU
- randompwd 6y agoIn your video, you're just hitting localhost.
- devasiajoseph 6y agoThis is a just a demo to show front end UI.
- forgotmypw17 6y agosame as before, html with progressive enhancement and graceful degradation. as one dev working part time, i am still able to build for netscape 3 and lynx, adding from there.
- sdepablos 6y agoMaybe the main issue here is that while SPAs make life so much better - proper testing, immutability, one way data bindings, speed of development... - for frontenders, they make it worse for absolutely everyone else: backenders that were able to hack a passable frontend or modify a proper one; final users that deal with bigger and slower webpages; devices struggling to render websites; backends that now need way more CPU to do SRR then they ever needed with traditional websites; beginners that were able to look at the HTML & CSS of a page...
- deleted 6y ago[deleted]
- BilalBudhani 6y agoI have been using Ruby on Rails with Vue.js + Inertia.js and honestly my productivity has skyrocketed. I don't worry about writing APIs for the frontend, no need to maintain separate router on frontend and no state management required. Using this stack I'm able to build a highly reactive apps with minimal efforts.
- brainbag 6y agoDo you have any examples or favorite articles about this? I just learned about inertia from this thread and your set up is similar.
- revskill 6y agoMain problem with web development is the css issues, not about javascript frameworks.
- randomsearch 6y agoAuthor seems to think the goal of SPAs was to simplify web dev, but it’s actually to allow you to build fully featured, highly interactive, apps in a browser. What the author is really getting at, I would guess, is that front end dev is awful, due to this weird combination of the Blub issue and a historical trajectory that has caused many problems. The blub issues is mostly simple enough to pin down. Experienced programmers know that JS is an awful language. But there’s also a tooling or SDK “blub problem”. For example, compare npm and webpack vs gradle and javac (not to defend the Java ecosystem, but it does get some things right, or more right than others). More idiosyncratically, there’s this historical arc of encountering fundamental problems, and trying to solve them within the current constraints of the web, rather than perhaps waiting for the web to standardise and evolve. This seems to be a mixture of lack of experience outside of this ecosystem (a bit like Blub) and, for this and other reasons, fixing problems “in your app” that should be fixed in the fundamental infrastructure of the web. It feels like technical solutions to social problems or, to use another metaphor, we are patching downstream what should be fixed upstream... if you build a house on sand, it will never be robust, no matter how many layers of infrastructure you add. That’s where the complexity arises. It’s an enlightening exercise to step back and ask how you would build SPA infrastructure if starting anew. You certainly wouldn’t use a language like JS, you certainly would want to provide visual design tools as far as possible, APIs would be replaced with standard protocols, and probably you’d use a relatively small XML for layout. So perhaps only the HTML is anything like what you’d use. There’d be no transpilation, no webpack, no polyfills, no CSS, no JS. In fact, what you’d end up with would look remarkably similar to the dev process for a Java applet!
- TacoSteemers 6y ago> not to defend the Java ecosystem, but it does get some things right, or more right than others Out of curiosity, as a Java enthusiast, I was wondering if you could give examples of what you feel is wrong? In my HN browsing I find Java is rarely actually discussed here, though often dismissed. I don't know why.
- rytill 6y agoFor me, Java’s ties with Oracle and the nightmare stories about complicated `MetaAbstractBaseClassFactoryClassFactory` are why I seek alternatives, or would be dismissive.
- tannhaeuser 6y agoFirst thing is to identify whether you're creating a web app or a web site. The latter being characterized by content-driven approaches and workflows around HTML fragments received from editors, aggregators, syndicates, product catalogs, or other third-party sites. These sites tend to be PHP-heavy, but don't have to be; a competent markup processor or "isomorphic" web composition processor (running both server-side and in the browser such as mine based on SGML no less) is specifically designed for this purpose, with straightforward and sophisticated, HTML-aware type checking, composition, templating, and escaping. For the former category of highly interactive web apps, my recommendation would by React or Vue, based on the mindshare of these frameworks. Don't let your devs use these frameworks for the sake of padding their resumes, and try to pin down your requirements and the necessary skill profiles for your team. It might not make sense for an internal app to be created using React when this will split your team into frontenders and backenders with completely disjoint stacks, increased coordinations, and loss of agile job rotation.
- can3p 6y agoSPAs obviously have some positive sides, i.e. state management, but that goes with a price of increasing complexity, especially if server-side rendering is required. In majority of cases, especially when building tools like back offices it's not what you want, you just want to be able to render forms, tables and save them in a convenient way. I've found turbolinks + simulus.js combo to work surprisingly well. Actually, I use the only one stimulus.js controller in majority of cases - one that makes an ajax request and reloads the page (with the help of turbolinks) on success. If page load time is fast enough, the use experience is the same as if you would change the dom with js manually. Of course the requirement is that reloaded page reflects the changes. Other stimulus.js controllers are there for the cases that don't fit into aforementioned pattern. That sounds primitive but can take you a really long way without turning your js into a a monster. In addition to that you don't need to care about the routing, html validation just works, you can wrap existing html components and even inject react apps here and there if you really need to. [EDIT] Forgot to say - this approach does not force any language or architecture on the server-side
- danjac 6y agoI'm really liking turbolinks+stimulus. While I'd probably still reach for Vue for more intricate work there is a lot of mileage you can get out of turbolinks with a small set of stimulus controllers. It's not just for Rails either: the Changelog people use Turbolinks with Elixir/Phoenix [1] for their site, including an audio player (although not with Stimulus), and I used it for a recent side project with Django [2]. [1] https://github.com/thechangelog/changelog.com https://github.com/thechangelog/changelog.com [2] https://demo.localhub.social/ https://demo.localhub.social/
- tarkin2 6y agoIs the issue with SPAs or frameworks like React, Angular, Vue etc?
- timdaub 6y agoI'm kinda surprised that apparently we've moved on from SPAs. I've recently started a new project with preact and an express backend, and I'm in love with the smoothness of the dev experience. Seems like all my problems have been encountered already, there's dependencies and heuristics for everything. I'm just really productive and my app looks great. Surely, all of that wouldn't be the case, had I tried some random new technology...
- mercer 6y agoI'd say this is perhaps an unknown unknown situation. I've had a wonderful time working with Preact and Express, but I wouldn't go back to it after becoming comfortable with the LiveView paradigm.
- davnicwil 6y agoThe article mentions using frameworks with React to get features like full stack data loading. If you're interested in doing this without going all-in on a framework, you should check out React Frontload [0] It's still opinionated, but only on the data loading part! It's just a small library that will slot into any stack. I'm the author. [0] https://github.com/davnicwil/react-frontload https://github.com/davnicwil/react-frontload
- keithb- 6y agoWith all due respect, I don't think the question is "how do we simplify SPAs?"; I think the question is "why do we need to run any app in a browser?" Look at the work associated with the "Next Billion Users" project [1]. Most of our assumptions about how-and-why are merely based on luck-and-whim. We didn't arrive at SPAs through some elaborate Grand Design. I just don't understand what a web application offers that cannot be had with a straight client-server application. Are walled gardens and app stores really tyranny when the garden is limited to a certain company/domain? For example, if my bank offers a client-server app that is walled off from the rest of the Internet, should I consider this stifling? If I was working for this bank and developing their client-server app, should I consider this a step back in my career? [1] https://99percentinvisible.org/episode/the-next-billion-users/ https://99percentinvisible.org/episode/the-next-billion-user...
- snikita 6y agoMy perspective on this question is that its convenience. If the app is something relatively simple, I just want to use it on the browser and not have to go through the steps of installing software that I probably will only use once. Also using a webapp is less dangerous than installing a program in the sense that it can't read your files, install malware, etc. I can relatively safely use an unknown webapp with confidence, but I would only install a program on my actual computer if I trust the author of it.
- a_imho 6y agoThere is nothing wrong with reloading a page. Hackernews is doing it. On the other hand a page not working because webdevs deemed your browser outdated really is problematic.
- darkhorse13 6y agoThis is something I really struggle to understand about the modern web dev mentality. What is exactly so bad about reloading a page? You get visual cues that the browser is doing work, and the page you requested is being downloaded. On the other hand, some SPAs literally provide zero cue when a route has been changed, which is just awful UX to me.
- a_imho 6y agoAgreed. For the most part I don't really care, the target audience of those services is probably people who put up with that kind of bullshit. But there are cases when functionality and compatibility should trump everything e.g. banking software or e-governance.
- CodeWriter23 6y agoOh of course the answer is shiny new framework of the week.
- exabrial 6y agoThere are very few SPAs that are tolerable. Even Google can't make a good one, their admin console for GSuite is terrible and has latency out of this world.
- ryansolid 6y agoIt's worth pointing out MarkoJS it was basically made for this case for eBay's eCommerce solution. It predates the Next.js of the world but offers similar experience except it's MPA first mentality with seamless isomorphic experience and full working partial hydration for years. https://medium.com/@mlrawlings/maybe-you-dont-need-that-spa-f2c659bc7fec https://medium.com/@mlrawlings/maybe-you-dont-need-that-spa-...
- nph5667 6y agoAfter 50 years of software development people still a) are surprised that a framework/approach fails to simplify the software development and b) suggest a new framework/approach.