pug (Jade) vs React
When comparing pug (Jade) vs React, the Slant community recommends pug (Jade) for most people. In the question“What are the best JavaScript templating engines?” pug (Jade) is ranked 1st while React is ranked 8th. The most important reason people chose pug (Jade) is:
Jade supports mixins. These not only make your templating job easier but are also super-easy to read.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Easy to read, powerful mixins
Jade supports mixins. These not only make your templating job easier but are also super-easy to read.
Pro Logic done in JavaScript
The logic in Jade is done with native JavaScript. This means there's less of a learning curve and it'll be easier to get other developers up to speed.
Pro Clean syntax
One of the distinguishing features of Jade is its clean syntax. Elements are created with CSS selector syntax which makes the template consistent with your style sheet and JavaScript element selector library.
Pro Identation reflects nesting
With Jade you can quickly overview the hierarchy of a template.
Pro High performance on the server and client side
Apart from their functionality all template engines need to be efficient in terms of the time they require to render a page. Jade beats most of its competitors in this area, it is highly optimized to deliver good performance on both the server and client ends.
Pro Easy sublayouts using block and extends
By using the extends and block keywords, sublayouts can be made with intuitive syntax.
Pro Preprocessor support
Filters make it easy to embed compiled languages such as coffeescript or markdown directly into the template. A filter will allow you to keep your inline code and content consistent with the rest of your codebase so you can continue using your prefered language with your outputted HTML.
Pro Allows writing inline JavaScript
Jade allows embedding regular JavaScript code directly within the template.
Pro Reuse code in other languages
In addition to JavaScript, you can reuse Jade templates in Scala, PHP, Ruby, Python and Java.
Pro Interactive documentation
There's an interactive documentation available here that allows you to play around with code examples and watch the results in real time.
Pro Compiles to JavaScript
Jade compiles to a JavaScript function that produces the ultimate output. This interim format makes it useful for embedding in conditions where you're trying to save space or decrease processing requirements.
Pro Use Markdown for readable markup
Jade is awesome at templating structural markup, but that's not all Jade is awesome at. It also allows you to use markdown within your template itself which will render to a beautiful HTML page.
Pro Easy to reuse components
Since every single UI component is created independently in JavaScript, it becomes very easy to reuse them throughout your app without having to re-write them.
Pro Supported by Facebook and Instagram
React is built by Facebook engineers initially to be used only for their inner projects especially to solve the problem of building large complex applications with constantly changing data.
Pro Server side rendering
React can render it's components and data server side, then it sends those components as HTML to the browser.
This ensures faster initial loading time and SEO friendliness out of the box, since it's indexed as any other static website by search engines.
Pro Virtual DOM support
Instead of relying on the DOM, React implements a virtual DOM from scratch, allowing it to calculate precisely what needs to be patched during the next screen refresh. This is orders of magnitude faster than fiddling with the DOM itself.
Pro One-way data flow
React's one-way data binding (or one-way data flow) means that it's easy to see where and how your UI is updated and where you need to make changes. It's also very easy to keep everything modular, fast and well-organized.
Pro Can be used with different libraries
ReactJS can be used independently as the only library for building the front-end, or it can be used alongside JavaScript libraries such as jQuery, or even Angular.
Pro Template engine independent
React provides a template engine (JSX) which is easy to use. But it's not mandatory.
Pro Widely used
The framework is widely used in the industry.
Pro Functional programming style leads to less buggy UIs
Pro Easy to write tests
Since React's virtual DOM system is implemented completely in JavaScript, it's very easy to write UI test cases.
Pro Good debugging tools
React has an official Chrome Extension which is used as a developing and debugging tool. It can be used to quickly and painlessly debug your application or view the whole application structure as it's rendered.
Pro Flux architecture pattern
Flux is a platform agnostic pattern which can technically be used with any application or programming language.
One of Flux' main features is that it enforces uni-directional data flow which means that views do not change the data directly.
With React this is useful because this way it's easier to understand an application as it starts getting more complicated. By having two-way data binding, lead to unpredictable changes, where changing one model's data would end up updating another model. By using the Flux architecture, this can be avoided.
Pro Extensive SVG support
Since React v0.15, SVG is fully supported. React supports all SVG attributes that are recognized by today's browsers.
Pro Keep control over your app's logic
React is just a view library, so you still have (almost) full control over how your app behaves.
Pro Supported by ClojureScript libraries
Reagent, Om, Rum, etc.
Pro Tested on Facebook itself
React is used on one of the most visited websites on the planet, Facebook. With stellar results and with millions of people experiencing it every day.
Cons
Con Cannot copy/paste examples from the internet
Examples from CSS frameworks like Bootstrap are never utilizing the Pug syntax, which means that you cannot ever copy/paste something to quickly see how it would look or if it works. You would have to convert the HTML to Pug first.
Con Unforgiving in case of indentation errors
The structure is entirely determined by the indentation. That means that indentation errors will ruin the end result, often without an easy way to find the error. Indentation errors are easily introduced by copy-pasting, by rearranging code and by working in a team where not everyone uses the same indentation style. (E.g tabs vs. spaces.)
Con off-side rule templating language not working well with native HTML
plain HTML pages usually can contain very deeply nested structures, whether they are hand-written by web UI designers or generated from popular web design tools or taken from existing HTML templates, which are a nightmare for front-end engineers to convert into Pug templates, where you have to take care of handling the indentation rules and the deeply nested HTML elements, even creating multiple blocks that don't have any meaning in terms of business logic, just to house the HTML elements within bearable amounts of indentations.
Pug templates are nice for Python programmers who don't want to learn HTML to start writing web pages and develop some entire websites personally from the ground up, but for any serious project that involves more than half a dozen people and has separate positions of web UI designers, front-end developers, and back-end engineers, it's much better to choose something more closely compatible with native HTML as the template engine. Pug is simply too alien from native HTML and resembles a lot more like those other off-side rule languages like Python.
Con Bad performance
Bad sintaxe (Short-hand HTML) and bad performance. No streaming or asynchronous calls. https://github.com/mauricionobrega/nodejs-template-benchmark
Con Performance is not great compared to other popular templating engines
Con Heavy on memory
React's virtual DOM is fast, but it requires storing elements in the virtual and real DOM increasing memory usage for the page. This can be a real problem for single-page webapps designed to be left running in the background.
Con Template(view) mixed into code
Con Verbose
React gets a little verbose as applications get more complicated with more components. It's simply not as straightforward as simply writing HTML and JavaScript would be.
Con You have to learn a new syntax
Requires learning a custom syntax, JSX, that has some gotchas and introduce complexity, a steeper learning curve, and incompatibility with other tools.
Though you can opt out from JSX and use vanilla JS instead. But that is not recommended since it adds a lot of unneeded complexity which JSX tries to avoid.
Con Not a complete solution
React does not do everything for the developer, it's merely a tool for building the UI of a web app. It does not have support for routing or models, at least not out of the box. While some missing features can be added through libraries, to start using React and use it in production, you still would need to have experience, or at least a good grasp on what the best libraries to use would be.
Con Large file size
React's react.min.js
is 145.5KB in size. It's much larger than some other libraries that offer roughly the same features and it's almost the same size as some MV* frameworks such as Angular or Ember that offer more features out of the box.
Although, it should be mentioned that sometimes having a smaller library may force developers to reinvent the wheel and write inefficient implementations on features that React already has. Ending up with a larger application that's harder to maintain and/or that has bad performance.
Con Renders too frequently
Con No support for legacy browsers
React has recently dropped support for Internet Explorer 8. While the library may still work on IE8, issues that affect only IE8 will not be prioritized and/or solved.