Hacker News new | ask | show | jobs
by Jemaclus 4835 days ago
Serious question. I haven't figured out the need for MVC in JS. I'm primarily a PHP programmer, and I use a custom MVC on the back-end. I don't see the point in having two MVC frameworks (one in front, one in back). At the end of the day, the front-end has to talk to the server to get data, doesn't it? What's the difference?
1 comments

You may not, necessarily, but Javascript Frameworks 1) aren't necessarily exactly MVC anyway and 2) if you're using the MVC in both frameworks, that's sort of the wrong way to do it.

Using Django as the example (which has its own stack behind it) and Backbone as the front-end, the only part of Django I really end up using, from an end-user's perspective, is the ORM and JSON serializers.

The way that backbone works is that your 'models' don't read to or write using the database, they read and write using APIs that you define with your normal framework. So, where in Django, you might execute a .save() on a model to commit it to the database, that same .save() operation in backbone will execute a PUT or PATCH request to your API endpoint to which its bound.