TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why I no longer use MVC frameworks

116 pointsby jdubrayover 9 years ago

31 comments

Lazareover 9 years ago
&quot;Why I no longer use full MVC frameworks to build sites that have no need for models or controllers.&quot; The better question might be why you ever started?<p>As a bonus, the article discounts React out of hand as one of those &quot;average MVC frameworks&quot; that does too much, then reinvents an incredibly crude version of hand-rolled JS components rendering DOM...the one thing React does.<p>The takeaway from the article, I think, should be:<p>1. If you only need some simple React components being fed by a basic Sinatra or Express server, just do that; it&#x27;ll be ten times easier to develop and maintain. (Edit: Although frankly, the example is so simple I think the author might be better off with a static site generator...)<p>And:<p>2. Do your research before reinventing the wheel badly.
评论 #10741019 未加载
quasseover 9 years ago
This article has kind of occam&#x27;s razored me, because I can&#x27;t actually tell if the author is serious. Do the inline HTML strings common to this style of programming remind anyone else of the good old days of writing PHP code with a bunch of echo statements and concatenated strings to build your pages? It seems to me that the author has sort of managed to move the V from MVC into the C, which I thought we had already discovered was a bad idea.<p>I work in a Flask and Jinja shop, so it&#x27;s not really fair for me to pass judgement one way or another without having actually spent a month using this style. I just can&#x27;t help preferring the Jinja method of templates that are mostly HTML with some templating code mixed in, vs. executable code that happens to be mostly concatenated strings of HTML.
评论 #10740836 未加载
评论 #10741191 未加载
评论 #10741124 未加载
评论 #10740715 未加载
评论 #10741048 未加载
csenseover 9 years ago
Beginning CS students frequently don&#x27;t see the point of object-oriented design, because intro-level class projects are by definition small, simple programs that can be readily comprehended by a single person and written from start to finish in a few hours. For such simple programs, the modest organizational gains from OO programming don&#x27;t seem to justify the extra boilerplate and conceptual complexity.<p>The first time I started using Django, I was really confused and everything seemed incredibly bloated and complicated. Flask seemed much more attractive -- but as soon as I had a Flask project started to grow a moderate number of features, Django looked better and better. For simple projects, the modest gains from using Django&#x27;s features don&#x27;t seem to justify the extra boilerplate and conceptual complexity.<p>I know someone who insists that assembly language is where beginners should start.<p>The common thread: It&#x27;s hard to start working at a high level of abstraction, because understanding the lower level of abstraction first is what gives you the grounding for appreciating exactly what the higher level abstraction does and why you want it to be done.<p>I think the author of this article is at a point in his web dev learning where working at a low level of abstraction is easier. When he gets to larger, more complicated projects, he&#x27;ll probably end up writing his own half-baked home-rolled MVC, or having a project implode under the weight of its own spaghetti architecture. Then he&#x27;ll start to see the advantages of using a framework.<p>Nothing negative is implied by going down this path -- it provides valuable learning experience and an intuition for what the internals of a good framework do without even using the framework (since you&#x27;ve experienced first-hand things that seem like they would be common pain points and how they&#x27;re dealt with at the lower level, you&#x27;ll (often correctly) suspect that standard higher-level tools might have ways to help people deal with those pain points.)
评论 #10741401 未加载
评论 #10743703 未加载
scotty79over 9 years ago
Funny thing is that recent React fully supports (even recommends) exactly this style for his use case. Stateless component can now be just a function.<p><a href="https:&#x2F;&#x2F;facebook.github.io&#x2F;react&#x2F;blog&#x2F;2015&#x2F;10&#x2F;07&#x2F;react-v0.14.html#stateless-functional-components" rel="nofollow">https:&#x2F;&#x2F;facebook.github.io&#x2F;react&#x2F;blog&#x2F;2015&#x2F;10&#x2F;07&#x2F;react-v0.14...</a><p>He could just change few lines and have JSX, React state management, contexts, property type and all that other stuff available if he ever needs it.<p>With his own solution he&#x27;d eventually need to re-implement bits of React.
评论 #10741042 未加载
评论 #10740952 未加载
aneover 9 years ago
The MVC <i>pattern</i> is honestly so simple it or something like it usually emerges from most UI architectures. I would argue that even the increasingly common backend vs. frontend separation is a form of MVC. Of course, MVC isn&#x27;t synonymous with <i>MVC frameworks</i>.<p>When it comes to pure old MVC, I feel that it is a bit like Greenspun&#x27;s tenth rule:<p>&gt; Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.<p>So any UI environment will eventually contain an architecture that more or less embodies the spirit of MVC.<p>And I think MVC is fine <i>within a single environment</i>. That means, the information travelling from the models to the controllers to the views does not contain intermediary where mediums are crossed. A traditional Rails application crosses from databases to a Ruby program to a web browser, and each bit of logic is dependent of the others.<p>What makes the backend&#x2F;frontend separation such a good model is that a front running on a REST API is not inherently dependent on a protocol or a server implementation, and the same applies to the backend. This will work in the post-HTTP world, whenever that comes.<p>Traditional Rails apps assume they are talking to a web browser. This is assumption is no longer tenable.
评论 #10740892 未加载
评论 #10741178 未加载
评论 #10741265 未加载
nostrademonsover 9 years ago
A lot of hate for this guy here that is, IMHO, unjustified. What he did isn&#x27;t insane. It&#x27;s not exactly what I would&#x27;ve done, but then, the meta-lesson from this post is that <i>you don&#x27;t have to do what everyone else is doing</i>.<p>The comment here about the point of MVC frameworks being for communication is true. However, this guy isn&#x27;t working on a frontend dev team. He is a consultant doing primarily server-side development, building a landing page for his business. The code he wrote in this entry probably took him all of about 15 minutes. Meanwhile, many of the comments here say that he should&#x27;ve used Jade, or Angular, or Knockout, or Flask, or Jinja. How long would it take him to get up-to-speed on that? That&#x27;s time he doesn&#x27;t get back, which won&#x27;t be spent <i>working on the things that make money for him</i>.<p>I wrote a similar build script to try out different landing page concepts - in about an hour, I&#x27;d wired up Babel, PreCSS, and Marky-Markdown so I could write all my marketing text &amp; tutorials in Markdown, my CSS in CSSNext, and have a common page layout for everything. It&#x27;s a lot cheaper than the MVP generators on the net, it&#x27;s easier to change and gives me more flexibility than Bootstrap, and it&#x27;s a lot less code than writing everything from scratch in HTML. No, it bears no resemblance to any living framework, and no, it&#x27;s probably not intelligible or sane to any other frontend developer. However, it doesn&#x27;t have to be. If I get to the point where I&#x27;m hiring frontend devs, they&#x27;ll be rewriting everything anyway in the framework of <i>their</i> choice, so my opinion doesn&#x27;t matter anyways, and in the meantime, the landing page and product description helped me discover that I didn&#x27;t need a frontend component at all, at least for an initial version.<p>Optimize for the problem you have, not for the problem other people have. And when other people come up with a solution that&#x27;s different from what you would&#x27;ve done, try to see how their <i>problem</i> differs rather than saying they&#x27;re stupid.
评论 #10741238 未加载
评论 #10741440 未加载
评论 #10741203 未加载
dimglover 9 years ago
This post makes me kind of sad. There&#x27;s a whole slew of developers who believe &quot;X is bad so I did Y&quot; and are in turn alienating themselves from design patterns and frameworks needlessly. I think posts like these breed arrogance and it should be less about &quot;why not to&quot; and more about &quot;why to&quot;.
gotchangeover 9 years ago
He lost me at the moment he showed me the all-encompassing, all-powerful, all-knowing spaghetti wrapper function in JS.<p>If he really wanted to build a nice looking web template solely with front end technologies, he could build it with Jade for the HTML part, Sass for the CSS, and JS&#x2F;TS&#x2F;Babel for the behavior part and structure the template in a modular and component-based fashion for reusability, maintainability, scalability, customizability, and above all sanity.<p>If you&#x27;re looking to build a web app instead, just pick any framework you feel comfortable and your future self will thank you for that decision as the web gets bigger and bigger, you&#x27;d still can keep it together and deliver good results consistently.
评论 #10741607 未加载
archimedespiover 9 years ago
I feel like the author is talking about how bad MVC is without fully understanding what MVC <i>is</i>.
评论 #10740879 未加载
评论 #10743060 未加载
gherkin0over 9 years ago
&gt; I first saw a “web app” when Steve Jobs introduced WebObjects at the Moscone Center in 1995, which he claimed was the first dynamic HTML app server to go to market (followed by a few others like Kiva, WebLogic…). It was quite something to see for the first time a Web page which content was dynamically constructed from the result of a query to a database. If I remember correctly it was a list of cars (Chrysler may have been a client of NeXT).<p>Kind of an aside, but I think this might be that presentation:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=goNXogpwvAk" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=goNXogpwvAk</a>
评论 #10741068 未加载
ajbetteridgeover 9 years ago
Ok, then add in some routing for your different pages, and tidy it up a bit, make it all callable from a URL mapping, and low and behold, you&#x27;ve made your own MVC framework on top of express.js. Congratulations.
icebrainingover 9 years ago
<i>A natural extension of that pattern would be to create standard Web apps&#x2F;Website components (wrapper function) such that you could replace the underlying “theme” as needed, as the interface would remain the same.</i><p>Yes. That&#x27;s called separating the Controller from the View. And pieces of HTML with dynamic parameters are just templates (like Mustache and such).<p>I think you just wrote your own (M?)VC framework, with your own templating language.
efarefover 9 years ago
I think he just reinvented Perl-CGI in Node.js. I guess the inexorable march of reimplementing everything in JavaScript continues.
smadgeover 9 years ago
* Why I invented my own MVC framework
overgardover 9 years ago
I&#x27;ve never understood why MVC is so popular. Any other form of application development, you just look at what your application needs to do and design for that. You might use a pattern, you might not, it depends. But for some reason in web development this is THE ONE TRUE WAY, despite the fact that it&#x27;s a pretty awkward pattern for a lot of problems.<p>The thing that makes it more baffling is that HTTP and HTML are so simple on their own. Almost all these abstractions being built on top of them are vastly harder to understand then the things they attempt to abstract away in the first place.
jbob2000over 9 years ago
Wow! A single developer working on small websites doesn&#x27;t need MVC? What a revelation! I bet he doesn&#x27;t have any pesky problems, such as; working in large teams, long term support, developer turn over, documentation, changing requirements, deadlines, scaling, etc. etc. Oh, but the rendered HTML looks nice!<p>MVC frameworks took off because they allowed more than one person to reason about an application. I can hire an Angular developer and expect them to have a fair understanding of my application on day 1. If I&#x27;m new to a React shop, I can read tons of documentation online, without pestering my new coworkers. My Product Management team likes to change stuff on the fly, so I can use Knockout to build small, independent components which I can piece together like lego.<p>I don&#x27;t know why this post irked me so much, but it did.
评论 #10740866 未加载
评论 #10740883 未加载
评论 #10740938 未加载
评论 #10741889 未加载
mplewisover 9 years ago
The author doesn&#x27;t need MVC, he needs a templating engine.
jdubrayover 9 years ago
Thanks guys, I was expecting this kind of answers. The part that bothers me is: why there is no &quot;standard&quot; wrapper functions (sliders, contact form,...) that you can &quot;theme&quot; with various snippets of HTML&#x2F;CSS. I would expect it would be a lot more practical to deliver a template as a set of wrapper functions, rather than the raw HTML&#x2F;CSS as it is always the case.
评论 #10741077 未加载
评论 #10740778 未加载
评论 #10740926 未加载
评论 #10742453 未加载
评论 #10740759 未加载
评论 #10741387 未加载
评论 #10740789 未加载
评论 #10741155 未加载
mschuster91over 9 years ago
The problem with all the &quot;fancy&quot; JS stuff is: people these days totally disable their JS because people have fucked their users over and over again with endless heaps of tracking, ads and other nasties. Or their connection has a too high RTT (ohai EDGE!) for downloading 100+ assets in a timely matter.<p>I have yet to see a JS&#x2F;* framework that allows me as a full-stack developer to deliver the same content experience (sans interactiveness of course) to clients with or without JS, without having to duplicate templating logic or switch to NodeJS which requires a) a host supporting it, which many &quot;mainstream hosters&quot; don&#x27;t and b) having to code a server in javascript&#x27;s callback&#x2F;promise hell.
评论 #10741547 未加载
评论 #10741646 未加载
syjerover 9 years ago
This style is quite prone to escaping&#x2F;sanitization issues. I would have at least used a template engine instead of concatenating strings.
chowesover 9 years ago
Interesting article and approach, but I don&#x27;t think this is really an argument against using something like Angular or React (which alone isn&#x27;t even a true &quot;MVC&quot;). It&#x27;s more of &quot;for my particular use case, this worked well&quot;... Angular and React most definitely have their use.<p>(In fact, you could probably leverage React&#x27;s server side rendering and JSX to clean up that long chain of function calls in your page function.)
spo81rtyover 9 years ago
This is why we use knockout instead of angular. Much simpler to do basic temptation without forcing some mvc framework client side.
评论 #10741645 未加载
bikamonkiover 9 years ago
Suddenly the author realizes his web app needs to handle a click event which in turn interacts with data on a database...boom it hits him: this would be simpler with a framework, maybe an MVC framework?
cwisecarverover 9 years ago
This is a static site, at least from the examples given. Using MVC to build it is a way to go but it seems like his way is equally pointless.<p>Let&#x27;s take some strings and hardcode them into JS and make the user&#x27;s browser render this page dynamically every time it&#x27;s loaded instead of WRITING SOME STATIC HTML... It&#x27;s all well and good to try a new way of doing things but writing a blog post decrying MVC frameworks for a static site that you&#x27;re building dynamically with javascript is silly.
rileymat1over 9 years ago
Is the css in the screen shot &quot;good&quot;.<p>It seems to really unnecessarily break any sort of distinction between presentation and content. For example what is the practical reason for using class &quot;white-text&quot; on a text span instead of an inline style?
gitaarikover 9 years ago
As always: use the right tool for the job.<p>React is not an MVC framework also, and it could actually make things much easier for this particular job.<p>If you don&#x27;t need MVC or frameworks then don&#x27;t use them, you&#x27;ll be happy they are available when you need them ;).
hcarvalhoalvesover 9 years ago
TL;DR Web developer rediscovering function composition, data as code, etc.
escherizeover 9 years ago
The actual title was &quot;Why I no longer use MVC Frameworks?&quot; and that was enough to make me stop.<p>I can&#x27;t stand when people end declarative sentences with question marks. Never again.
Walkmanover 9 years ago
&gt; a collection of interchangeable themes with standard wrapper functions&#x2F;interfaces.<p>That collection is called a framework...
backtoyoujimover 9 years ago
Did anyone else use zope? Add an object db to this and it strongly reminds me of zope.
seereadhackover 9 years ago
Woof.