When comparing Mithril vs Marko, the Slant community recommends Mithril for most people. In the question“What are the best client-side JavaScript MV* frameworks?” Mithril is ranked 6th while Marko is ranked 17th. The most important reason people chose Mithril is:
Most other frameworks either offer a huge API to deal with model and view synchronization, or defer to other libraries & plugins to cater for relatively simple use cases. Mithril's API is tiny but complete. The natural reaction is to assume something is missing, but as you build you realise you incredibly fast, powerful and rich applications can be built using nothing but Mithril.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Small, easy to learn API
Most other frameworks either offer a huge API to deal with model and view synchronization, or defer to other libraries & plugins to cater for relatively simple use cases. Mithril's API is tiny but complete. The natural reaction is to assume something is missing, but as you build you realise you incredibly fast, powerful and rich applications can be built using nothing but Mithril.
Pro Fast rendering
Mithril's loading times are very fast. This is because it's templates are compiled first and then served to the browser and because it uses a virtual DOM. The virtual DOM is a virtual tree containing all the nodes of the real DOM, every time anything changes in the virtual DOM, Mithril does not re-render the entire (real) DOM, instead it just searches and applies the differences.
Pro No need to learn another syntax to write views
Most MVC frameworks use HTML templates to render their views. They are good and useful because they are easy to read and understand. But they add more complication to an app because it's practically a new language and syntax that needs to be learned.
Mithril argues that separating markup from logic is just a separation of technologies and not concerns, so you can write Mithril views in JavaScript. Writing them in JavaScript also makes it easier to debug them (HTML templates can't be debugged).
Pro Familiar to people used to MVC
Doesn't lock you into any complicated conventions or structures, only one function is required to create either a Controller or a View. You're free to implement your architecture exactly as you want, so you can focus on the purpose of MVC, making connections between computer data and stuff in the end user's head.
Pro Small size
Weights just 8Kb gzipped and has no dependencies. A reactive stream module can be added for one extra Kb.
Pro Great documentation
Mithril has a large and expansive documentation despite it's relatively small API. Mithril's GitHub repo has more documentation than actual source code. None of that documentation is auto-generated
Pro Allows a smooth transition from other UI frameworks
One thing you need to start using Mithril is just a DOM node. With Mithril a developer is able to introduce the library step by step.
Pro Allows you to choose which JavaScript libraries to integrate in your project
Mithril gives to the developer the flexibility to chose the best JavaScript library to use for a specific task.
A huge framework like Angular instead forces you to use their API, which does not necessarily evolve as fast as the JavaScript ecosystem. Therefore you may end up in case when you are stuck using an API which is just not the best in terms of performance
Pro Can be used without build systems
It's plain old JavaScript, can be used without webpack, gulp or grunt, just include it into your HTML and start writing your app.
Pro Does not force you into a predefined structure
Mithril's API is pretty small compared to other frameworks. It forces developers to solve problems in JavaScript rather than in Mithril. Other frameworks with massive APIs force you to think in a way that suits the framework. Mithril doesn't do that.
Pro Extremely fast
Marko consistently outperforms other alternatives in code benchmarks, both on rendering speed and compilation time.
Pro Custom tags
Custom tags provide a simple mechanism for embedding more complex components into a template by extending the HTML grammar with support for new tags. For example:
<div>
<say-hello name="World"/>
</div>
Custom tags are easy to create since they just map to a JavaScript "renderer" function as shown below:
module.exports = function sayHelloRenderer(input, out) {
out.write('Hello ' + input.name + '!');
}
Custom tags support nested content:
<fancy-overlay title="My Title">
This will be the body content of the overlay
</fancy-overlay>
Custom tags can also have parent/child relationships to support more complex use cases such a "tabs" component with nested "tab" components:
<fancy-tabs>
<fancy-tabs:tab label="Home">
Content for Home
</fancy-tabs:tab>
<fancy-tabs:tab label="Profile">
Content for Profile
</fancy-tabs:tab>
<fancy-tabs:tab label="Messages">
Content for Messages
</fancy-tabs:tab>
</fancy-tabs>
Pro Streaming
Streaming allows progressive HTML rendering and reduces time to first byte.
Pro Server-side rendering
Marko supports both server-side and client-side rendering.
Pro Marko Widgets
Marko Widgets allows UI components (rendering + behavior) to be built using Marko.
Pro Compiled templates are readable CommonJS modules
Avoids ugly globals and "named" templates.
var template = require('./template.marko');
var html = template.renderSync({name: 'Frank'});
Pro Asynchronous rendering
Marko makes additional asynchronous calls after the view rendering has begun.
Pro Lightweight runtime (~4 KB gzip)
Pro Easy to integrate with express.js
Easy Integration with Express and Node
Pro Documentation is well maintained and helpful
The documentation is extensive and very helpful. It also contains several sample applications which are very useful.
Pro Allows JavaScript expressions
JavaScript expressions can be executed inside the templates.
Pro Simple and readable syntax
Marko has a HTML-like syntax which should be easy to read and understand for everyone who has even minimal experience in web development.
Pro Short learning curve
It is easy to get up to speed and understand what is going on in a very short period of time.
Pro Small compiled templates
Marko's compiled templates are usually very small, as proven by benchmarks.
Pro Lots of tests
To prevent regressions, Marko includes a full suite of tests. The testing harness renders a collection of templates and does an exact string comparison to make sure that the tests rendered exactly as expected. There are also API tests, and negative tests to make sure that errors are reported in a friendly way.
To run tests:
git clone https://github.com/marko-js/marko
cd marko
npm install
npm test
Pro Friendly compile-time error messages
Error messages come in an easy to read and friendly format, with valid stack traces and file formats of the file(s) which brought the error(s).
Pro Concise and Mixed syntax
The Concise syntax type lets you write Marko with a Jade-like indentation based syntax, and the Mixed mode lets you combine in regular HTML-style syntax.
Pro Server and client logic can easily be expressed within the same template
Pro Has a very active and interactive community
Marko's development community is rather small compared to other frameworks but community is well mannered and active. You can chat with the core development team using gitter.im
Cons
Con Small API can make it unsuitable for larger more complex projects
Mithril's small API and small number of functions while helpful for small projects and applications where speed is needed, can add another layer of complexity in larger more complex applications where a more extensive API is needed out of the box.
Con If you want to get the full experience you have to use NodeJS
To use markojs's most popular feature: SSR although you can use any language based server as a backend. It is rather complicated.
Con Very opinionated and not customizable enough
Some custom use cases are not possible. For example, trying to build an AMP page using Marko can be very challenging (special style tag requirements are hard to work with, also, Marko by default inserts a script tag into the rendered output html which is invalid in AMP and needs to be manually removed, etc..)