In the 10th AMA, the Nuggets team invited Tianzhu, the core developer of Ali Node foundation framework EggJS, to do a three-day Ask Me Anything (AMA) activity (which has ended).

We’ve compiled a selection of questions and answers from users.

On day a pig

  • Personal GitHub: github.com/atian25
  • Personal zhihu: www.zhihu.com/people/liuy…
  • Personal gold digger homepage: juejin.cn/user/289926…
  • Personal Weibo: weibo.com/liuyong25?i…

Community partners selected questions

What’s the best thing about Egg? ─ @ Lanwy

Hey, dude, can you tell me what you think is the best thing about Egg? 😃 can only say a little

The biggest highlight is the positioning. Egg is positioned as the framework of the framework. Based on Koa, it provides a set of loading specifications, thus extending the concept of plug-in and upper-layer framework, achieving a balance between ecological co-construction and differentiated customization, and helping architects of different teams hatch upper-layer frameworks suitable for their own business scenarios.

Are too many restrictions preventing egg from being widely distributed

Does egg have too many constraints compared to other Node frameworks, which prevents it from being widely used

First, Egg is lightweight, with few constraints and just a few extension points, and is simpler than upper decks like Loopback, which focus on providing a core set of sails that those upper decks have in common: a set of loaders. You think too much, may be the problem of our official website documents, many are provided by plug-ins, there is no integration.

Secondly, Egg does not need to be promoted. It was originally designed to support the cooperation among major BU within Ali, involving all walks of life, such as e-commerce, we-media, games, finance and other diverse business scenarios. Therefore, our positioning is to focus on the framework of the framework. As shown in the figure below

In addition, as a group of us who have always benefited from open source, the goal was to open source from the beginning. As for promotion, to be honest, it’s not our KPI.

What’s the difference between hapi and egg? ─ @ chenchao

What is the difference between HAPI and Egg? In enterprise development, how to choose? Are there any weaknesses that stand out compared to Express?

Hapi does not have configuration priority. It is in the same level as Express and Koa, both in the microframe layer. Egg adds a layer of Loader mechanism on top of them. When developing on Express or Koa, the team usually encapsulates a layer of business framework on top of it. The positioning of Egg is to abstract some common capabilities of this layer and enable everyone to encapsulate the upper layer of business framework based on the same set of basic rules to achieve ecological sharing.

The limitations of Express, as summarized in a recent book of mine, are:

  • However, the HTTP API of Node is encapsulated in a very thin layer, exposing the API abstraction level to developers, which is inconvenient to control.
  • The middleware model is linear, in and out, only handles the link where REQ comes in, not res goes out.
  • Callback – based middleware models are inevitably subject to Callback hell.

Which of egg’s extensions help.js or app.js is better for extending utility methods? ─ @ magican

Which of egg’s extensions help.js or app.js is better for extending utility methods? In terms of convention, help is suitable, but help is bound to context. Is app better in terms of memory footprint?

Memory this do not go to consider too much, basically according to everyone’s business magnitude, there will be no problem. In our positioning, the helper is the local formatter for the template. Extension methods, depending on your scenario, can even be placed on ctx.service.xxutils

Do you still use Node as the backend in China? How to plan for career development? ─ @ gea

Tianpig big guy, now domestic use node to do the back end of the situation is more? How to plan for career development? Because I am a Noder with more than two years of working experience, I started to work on the front end, and now I have been working on the back end of pure Node for nearly two years. Recently, I feel that most enterprises have started to shift the scene of Node forward, and I personally think node is enough to do the back end. Performance is not that big a hit, you can use a series of architectures and methods such as K8S to eliminate the weakness of weakened performance, but node backend is becoming less and less, to switch to the front-end or to other languages?

Microservitization actually brings good to Node, just provide services, do not pay attention to the language behind. The current domestic Node team, I think, is polarized:

  • A company like Alibaba, with its infrastructure and middleware, can shine.
  • Start a small company, the pursuit of speed and efficiency, so can be hands-on.
  • On the contrary, it is the middle of the small and medium-sized companies, including some large companies inside the team, limited by the movement of wiki construction and voice, push up more painful.

