Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
It depends on the task but generally I would agree. Code on the backend is running on (hopefully) good hardware that's under your control; code on the frontend is running under whatever random conditions and is ultimately controlled by the user. "Don't trust the client" is a pretty important security maxim, and any code you run on the frontend is code you're trusting them with. Even in a corporate environment, you're not guaranteed against bad actors and you're definitely not guaranteed against stupidity. Is your frontend code going to keep working correctly if they run it on their crappy old iPad or is it going to AJAX POST a bunch of garbage into your database? In a server environment, if a task crashes you can set up automated alerts and retries. What do you do in the client environment if they close the window? Is there anything in the data that's supposed to be hands-off but that a client might be tempted to manually tweak? Any secrets they could lift out of the source?
Yea, then it does make sense to just have that same code in the backend and the request go to it. I mean, it depends on the specific problem, and what you mean by "automation."