3 ms·
> Cookies are preferred by developers who fear JavaScript precisely because because they can be written and transmitted without need for JavaScript. You seem t
by goto11 7y ago
> Cookies are preferred by developers who fear JavaScript precisely because because they can be written and transmitted without need for JavaScript.
You seem to believe that developers should always chose the most complex and intricate solution possible, and the only reason someone would chose a simpler solution would be due to incompetence or ignorance of the more complex solution.
This is completely opposite of all good engineering practice. Complexity is not a goal, it is a liability. You want to have the minimum amount of complexity which solves the problem.
- austincheney 7y agoI have defined complexity for you several times. Complexity is not hard just as simplicity is not easy. Just because some framework running on the server hides the challenges from you does not mean the complexity is lower. The complexity is dictated by the business requirements (the problem state).
- ComputerGuru 7y agoYou’re not getting it. You don’t need any intermediary framework or library to store state in cookies from the backend. You can do it without executing anything on the client. With LS, you are forced architecturally to execute code on the backend and in the browser just to accomplish the same thing. They’re incomparable.
- goto11 7y agoConsider when you are visiting a page where you have been before, and you have received some identifier token. Using cookies, the browser automatically sends the identifier token along with the initial request, and the server can serve the initial response based on your identity. With localStorage, the browser initially send an anonymous request to the server, the server then have to return some bootstrap JavaScript which reads the identity token from localStorage and then passes it to the server in the next request, and only then the server can respond based on your identity. By any reasonable definition, the second approach is more complex, not to mention slower and more fragile.