3 ms·
Ask HN: Should I move computation to the front end? Why not?
I've been in doubt about this. This project is calculating curves for cement maturity.
My backend is smallish and the frontend is a VueJS project a few times bigger.
Which pattern makes more sense: calculate on the backend, or pull the data to the frontend and make my calculations in JS?
Since there are several ways to transform this data, I've been doing most of the calculations on the frontend...
- CuriouslyC 9y agoThere are two big determining factors: 1.) Is your analysis fixed, or are you interested in expanding your analysis over time? 2.) Is your analysis method secret sauce? Additionally, your scalability needs are also a factor. If you plan on expanding or significantly modifying your analysis over time, the breadth of analytical tools available on the back-end is much larger. Working on the front-end is going to constrain your access to analytic libraries. You could of course do some analysis on the front end and some on the back-end but this is a hassle and why bother if you don't need to. If your analysis is secret sauce, and you are worried about someone ripping off your site, you definitely want it on the back-end. Scalability wise, moving computation to the front end is almost always a good idea. You'd be surprised at the numbers you can pull with well written javascript, and you can do even better if you can figure out a way to do your calculations using GLSL. In my opinion you're better off prototyping and getting a product started with calculations on the back-end then migrating work to the front-end as needed in most cases.
- swah 9y agoThanks, I agree. Its simple calculation here. And with frontend code I can do stuff like http://worrydream.com/Tangle http://worrydream.com/Tangle (interactive, re-rendering apps).
- davelnewton 9y agoDepends on your actual needs; there's no general answer.