Recently received a foreigner's project, the other party asked to use meteor development. At first I felt that the framework was so good that I even intended to use it later in my own project, and after this time, I would like to talk about my understanding of the framework today. Meteor is a real-time web development framework based on the Nodejs platform, with a new programming concept and a new communication model. Specific situation, can Baidu, here is no nonsense.
First of all, the advantages:
1. Setting up the environment is very simple, can easily establish a development environment, documentation is complete.
2. Front and back language unified, front and back end fully integrated, back end and front end can completely share code, for example, defined in a file of constants, functions, can be called on the back end, if you like, you can also invoke on the browser. Share the code to the fullest. Reduce workload.
3. Can quickly iterate, shorten the development cycle and cost.
4. The code runs synchronously, try to avoid the callback (actually callback this thing, if you get used to it, really feel nothing, there are many libraries can make this matter, some people from other languages to Nodejs just start not too accustomed).
5. The browser simulates a mini Mongo, you can directly query the data on the client, it feels like the query on the server.
6. Reactive programming, many places you just update the data, update the data after the other operations, do not need the programmer. such as refreshing the view.
7. DDP protocol, later can be extended to other languages, in fact, there are community versions, but the official JS.
Then say the disadvantage:
1. The framework basically uses global variables, it does it by itself, and the programmer must do so, which is determined by its implementation mechanism, this small project is OK, but a little bigger project will be disaster, no one knows what other people define the global variables, but also the framework itself has a lot of global variables, These may be you do not know, but there is no way to check, such as the framework itself with underscore library, with the global variable ' _ ', if anyone does not know that this is used by underscore, covered, the consequences are serious, more deadly, the whole framework is this model. Before you use it, you need to know which global variables are already in use in the framework or in the third-party package you are using, and which variables are not available. If you want to use a variable name, if the variable name is already used by a package, you can only change it. So from this point on, this is especially not suitable for multi-person collaboration, large-scale project development.
2. You can not manually control the loading order of files, in the normal Nodejs project, you may load a file through Reqiure, but this is not available in meteor. Programmers can not decide this, the framework to load the file in its own way, the official method is to change the file name, to the alphabetical order, or put into a subdirectory, because Meteor is the name of the alphabetical order and sub-directory priority loading. This procedure feels too cottage. In order to save the procedure require, this kind of automatic loading is done. I think it is not advisable, also very inconvenient, such as I encountered in a project such a always, want to load bootstrap.js and bootstrap-switch.js, And Bootstrap.js must be in the back of this file before loading, but the actual situation is bootstrap-switch.js loaded into the front, the results will be error, quite a headache, the solution either to rename Bootstrap.js to A-bootstrap.js or bootstrap . js to sub-directory, both ways I do not like, why I can not use this name, do not want to change, as a programmer, I have not been free to name the file? , why I want to put it in a subdirectory, I like to put the same type of file into a directory. So that makes people feel very unhappy.
3. Session problem, meteor in the session can only be used in the browser, the server is no session this thing, this feeling is not convenient, sometimes need to save some state on the servers, can only be saved in the database, each time to query. Even more inconvenient is that if you do not use the login interface to save the user ID, you simply can not distinguish visitors users. Because there's no such thing as cookies. The workaround is to generate a random string when the browser first accesses it, and then each time it is passed to the server, the server is saved and used to distinguish which user it is.
4. Memory problems, the memory footprint of the meteor application is much larger than the general application, it may be related to the real-time characteristics he implemented, because it to maintain the connection and data status of each client, one is the client subscription data state changes, the server will proactively notify the client of these changes, So the memory consumption is very scary.
5. Paging support, paging is an application of the most basic features, but this feature actually does not have a good official support, in the discover in Meteor, the author has mentioned, why not very good support paging, but there are a lot of plug-in assistance, but these features, I still want to have the official solution.
6. There is no complete test solution, although the official offers a number of test solutions, but the feeling is an understatement, and the official solution is still in the exploration, not suitable for the complete testing of large products.
7. Cannot directly use the package on NPM, if there is no asynchronous package, can be used directly, but if a package has asynchronous want to shut down the function, you can not directly use, you need to re-encapsulate, packaged into synchronous, although the official provides the method, but the feeling is still very troublesome.
8. Performance problems, although nodejs is efficient, but meteor in order to do real-time, on the server to do a lot of computational comparison operations, but also occupied a lot of memory, each browser with Websockt and the server to establish a long connection, so performance is not much good, This is not easy to feel when you develop, but a little bit of user access to your site, you will immediately feel.
9. Does not support Windows environment development, there is community support, but there is no official support.
Summary below:
Meteor as a new framework, has its extraordinary, there are other frameworks can not provide features, but we should also see its shortcomings, there is a lot of room for growth, on a personal point of view, is only suitable for small projects, absolutely not for the development of large projects, at least not yet. I have a hunch that if you use it to develop a larger project, it will make you crazy.
Why do I have to give up meteor