News for hackers. Stuff that matters.

Ask HN: Alternatives to MVC

I'd like to branch out from MVC for my next webapp. What battle-tested alternatives are others using?

Here's a post from 2014, but there aren't any example code bases. https://blog.ircmaxell.com/2014/11/alternatives-to-mvc.html

( 15 comments | 25 points | on HN )
Re:Ask HN: Alternatives to MVC by davidjnelson on Tuesday August 13, 2019 @08:43PM (#20691719)
You could look into functional reactive programming as in rxjs/rxjava etc (https://medium.com/netflix-techblog/reactive-programming-in-...) or command query responsibility segregation (https://microservices.io/patterns/data/cqrs.html).
Re:Ask HN: Alternatives to MVC by deepaksurti on Wednesday August 14, 2019 @02:06AM (#20693076)
If you haven't, you can look at MVP [1] and [2].

In MVP, by rotating (or twisting) the MVC triad, one can produce an "Observer" based framework that is easy to use and more flexible.

Some googling and you may find more literature on the same including comparisons with MVVP.

[1] http://www.object-arts.com/downloads/papers/TwistingTheTriad...

[2] http://carfield.com.hk/document/software+design/MVP.pdf

Re:Ask HN: Alternatives to MVC by xaedes on Wednesday August 14, 2019 @03:42AM (#20693443)
Immediate mode gui - short imgui. For example the library "Dear imgui".

Basically you write imperative paint functions like this example:

  ImGui::Text("Hello, world %d", 123);
  if (ImGui::Button("Save"))
  {
      // do stuff
  }
  ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
  ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
Re:Ask HN: Alternatives to MVC by quickthrower2 on Tuesday August 13, 2019 @07:04PM (#20691147)
It depends on why. Is it for learning purposes, or some other reason? Old school (but battle tested, not great patterns for learning though):

* One file (script) per route e.g. classic vanilla PHP.

* ASP.NET web forms - tries to make the web like a drag and drop windows forms application. Very nice for basic websites but doesn't scale to well if there are a lot of nested controls. Has this horrible concept called 'viewstate' where you send state about your controls in a hidden form field and post it back. This makes server side "on change" events possible for client side actions. It's horrible because Viewstate size grows quickly for complex forms, and it doesn't feel very web-like or Restful.

If you want to create a SPA, then React/Redux and Elm offer interesting patterns, but your server would still need to send data, and I can't think of anything better than an MC (no V!) type of framework for this.

Re:Ask HN: Alternatives to MVC by sansnomme on Tuesday August 13, 2019 @08:43PM (#20691718)
A ton of web frameworks are trying to reinvent WebForms using WebSockets e.g. Phoenix LiveView, the new Blazor components in ASP.NET CORE that uses WebAssembly alongside WebSockets to create a unified stack. Unfortunately the whole web builder concept is no longer popular other than for generic sites, those areas are dominated by companies like Webflow, Weebly, SquareSpace, Pinegrow etc.
Re:Ask HN: Alternatives to MVC by tabtab on Tuesday August 13, 2019 @07:16PM (#20691212)
What is a "Restful feel"? I didn't think REST was a UI pattern or style.
Re:Ask HN: Alternatives to MVC by tim333 on Tuesday August 13, 2019 @07:46PM (#20691372)
from https://www.codecademy.com/articles/what-is-rest

>SEPARATION OF CLIENT AND SERVER

>In the REST architectural style, the implementation of the client and the implementation of the server can be done independently without each knowing about the other. This means that the code on the client side can be changed at any time without affecting the operation of the server, and the code on the server side can be changed without affecting the operation of the client.

which is kind of different from having server side "on change" events

Re:Ask HN: Alternatives to MVC by tabtab on Wednesday August 14, 2019 @11:01AM (#20696238)
Still this describes an "under the hood" implementation technique. It doesn't describe a UI method/technique/style in terms of what the end user sees. The end user's perspective is the key to my question. If that wasn't clear, I apologize.
Re:Ask HN: Alternatives to MVC by muzani on Wednesday August 14, 2019 @01:34AM (#20692936)
Stateless is what I imagine REST to feel like. You do everything with just an API key or token. There's no need to keep trading credentials with the server.
Re:Ask HN: Alternatives to MVC by tabtab on Tuesday August 13, 2019 @07:14PM (#20691205)
Microsoft has something called Razor Pages that is sort of a hybrid between MVC and Web Forms. It may be a better fit for smaller projects, but is still fairly new.

Are you mostly doing CRUD (data-centric), or a more document-centric (CMS-like)?

Re:Ask HN: Alternatives to MVC by sebscholl on Tuesday August 13, 2019 @09:23PM (#20691920)
I'm ready this book right now, and it's great. https://www.amazon.com/Design-Patterns-Elements-Reusable-Obj...
Re:Ask HN: Alternatives to MVC by arh68 on Wednesday August 14, 2019 @06:28PM (#20700697)
One alternative: The Elm Architecture [0] is more like Model-View-Update than MVC. Examples aplenty [1].

[0] https://guide.elm-lang.org/architecture/

[1] https://elm-lang.org/examples

Re:Ask HN: Alternatives to MVC by throwaway5d097 on Wednesday August 14, 2019 @02:42AM (#20693224)
"View oriented" like https://www.liftweb.net/
Re:Ask HN: Alternatives to MVC by fgonzag on Wednesday August 14, 2019 @03:17AM (#20693347)
I'm quite fond of the Ports and Adapters / Hexagonal architecture.
Re:Ask HN: Alternatives to MVC by dragonwriter on Wednesday August 14, 2019 @08:17AM (#20694696)
Well, MVVM is a battle tested alternative to MVC.