Performance in fact, the major language development today, for most business scenarios, it is not the time to fight this talent. The choice of a technology depends more on the team’s technology stack + operation wiki + middleware service support degree + voice.

For the development of Node, it is recommended to enter Ali to experience it. In China, Ali’s Node and other companies are completely two different stages. Or at least understand the ali Node in this process of practice, step on the pit experience, future direction, so that the target.

Comment on Nest, what do you or the Egg team think of him? — @Whales eat melons

I would like to ask Brother Tianzhu to briefly comment on Nest, tell us your or Egg team’s opinion on him, as well as his advantages and disadvantages 🙃

Nest is a framework that has emerged in recent years, notably with TypeScript and concepts from Spring.

From our perspective, the benefits of TypeScript static typing are just a few but not all of the many elements that make up an enterprise application, including programming model constraints, extension points, multi-process management, logging, security, RPC, and much more. Features such as decorators, which are currently in the stages, have not made it to Node LTS. In our view, the benefits of static typing are not as practical as unit test coverage.

TypeScript isn’t unique to frameworks either, as the Ant’s Team is working on Egg applications using TS (I heard they made a Tegg framework, which may be released later).

To recap the frame comparison, from our point of view, the frame has three layers:

  • Basic framework: Express, Koa
  • Frame of frame: Egg
  • Upper Sails: TEGG, Chair, SOFA – Node, ThinkJS, Sails, Loopback, Nest

Their positioning:

  • The microframework focuses on the underlying middleware model and is a thin layer on top of Node HTTP.
  • The upper-layer business framework is a business framework customized for a certain field and business scenario, and a combination of the team’s own business scenario and technology selection. (There are, of course, large, cathedral-like frames.)
  • Upper generally every team can encapsulate a business framework, like when ali each big BU, but an Egg is defined between front between the two, abstracts the upper frame of some common load a set of norms, on the one hand, its capability of providing plug-in reuse, on the one hand provide framework customization capability for team architect customize their upper business framework.

How do Node newcomers grow? ─ @ L, q

I have been working in a startup company, devoting myself to various businesses and solving problems. Sometimes, I need to check my basic knowledge. My personal skills are also at different levels

The key is to summarize, after encountering problems, think more, what problems encountered, what problems solved? How does a similar scenario solve this problem? How do they compare? Who is better and who is worse? What if the merits of their scheme were combined?

Or, in the future, when you go into an interview, do they want you to say, “I’ve worked with the XX framework” or do they want you to say, “When I was doing XX project, I pre-studied XX and YY framework, and finally because of XX and other reasons, I chose XX framework. In this process, I encountered XX problems, so I went to see XX source code, found that they are based on XX principle, there is room for optimization, so I tried XX. After solving the problem, I wrote a XX summary article, and even tried to solve the problem by proposing a PR for the XX framework “– this sentence seems to be said by taro.

Dialogue: Tianzhu & Yang Xuejin & Zizizhuji’s views on open source and Egg.js community

Yang Xuejin: I used Egg in the company’s technical selection of Node. After two phases, I found that the development was ok but the experience was very general. The error message is not clear, the official document is flashy, the tripartite module is there to make up the number, the framework constraints handan learning. In terms of error messages, you can say that Nodejs is asynchronous and it is not easy to locate errors. The official documents are just good-looking, but in business development, we found that many documents are not detailed. Third-party modules such as EGG-JWT typical NPM copy can also be officially recommended to use. Compare this to Laravel, where directory and module names are uppercase, but routes must be lowercase! And there are two or three ways to introduce modules in ES6. The official documentation and the source code of the CNode community you developed is the one with a lot of code duplication. For the Controller layer, there is an egg-validate plug-in that can be used independently in files or in constructors. None of this official documentation says much about custom validations and timers, which are less important but simple enough to overstate.

Day pig:

