The cause of

One day a friend in the group asked a question like this:


Native development

At the beginning of mobile Internet, the initial development mode was to develop native applications through Swift or Java, with some processing of web page jump. Ios used UIWebView (WKWebView was added after ios8), and Android used WebView. At this time, the business model is not particularly complex, the users are not so many, and the length of iteration time is not particularly strong. As the business grows, this development model gradually presents a problem

  • As the business grew larger, native development required more people
  • The business becomes more complex and the development of multiple functions is completely repetitive
  • The time limit for ios review and release may be as small as a UI change, requiring a new release

Hybrid (native + H5)

Based on these problems, hrbrid applications similar to PhoneGap and Ionic have emerged. Their function is to package h5 developed pages and process them into webView. The final browsing operation is actually H5, but in this process, H5 can use native functions. The underlying concept of this h5 call native function implementation is called JsBridge, or jsBridge is a process of communication between native and H5 implementation. The core of PhoneGap, Ionic and the like is that they implement this process and expose the interface to h5 calls; In a nutshell, the PhoneGap framework process consists of three steps:

2. Android intercepts the onJsPrompt function of WebChromeClient and intercepts the message. 3. The Pluginmanager is used to distribute the message to the destination plug-in, and the jsMessageQueue is used to collect the data that needs to be returned to JS and reference a graph on the web


RN, WEEX (DSL)

Due to the hybrid development cost of a set of multi-purpose and h5 release does not need to review factors, Facebook developed a framework to deal with the corresponding mode, the performance impact of the rendering steps are handled, both RN and Weex, their development languages are JS, HTML, CSS, but at compile time, For example, after RN is converted into the corresponding Virtual DOM, a mechanism for converting the Virtual DOM into a native component is implemented at the bottom layer of Native. This process is to convert the Virtual DOM into a language form similar to JSON. Finally, through its own parsing mode to realize native components, the performance will be much better, but this implementation is similar to JSON, can also be called DSL, SQL statements can also be DSL, including HTML is also a set of DSL language. In ios, there is a JavaScriptCore framework that allows javascript to interact with OC (through which native modules can be called and rendered)

conclusion

Architectural patterns continue to evolve, such as the recent popularity of the Hybrid model. The above several problems through this article has also done a general brief, more in-depth things, but also need to continue to learn;