blog.codecarrot.net
How Developing SPA Influenced Me & My Code
Excerpt
Of course, it wasn’t always pretty and shiny. In the past, I was skeptical about SPAs. The argument of productivity in rails appealed to me. I must admit, the new way of doing things and learning a javascript framework has been a steep learning curve. You won’t be moving as fast as with rails in the beginning. JavaScript can feel less familiar than ruby and testing can be awkward: they are different tools, created for different environments and purposes. The change of paradigm also brings a whole suite of new challenges. For example, the lifecycle of a page is longer: you can expect the user to have an application open in a tab for hours! That’s why you need to be extra careful about memory management by removing references and bindings to unused objects, so that JavaScript’s GC can sweep them. Memory leaks can cause deterioration of responsiveness or even crash the browser tab. The back button is a common trouble spot in SPAs. You need to make sure it works as expected (check if the framework can handle it for you). Moreover, in most cases, refreshing the page should bring up the same view (this applies to links shared with others too).
Related Pain Points
Memory Leaks in JavaScript Applications
7Memory leaks are nearly inevitable in JavaScript development without conscious effort to prevent them. Multiple common patterns inadvertently cause memory to accumulate, making leak prevention difficult and error-prone.
Client-Side Routing Complexity
6Managing browser history, back button behavior, and URL transitions between pages creates messy routing logic. Routing complexities introduce loading states for every route and require specialized libraries to manage navigation efficiently.
Steep learning curve transitioning from server-side to SPA frameworks
6Developers familiar with Rails and server-side frameworks experience significant productivity loss when adopting JavaScript SPA frameworks. The paradigm shift requires learning new tools, patterns, and mental models, resulting in slower initial development velocity compared to traditional server-side approaches.
Difficulty testing JavaScript versus Ruby due to environmental differences
5JavaScript and Ruby were created for different environments and purposes, making testing practices less intuitive for developers transitioning from Ruby. This creates awkward testing workflows and reduces development comfort.