From 50b116c56dd83594dd9ef3fa4c3c3690ee67ff21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 24 Jan 2020 15:41:39 +0100 Subject: [PATCH] [DOC] add information on why odoo made owl --- README.md | 27 +++++--- doc/why_owl.md | 180 +++++++++++++++++++++++++++++++++++++++++++++++++ roadmap.md | 17 +---- 3 files changed, 200 insertions(+), 24 deletions(-) create mode 100644 doc/why_owl.md diff --git a/README.md b/README.md index a6037c7e..6cbfb598 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

🦉 Odoo Web Library 🦉

+

🦉 OWL: the Odoo Web Library 🦉

_Class based components with hooks, reactive state and concurrent mode_ @@ -14,15 +14,28 @@ simple and consistent way. Owl's main features are: - a store implementation (for state management), - a small frontend router -Owl components are defined with ES6 classes, they use QWeb templates, an underlying -virtual dom, integrates beautifully with hooks, and the rendering is asynchronous. +Owl components are defined with ES6 classes, they use QWeb templates, an +underlying virtual dom, integrates beautifully with hooks, and the rendering is +asynchronous. -**Try it online!** An online playground is available at [https://odoo.github.io/owl/playground](https://odoo.github.io/owl/playground) to let you experiment with the Owl framework. There -are some code examples to showcase some interesting features. +**Try it online!** An online playground is available at +[https://odoo.github.io/owl/playground](https://odoo.github.io/owl/playground) +to let you experiment with the Owl framework. There are some code examples to +showcase some interesting features. -Owl is currently mostly stable. Possible future changes are explained in the +Owl is currently stable. Possible future changes are explained in the [roadmap](roadmap.md). +## Why Owl? + +Why did Odoo decide to make Yet Another Framework? This is really a question +that deserves [a long answer](doc/why_owl.md). But in short, we believe that +while the current state of the art frameworks are excellent, they are not +optimized for our use case, and there is still room for something else. + +If you are interested in a comparison with React or Vue, you will +find some more additional information [here](doc/comparison.md). + ## Example Here is a short example to illustrate interactive components: @@ -81,8 +94,6 @@ Owl is not designed to be fast nor small (even though it is quite good on those two topics). It is a no nonsense framework to build applications. There is only one way to define components (with classes). -If you are interested in a comparison with React or Vue, you will -find some more information [here](doc/comparison.md). ## Documentation diff --git a/doc/why_owl.md b/doc/why_owl.md new file mode 100644 index 00000000..135fc074 --- /dev/null +++ b/doc/why_owl.md @@ -0,0 +1,180 @@ +# 🦉 Why Owl ? 🦉 + +The common wisdom is that one should not reinvent the wheel, because that would +waste effort and resources. It is certainly true in many cases. A javascript +framework is a considerable investment, so it is quite logical to ask the question: +why did Odoo decide to make OWL instead of using a standard/well known framework, +such as React or Vue? + +As you might expect, the answer to that question is not simple. But most of the +reasons discussed in this page are a consequence from a single fact: Odoo is +extremely modular. + +This means, for example, that the core parts of Odoo are not aware, before runtime, +of what files will be loaded/executed, or what will be the state of the UI. Beause +of that, Odoo cannot rely on a standard build toolchain. Also, this implies that +the core parts of Odoo need to be extremely generic. In other words, Odoo is not +really an application with a user interface. It is an application which generates +a dynamic user interface. And most frameworks are not up to the task. + +Betting on Owl was not an easy choice to make, because there certainly are a lot +of conflicting needs that we want to carefully balance. Choosing anything other +than a well known framework is bound to be controversial. This page will explain +some of the reason why we still believe that building Owl is a worthwile +endeavour. + +## Strategy + +It is true that we want to keep control of our technology, in the sense that we +do not want to depend on Facebook or Google, or any other large (or small) +company. If they decide to change their license, or to go in a direction that +will not work for us, this may be a problem. This is even more true because +Odoo is not a conventional javascript application, and our needs are probably +quite different as most other applications. + +## Class components + +It is clear that the biggest frameworks are moving away from class components. +There is an implicit assumption that class components are terrible, and that +functional programming is the way to go. React even goes as far as to say that +classes are confusing for developers. + +While there is some truth to that, and to the fact that composition is certainly +a good mechanism for code reuse, we believe that classes and inheritance are +important tools. + +Sharing code between generic components with inheritance is the way Odoo built +its web client. And it is clear that inheritance is not the root of all evils. +It is often a perfectly simple and appropriate solution. What matter most is +the architectural decisions. + +Also, Odoo has another specific use out of class components: each method of a +class provides an extension point for addons. This may not be a clean architecture +pattern, but it is a pragmatic decision that served Odoo well: classes are +sometimes monkey-patched to add behaviour from the outside. A little bit like +mixins, but from the outside. + +Using React or Vue would make it significantly harder to monkey patch components, +because a lot of the state is hidden in their internals. + +## Tooling + +React or Vue have a huge community, and a lot of effort have been made into their +tooling. This is wonderful, but at the same time, a pretty big issue for Odoo: +since the assets are totally dynamic (and could change whenever the user install +or remove an addon), we need to have all that kind of tooling on the production +servers. This is certainly not ideal. + +Also, this makes it very complicated to setup Vue or React tools: Odoo code is +not a simple file that import other files. It changes all the time, assets +are bundled differently in different contexts. This is the reason why Odoo has +its own module system, which are resolve at runtime, by the browser. The +dynamic nature of Odoo means that we often need to delay work as late as possible +(in other word, we want a JIT user interface!) + +Our ideal framework has minimal (mandatory) tooling, which makes it easier to +deploy. Using React without JSX, or Vue without vue file is not very appealing. + +At the same time, Owl is designed to solve this issue: it compiles templates +by the browser, it doesn't need much code for that, since we use the XML parser +built into each browser. Owl works with or without any additional tooling. It +can use template strings to write single file component, and is easy to integrate +in any html page, with a simple `