Thanks for the feedback. There’s a lot of room for improvement in the community area. You mean there’s an awsome-egg there? At present, as long as the PR can be merged, it is only as an index, we do not have the energy to analyze the source code and evaluation scheme one by one, if there are students interested in this part of the community, you can consider participating in taking over.

JWT is a community plugin, not officially maintained. Validate is not a built-in plug-in, so it’s not documented. Cnode that in fact is not the official rewrite, is park teacher called community reconstruction, the first phase only focused on migration, and no optimization.

Yang Xuejin: Thanks for the explanation, sorry I may be a little excited, I really hope the Node community can also have a relatively perfect Web framework and ecosystem.

Day pig:

It’s okay. We all have multiple roles in the community. They are also the core developers of Koa, and Koa has already accomplished its core goals. Then, at the next level of encapsulation, they are developed as the core and exported to the Egg. Similarly, the higher level business framework output, we are in another role, in other projects output, can pay attention to ant’s recent open source SOFA – Node.

Can also take a look at our this column the InfoQ interview a dead horse: why say Egg. Js is enterprise Node framework zhuanlan.zhihu.com/p/36240171

Yang Xuejin: Please use egg in your company’s project and submit an issue on Github if you have any problems. Indeed, the official reply was very quick, and basically tianzhu replied a lot, and the issue was immediately closed even if the problems were not solved after the reply. Even so, there are still many problems and obvious deficiencies in the issue of egg project, and I don’t feel that the official team is pursuing technological innovation in Egg

Day pig:

  1. If there is no solution can be reopened, this is the community, do not have a burden.
  2. To be honest, the Egg itself is pretty much done, it’s a load specification, and the core is pretty stable.
  3. The rest of us are no different from you, as members of the community, to improve the ecology.
  4. There are modules and practices that we don’t use in daily development that we really don’t have the ability or time to focus on. After all, we are just a virtual team, and we are mainly supporting Node evolution in our respective departments.
  5. Many of ali’s back end and operation wiki are not the same as the community (of course we are trying to embrace), so the open source plugins are only possible to share as a community role after we mature our internal practice.

Is there a PART of KPI assessment that drives the big guys to embrace the community so? Will there be new projects directly on Node? Or just replace the mature system with Node?

Day pig:

  1. It has always been ali’s tradition to embrace the community. We have ali Open Source group.
  2. We benefit from the open source community ourselves, and it’s natural to give back. Even many of us were recruited from the community.
  3. In fact, open source has advantages, just like we are now hiring people, many have egg and Ant Design capabilities, effectively reducing the cost of recruitment, screening and training.
  4. Open source can never be a KPI. One of our KPIs is the engineering infrastructure of our respective teams. Just to better accomplish this goal, we will consider collaboration and building an ecosystem, and then incidentally share it.
  5. Egg was never a physical team, we were all in different departments and cities, and we couldn’t have the same KPIs.

The “replacement system” thing is really difficult, not just to say, involving ecology, operation wiki building, middleware SDK, monitoring, application governance and many other fields. Node’s goal was never to replace Java; their positioning is different and complementary. Ali’s Node.js is also Su Qian Pu Ling and other predecessors fully experienced 8 years of wilderness, just out of a bloody way, with today’s blossom and fruit.

Happy question

Excuse me, why do you call day pig… ? ─ @ ink

Excuse me, why do you call day pig…

In college, the nickname was A tian, and in my day, it was popular to add a pig suffix as a nickname, so…

What’s the relationship between sky pig and flying pig? ─ @ bearever

What’s the relationship between sky pig and flying pig?

They gave me a flying Pig Angel user badge.


This issue of AMA community partners raised a lot of practical questions, thank day pig seriously for digging gold partners to answer a lot of questions. For more q&A, you can read and discuss it in the Tianzhu AMA.


This week’s AMA: You Ming, author of the Docker Practice Guide for Developers

AMA is running this week time: 2018.11.13-2018.11.15, event delivery: 👉

This week’s AMA guest is the author of the book “Docker is Not difficult” and the small volume “Necessary Docker Practice Guide for Developers”. You can contact him for any questions about Docker, virtualization, container technology, personal growth, and team management