Introducing Maria: The Real MVC

In December 2011, James Ladd (@jamesladd) and I were chatting about JavaScript, its dynamic nature, and program design. During the discussion, James asked detailed questions and I needed to illustrate a few points about MVC. I created a GitHub repository with code we could discuss.

Fast forward 1.5 years, through many more conversations, much more research, testing, and refining, and the Maria framework for building MVC application in JavaScript is 1.0.0!

Over the past several years, the JavaScript community has been inundated with MV* frameworks. In the wake of the one-page app explosion, many JavaScript developers searched for ways to structure their larger browser applications more manageably. You can see in the source code of the frameworks that the authors were struggling away on their own attempting to solve the same problems. I’m willing to bet they went through a similar process I did trying to find discussions tailored to JavaScript about this famous MVC that was supposed to solve all their problems and more.

Why no one else chose to write an true MVC framework, I cannot figure. There is no doubt that the early Smalltalk MVC architecture inspired today’s MV* frameworks for JavaScript. My take on it was straight forward. The MVC architecture has withstood a 30 year test. It has passed that brutal test. It is still used for application programming. It is very useful for browser programming. Why not take this time-tested architecture and make a JavaScript framework true to the MVC that is implemented in Squeak Smalltalk and written about in Design Patterns? My experience with Maria has shown it was a good choice.

How true is Maria to the real MVC? Somewhere along the way, I downloaded the Smalltalk Squeak implementation, found the model, view, and controller classes, and started porting lines of Smalltalk to JavaScript. In places, the two really are that close. And it wasn’t like pounding a square peg in a round hole. It was a natural fit. As my detailed understanding of the Smalltalk implementation improved, more of my “creative” lines of code in the growing Maria were deleted and in their place appeared more ported lines from Smalltalk. Every single time it was an improvement. The Squeak classes have been around a long time. They are some of the best lines of code in all the world’s aggregate of software. They are a solid foundation on top of which to build an important application.

So if you want to build your applications on a solid foundation, I recommend you check out the Maria framework.

Comments

Have something to write? Comment on this article.

Jonah June 19, 2013

Hi Peter,

I just found Maria and really love the idea behind it. As I’ve learned angular and other MV* frameworks, I often myself struggling to map their concepts onto the original Smalltalk MVC pattern and wondering what motivated their deviations from it. Their documentation almost never addresses the reasons for deviating, and I always wonder if I am missing something.

I would love to hear your specific thoughts on Maria vs angular, the pros and cons you see in each, and if you believe there are defensible reasons for angular’s deviation from the original MVC.

Keep up the terrific work!

Jonah

Peter Michaux June 19, 2013

Hi Jonah,

I’m not really familiar with AngularJS in particular. In general, your questions about deviating from standard MVC are exactly the same as mine. For the MV* frameworks that I have looked into, I haven’t understood why they do not start with standard MVC as the foundation and then extend it in new directions. All the parts of MVC are useful. The model-view relationship via the observer pattern is common to all the MV* frameworks. Composite views are very useful and any MV* framework without composite views would need to be extended to have composite views for any work that I do. Controllers seem to be the part browser developers can and are willing to do without. I had done without them for a long time but with Maria and controllers, I’m finding the readability improvements to be justification enough for keeping controllers even if the strategy pattern aspect of controllers is not specifically used.

There are AngularJS vs Maria head-to-head talks later this month in Melbourne, Australia. I’m looking forward to videos being available and possibly some insights into the issues you mention.

I’m glad to read you are enjoying the Maria concepts. Please keep in touch and use the GitHub issue tracker for any questions or discussions you have regarding Maria and/or its use.

Jonah June 19, 2013

Peter,

Thanks for the reply. I will certainly watch the videos of those talks when they’re posted. Hopefully James Ladd will chime in here as well.

Jonah

Have something to write? Comment on this article.