The similarities and differences between Web front-end development and iOS terminal development [go]

Source: Internet
Author: User

Untitled Note http://blog.cnbang.net/tech/2495/

The similarities and differences between Web front-end development and iOS terminal development
2014-12-22
have been doing front-end development before graduation, after graduating to do iOS development, the two have a lot of interesting contrast, try to write down I can think of some of their similarities and different points.
Language
Front end and terminal as a user-oriented program, there is a common feature: the need to rely on the user's machine operating environment, so the development of language is basically no choice, not like backstage want to use what, iOS can only use object-c, the front end can only JavaScript, Of course, iOS can also use rubymotion, the front end can also be used gwt/coffeescript, but not the mainstream, with few people, the real use will be a lot more trouble. iOS can also use Apple's new Swift language, which may later be used instead of object-c, and is still in its infancy, not discussed first.
OBJC and JS have an interesting contrast: the variable/method naming style is just the opposite. Apple has been advocating user experience, write code is no exception, the program name is in English full name and more detailed, to look at variables and method name can know what is doing, such as application:didfinishlaunchingwithoptions:. And JS because every time to download from the network, to try to reduce the volume of code, so the variable method name is as far as possible with abbreviations, in fact, there are code compression tools, regardless of the variable name write how long the final line effect is the same, but we are also accustomed to the short name, such as the above OBJC application: Didfinishlaunchingwithoptions: The method in JS is used to naming is: $ ().
OBJC and JS are dynamic language, use it quite like, but OBJC is compiled, fast, many errors can also be found in the compilation process, JS is interpreted, performance depends on the interpretation of the engine, even in the strong V8 engine performance also can not catch up with the compiler language, language too dynamic, variable completely no type, It's cool to write, and it's a little bit harder to debug. Always feel JS light and flexible bohemian full of various artifice, OBJC not C + + Java so serious and no JS so flexible.
Thread
Front-end development of the concept of almost no thread, browser implementation on the page HTML and CSS parsing rendering may not be the same thread as JS, but all the JS code is only executed on one thread, not concurrent execution, there is no need to consider various concurrent programming problems. In the new JS feature can create a worker task, such a task can be executed in parallel with another thread, but because not all browsers are supported, different threads to pass the data each standard is not the same, the use of the scene is less, it does not seem to be large-scale use. For database Operations/Send network requests such tasks are different from the JS code execution thread, but these are managed by the browser, the front-end does not care or affect these threads, just receive the event callback, do not need to handle any concurrency problems.
Terminal development requires a lot of multi-threading, iOS has a main thread, UI rendering is in the threads, other time-consuming logic or database io/network requests need to be executed by another thread, otherwise it will occupy the main thread of time, resulting in the interface can not respond to user interaction events, or slow rendering caused scrolling lag. Program logic is distributed across multiple threads, need to handle a variety of code concurrency can result in inconsistent data/timing disorder and other problems, concurrency also caused some bugs to be difficult to troubleshoot, a inattention to the pit, you need to properly use some queue/lock to ensure that the program's execution sequence. iOS provides a multithreaded management approach GCD, which has packaged threads and queues in a very simple and easy-to-use feature that is much better than other end or backend, but still spends a lot of time dealing with multithreading issues.
Store
Terminal development requires a lot of data storage logic, mobile phone app is not like a browser, the user opens the browser must be connected to the network, but open an app is likely to be offline, it is likely that the network condition is very poor mobile GPRS, so you have to save the data before the request back. After the data is saved, it needs to be synchronized with the latest data of the server, if the amount of synchronous data is too large and the flow rate is slow, the incremental synchronization needs to be developed together with the service side to make the incremental data return, and the problem of consistency between client and server data needs to be handled well. When the data storage volume is complex, it is necessary to make use of limited memory to cache and optimize the performance of all kinds of storage queries.
Front-end on the desktop is rarely required to store, unless it is a one page app, do not store a series of work that naturally does not require data updates, data are removed from the background splicing directly to the page, even if there is a micro-blog can load more data on the page, the data only exist in memory, will not persist storage, Because the desktop is stable, regardless of traffic, all data can be taken directly from the backend, the client does not need to do a set of storage. Mobile web apps that work like native apps are just like terminal development, and data is saved to SQLite as well, with storage logic and the same problems to deal with.
Framework
In the third-party framework, the Web front-end and iOS development is completely the opposite, the web is weak and very open, so that a large number of third-party frameworks and libraries can cast their fists, and iOS native powerful and very closed, resulting in a third-party framework does not have much space to live.
Browser at the beginning only for content-based Web page design, JS is only this page can add small special effects of the scripting language, in the Web application era to keep up with the development, the need for a lot of third-party libraries and framework assistance, coupled with the front-end development is completely open areas, resulting in a variety of libraries and frameworks, In the early days, most libraries were focused on encapsulating DOM operations, and we repeatedly made the wheel of the DOM Operation Base Library, and after a period of time the contention for jquery alone, in the use of the library site more than 90% use JQ, almost become a standard base library. At the end of the period, we no longer re-create the wheel of this base library, there are some frameworks for the code organization and frontend architecture, such as the framework REQUIRE.JS,MVC framework Backbone/angular.js to help project modularity.
iOS development Apple has provided a complete development framework cocoa, and this framework in each generation of systems in the upgrade optimization and building blocks, the development model has been trained, the third-party framework does not have much space, a large number of popular open source projects are some common components and libraries, such as network request library afnetworking, Database Operations Library Fmdb. And some big frameworks like Beeframework/reactivecocoa are more difficult to pop up.
Compatible
Front-end development needs to be compatible with large-volume browsers, Desktop Chrome,safari,ie6-ie10,firefox, and various sets of Shell Cheetah 360 browsers, mobile ios/android respective browsers, and unlimited different screen sizes. It looks scary, actually it's not that hard, it just comes out to scare the human. Desktop-side Chrome/safari and a variety of shell-speed mode with the WebKit, the difference is very small, Firefox is generally compliant with the standard implementation, and WebKit difference is not small, the old IE6/7 need special care, but many sites do not support IE6, Mobile is a pro- , all WebKit, except for the new characteristics of the degree of support, the other difference is not small. For different screen sizes, the high-end point will be used in a responsive layout, for different screen sizes to adapt to different layouts, the general point of the desktop end of the dead width, the mobile end stretching adaptive width is done.
Terminal development also needs to be compatible with a variety of system versions and phone sizes, Android Needless to say, iOS also has 3.5/4/4.7/5.5/9.7 inches of these dimensions, but compatible with the web is quite easy, is the adaptive width, iOS uikit to handle all this, There are also advanced features such as Autolayout,sizeclass, which do not take too much effort in size. The system version on the iOS7 as a watershed, iOS7 before and after the version of the UI on the big difference, need to do some work-compatible, but the iOS user update quickly, it is expected in another year or two iOS7 the following users can be ignored.
Performance
Both the terminal and the front end are user-oriented, and performance optimization is intended to render content as quickly as possible and to allow the program to run smoothly under user action. The main focus of the terminal is storage/rendering performance. When an app stores a large amount of data, the data is complex, data query can easily become a performance bottleneck, the need to continuously optimize the efficiency of data access, planning data IO threads, design memory cache, the use of good terminal Equipment limited memory, rendering to avoid repeated rendering, as far as possible to reuse the view, to find the most efficient rendering scheme.
The front-end focus on page loading speed, because the Web page structure/style/program/resource pictures are real-time requests, to make the page to render content faster, it is necessary to optimize these requests, so that these resources are loaded at the fastest speed, including merging Pictures/merge code reduce the number of requests, compression code, parallel requests, Cache code requests based on version number, gzip compression, module/Picture lazy loading, etc. In addition to the same as the terminal is concerned about rendering performance, follow some rules to avoid page reflow, avoid using CSS shading such as the performance of the effects, with CSS3 animation instead of JS.
Compile
The terminal development needs to compile the procedure, compiles the program to the machine language, then builds the platform corresponding executable file after the various libraries link, finally by the operating system dispatches executes. Rules for compiling and linking in iOS terminal development Apple is already packaged on the Xcode development tool, and general development can be done without concern, but there are deep requirements that need to be dealt with in the compilation, such as compiling the front-end clang custom static code detection rules, writing compiled scripts for automated compilation and continuous integration, Packaging generates a static library that optimizes the app volume based on the composition of the linked executable file.
The front-end development of the program does not require the compilation process, just to throw the code to the browser, browser side parsing code side execution. Although the JS/CSS code does not have to do anything, the browser can parse the execution, but for the performance optimization described above, the front-end code will be all the code and resource files to be processed before the launch, including: compression merge js/css, merge CSS sprite diagram, processing module dependencies, Handles the code resource version number, handles resource positioning, and so on. This process is much like the traditional compilation of the program, the code to show people to optimize the processing to the machine to see, and solve some dependencies, can be considered as the front-end of the compilation process. Like Grunt.js/fis these tools can help with this compilation process, usually with front-end compilation combined with the on-line deployment as part of the on-line system.
Safety
Front-end and endpoint security issues do not need to be considered as much as the backend, but there are still some things to be aware of. In the security of the request, the terminal and the front end are the same, the user sent back to the request will need to go through layer-level routing, do not know where to be intercepted tampering or playback, so need to do some measures to defend these situations, the most common is the authentication, mostly using the expired token form instead of the user name password, Prevents a hacker from being caught in the bag and can log on to this account forever. Data security requirements will be encrypted transmission, or use HTTPS, also need to see the situation to handle some of the DNS hijacking, carrier ad implantation and other issues.
Other security issue terminals rarely consider that the system has helped to secure the entire app's environment on an jailbroken iOS machine, and that the malicious program has root privileges to do anything under the jailbroken machine, and the app is hard to prevent. Front-end aspects of the browser's characteristics of the front-end development has a few security risks, one is the Web page can be dynamically inserted in the JS code, the browser will execute the code without distinction, the second is the identity of the authentication information is stored in the cookie, third, the page can be arbitrary through the IFRAME embedded in other Web pages. Cause XSS, CSRF, cookie hijacking these attack means, so the front-end writing code need to consider these security issues, do the corresponding prevention, the simplest and most important precaution is to all users input and output content to do a complete filtering, to avoid the page embedded malicious code.
Interaction/Development
Finally, the two areas in the interaction and development of personal feelings. Before the Web front-end, feel the Web let human-machine interaction backwards for ten years, the interaction is hard click-snapped out of the results, scrolling is a refreshing, a lot of people at that time in advocating HTML5 can make how dazzling effect, in fact, Flash in ten years ago can be done out, It's also smoother than the most modern browsers. After the iphone became popular, human-computer interaction was finally restored to its rightful level, experiencing more fluency than the web, fingertip interaction/smooth animations/handy swipe gestures/unrestricted implementations, and the mainstream finally recovered or surpassed the level of flash ten years ago.
But human-computer interaction improved, the development of the way is very advanced, the development of the web is very modern, users are using the latest version, found that the bug can be immediately on-line second repair, especially for the Internet environment of the rapid iteration, and the terminal app does not, aside from the iphone audit does not say, Android also can not do to ensure that users are using the latest programs, with the traditional way of updating the client, bug fixes can not be timely to users, can not go online dozens of times a day, need to maintain a lot of old version, the development of the way back to the Web era ago. This is due to the mobile network instability and limited traffic, mobile can not be like a desktop browser, the full reliance on the network, so before the mobile network stable traffic free, the development method will not change much.
Also not optimistic about HTML5, the network said it can replace the app said three or four years, and now there is no record, the original app can get more system resources, more fluent human-computer interaction experience, HTML5 in this respect will never compare, And it can not play the advantages of web development under the limitation of mobile network and traffic, so pure HTML5 application will not become the mainstream, can do is to mix development, or take advantage of the low cost of installation/acquisition, do some light-weight things parasitic on a platform.

The similarities and differences between Web front-end development and iOS terminal development [go]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.