
Ask HN: Should I move computation to the front end? Why not? - swah
I&#x27;ve been in doubt about this. This project is calculating curves for cement maturity.<p>My backend is smallish and the frontend is a VueJS project a few times bigger.<p>Which pattern makes more sense: calculate on the backend, or pull the data to the frontend and make my calculations in JS?<p>Since there are several ways to transform this data, I&#x27;ve been doing most of the calculations on the frontend...
======
CuriouslyC
There 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
Thanks, 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).

~~~
itamarst
You can get reactive calculation with a backend using something like
[http://intercoolerjs.org/](http://intercoolerjs.org/).

~~~
swah
Sure, but there will be a huge delay, so the "interactive" effect is kinda
lost.

------
davelnewton
Depends on your actual needs; there's no general answer.

