<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jan Friedensreich on Medium]]></title>
        <description><![CDATA[Stories by Jan Friedensreich on Medium]]></description>
        <link>https://medium.com/@jfriedensreich?source=rss-20a87af2b170------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SLPfJqYs6Hm-TnXW.jpeg</url>
            <title>Stories by Jan Friedensreich on Medium</title>
            <link>https://medium.com/@jfriedensreich?source=rss-20a87af2b170------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:18:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jfriedensreich/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Javascript HMR considered harmful, change my mind]]></title>
            <link>https://medium.com/hackernoon/javascript-hmr-considered-harmful-change-my-mind-20823320bdf7?source=rss-20a87af2b170------2</link>
            <guid isPermaLink="false">https://medium.com/p/20823320bdf7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[hmr]]></category>
            <dc:creator><![CDATA[Jan Friedensreich]]></dc:creator>
            <pubDate>Tue, 09 Jun 2020 11:59:59 GMT</pubDate>
            <atom:updated>2020-06-09T11:59:59.982Z</atom:updated>
            <content:encoded><![CDATA[<p>Whenever i start a new web-app from a template or use some new development tool, one of the first things I do is disable or remove everything connected to “Hot Module Replacement”. I never wrote down every reason in one place before, but now that I am preparing to release a tool of my own, I need to document the decision appropriately. At the same time this article is a request to challenge my points in case i did not think of all use cases or reasons for HMR, so please do comment!</p><p>It’s weird that I hate js HMR so much because I was an Erlang developer before and its “hot code reloading” is something every Erlang developer likes to mention in discussions. However it is a feature for high reliability production applications that have internal state. It is not a developer experience tool or something you would use unless you really have to, it is a tool in your tool belt that makes something possible that is very hard or impossible otherwise.</p><p>This brings me to my first point: because js HMR is for developer experience, not for production use, it means having quite different runtime and loading behaviour of production and development environments. After days of debugging-sessions that had to go to live environments eventually, everything that makes the environments different makes me uncomfortable. It does not even necessarily mean that bugs slip from dev to prod environments because test/staging are usually setup as close to production as possible, but it is a level of disconnect to the production software that just makes me feel uncertain how exactly the loading of the complete application feels, especially uncached reload and initial application launch.</p><p>The second point is loading performance. One reason people use HMR is the removal of reload waiting times, however i question you should force end users to use an application that loads too slow on localhost to refresh the page on every code change. It sounds like an absurd preference of developer experience over end-user experience, because it will not force developers to fix bloat and load timing. The counter argument of minification, bundling and other optimisations only done in production do not really hold true. The effect of network outweighs other effects like parsing and even if you have a bundle size of 800KB the request will be possible in 20ms on localhost and probably take 50ms+ on the fully minified and properly bundled/tree-shaken production version. And if it is just the physical activity of hitting refresh in the browser, it’s quite simple to auto-reload the application without any of the complexities of HMR.</p><p>My third point is local state handling. I am daily annoyed by web applications losing state when my browser updates or some other event forces tabs to refresh. The two main reasons for this are redirect behaviour on login/logout scenarios and not exposing hierarchical navigation state as url path or as an anchor hash (eg. using “/settings” instead of “/settings/security/two-way-auth” or “/settings/#two-way-auth”)</p><p>In addition to broken reloads, not exposing these types of state in the URL prevent sharing URLs and navigating with browser buttons, there is no excuse for this in 2020. Not having HMR makes these kinds of issues immediately obvious and forces developers to fix them before even going to QA. What remains is more complex client side state that does not belong in the URL and there are two answers here: 1. Having to manually recreate this kind of state is a great motivator to write integration tests for cypress or similar that take care of this, it is much more fun when it saves you doing the same task oll over again while you implement a feature vs. just for quality assurance after the feature is finished. 2. For situations where much faster iterations are needed, a simple state dump to localstorage solves the same problem as HMR without any of the added downsides. Most state handling libraries have a tutorial how to do this in 10 lines of code and if it takes much more work you should probably reconsider your choice of state handling.</p><p>The last point is the HMR complexity itself and lack of easy reasoning about the local dev environment. HMR implementations usually rely on a mixture of special bundler in memory build setups, websocket communication with a module hash + chunking protocol, application side HMR checks and replace/destroy handling and depending on the plugins and state libraries some state preserving magic. Especially when fixing actual bugs vs. working on styles or layout often the system breaks at an exception or syntax error and you need to refresh the page anyways. Most people dislike the idea of having to touch a working webpack setup, and I am sure HMR does not reduce this feeling. More than once did i see suboptimal webpack settings that were avoided changing because of the fragile nature and non linear complexity when dipping into the details of webpack to fix things. I would assume most bigger projects even have complete codepaths or file types that do not work at all in HMR and no one wanted to fix this.</p><p>Unfortunately i see a trend among young javascript projects to feel pressured(?) to do HMR out of the box and as a default, i assume because it can have a magic WOW demo effect. Even more worrisome is the incompleteness of opting out that most of these projects have, i saw at least two projects that would even inject code to open the web-socket connection when HMR was “disabled”.</p><p>I rest my case and this is where your opinion is appreciated: Do you disagree? Did i forget something? Most importantly: would you not consider using a framework/tool if it decidedly would not support HMR, but tried to optimise the reload experience? Really helpful would also be if you could share the acceptable/experienced times that you have in your real world projects from saving a file in the editor to seeing the change in the browser tab or if you don’t care about this that much. Lastly I am interested if any of you add little hints to your web app that allow you to see more easily if a subtle change is loaded yet (eg. build-counters in a corner, flashing of the page on update, etc.)</p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20823320bdf7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/javascript-hmr-considered-harmful-change-my-mind-20823320bdf7">Javascript HMR considered harmful, change my mind</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[REST is just not for RPC]]></title>
            <link>https://medium.com/hackernoon/rest-is-just-not-for-rpc-d5d9507ff99a?source=rss-20a87af2b170------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5d9507ff99a</guid>
            <category><![CDATA[rpc]]></category>
            <category><![CDATA[rest-is-just-not-for-rpc]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[rest]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Jan Friedensreich]]></dc:creator>
            <pubDate>Tue, 19 Dec 2017 01:05:15 GMT</pubDate>
            <atom:updated>2019-05-25T05:48:11.291Z</atom:updated>
            <content:encoded><![CDATA[<p>I think that RPC protocols and <a href="https://hackernoon.com/tagged/rest">REST</a> protocols live on very different abstraction levels and should not be compared like alternatives. This is maybe the main problem I have with the current wave of REST criticism. If we just accept that no one will be happy to force an RPC kind of <a href="https://hackernoon.com/tagged/api">API</a> through REST, a domain specific API that was made for resource synchronization, the discussion could be more productive.</p><p>As programming languages use functions and RPC is a way to use those through a network of some kind, of course RPC APIs are the most generic and transparent way to achieve this. We now have amazing technology like gRPC, websockets, Cap’nProto, ProtocolBuffers, MessagePack and similar for this and HTTP is maybe a good fallback transport layer for legacy support but in principle these don’t need anything from the HTTP layer but are far better to be put through pure websockets or pure UDP/TCP.</p><p>Best is to look at two extremes and then at how real world mixed use cases can be modeled best:<br>- Pure RPC APIs:<br> everything that fits to things like message passing, very dynamic and multi dimensional queries, requesting view models, triggering events, remote algorithm execution, sending mutations. These things are just best implemented using the RPC technology I mention above. These concepts are often not even connected to the concept of a ‘Resource’, so it will run into all the REST problems we read about.</p><p>- Pure Resource APIs:<br> Any protocol that should synchronize or publish consistent state and state changes on resources and needs access to the full resource for consistency while abstracting implementation details as much as possible, is best modeled in REST. Pay attention to how relatively narrow this application is compared to the description above. Still, this applies to A LOT of systems, as long as the concept of a resource makes sense in the logic of that system:<br> For the logic of REST I find the following definition most practical: A resource is an entity that makes sense to be theoretically exposed as a unix file and whose state at a certain time makes sense to be validated by a simple hash function. This analogy is also interesting because it mirrors the development of plan9 (everything is really a file/everything should have a REST interface) being transformed into a more real world linux world (there are many file like APIs, but also d-bus etc. / there will be many REST APIs where it makes sense but also many RPC protocols)<br> Notice how every REST API can relatively easily be modelled in a RPC style API (though probably reinventing the weel) but not the other way around.<br> There are also two important technologies to have in mind when thinking about the real application of REST APIs, even if you use completely different technology in reality, but the purity of those technology implementations and the fact there are real Resources to check your thoughts against is an extreme help:<br> couchDB and webDAV<br> — does this api make in theory sense to be exposed as a webDAV server? How ridiculous would this api look when mounted in the file explorer? The more ridiculous the interaction with this API would be the less likely REST is a good model for your api. The more nerdy/nice use cases you find that would make such an interface awesome, the better it is suited for REST.<br> — if you know couchDB better than webDAV this works the same, how much would it make sense to model this API as a couchdb database with documents and revisions for versions of documents?</p><p>Real world APIs have mostly always both aspects. The key is finding the natural main idea of the API and indentifying and solving the other side of the coin as edge cases.<br>- If your API is mainly RPC style but you have a stronger need to act on resources, this is where graphQL comes in, this is also why I think graphQL makes most sense via web socket and I don’t think of it as an alternative to REST but as a tool belt to empower RPC APIs with stronger data needs.<br>- If your API is huge and can be split into domains that fit best to both worlds it makes sometimes sense to have two cleanly modeled separate APIs. This seems strange at first but this is exactly what happens if Web apps have a REST API but also use websockets for certain features.<br>- If your API is mainly a perfect REST fit but has some RPC aspects then of course its still OK to model RPCs as REST but be clear what those endpoints are and be ready to replace them if you run into the known problems, just knowing consciously about this already helps a lot.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5d9507ff99a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/rest-is-just-not-for-rpc-d5d9507ff99a">REST is just not for RPC</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>