Coding All-in-One For Dummies. Nikhil Abraham

Читать онлайн.
Название Coding All-in-One For Dummies
Автор произведения Nikhil Abraham
Жанр Зарубежная образовательная литература
Серия
Издательство Зарубежная образовательная литература
Год выпуска 0
isbn 9781119363033



Скачать книгу

target="_blank" rel="nofollow" href="#x7_c02_para_0039">FIGURE 2-8: The lindaliukas.fi website, built with HTML, CSS, and JavaScript.

      Websites conveying mainly static, unchanging information are often coded only in these three languages. You read about each of these languages in Book 3.

      Adding logic with Python, Ruby, or PHP

      Websites with more advanced functionality, such as user accounts, file uploads, and e-commerce, typically require a programming language to implement these features. Although Python, Ruby, and PHP aren’t the only programming languages these sites can use, they are among the most popular ones. This popularity means that there are large online communities of online developers who program in these languages, freely post code that you can copy to build common features, and host public online discussions that you can read for solutions to common issues.

      Each of these languages also has popular and well-documented frameworks. A framework is a collection of generic components, such as user accounts and authentication schemes that are reused frequently, allowing developers to build, test, and launch websites more quickly.

      Think of a framework as being similar to the collection of templates that comes with a word processor. You can design your resume, greeting card, or calendar from scratch, but using the built-in template for each of these document types helps you create your document faster and with greater consistency.

      Popular frameworks for these languages include

      ❯❯ Django and Flask for Python

      ❯❯ Rails and Sinatra for Ruby

      ❯❯ Zend and Laravel for PHP

Coding Mobile Applications

      Mobile applications are hot topics today, in part because mobile apps such as WhatsApp and Instagram were acquired for billions of dollars, and mobile app companies like Rovio, makers of Angry Birds, and King Digital, makers of Candy Crush, generate annual revenues of hundreds of millions to billions of dollars.

      When coding mobile applications, developers can build in one of the following ways:

      ❯❯ Mobile web applications, using HTML, CSS, and JavaScript.

      ❯❯ Native mobile applications using a specific language. For example, Apple devices are programmed using Objective-C or Swift, and Android devices are programmed using Java.

      The choice between these two options may seem simple, but there are a few factors at play. Consider the following:

      ❯❯ Companies developing mobile web applications must make sure the mobile version works across different browsers, different screen sizes, and even different manufacturers, such as Apple, Samsung, RIM, and Microsoft. This requirement results in thousands of possible phone combinations, which can greatly increase the complexity of testing needed before launch. Native mobile apps run on only one phone platform, so there is less variation to account for.

      ❯❯ Despite running on only one platform, native mobile apps are more expensive and take longer to build than mobile web apps.

      ❯❯ Some developers have reported that mobile web applications have more performance issues and load more slowly than native mobile applications.

      ❯❯ As mentioned earlier, users are spending more time using native mobile applications and less time using browser-based mobile web apps.

      ❯❯ Native mobile apps are distributed through an app store, which may require approval from the app store owner, whereas mobile web apps are accessible from any web browser. For example, Apple has a strict approval policy and takes up to six days to approve an app for inclusion in the Apple App Store, while Google has a more relaxed approval policy and takes two hours to approve an app.

      In one famous example of an app rejected from an app store, Apple blocked Google from launching the Google Voice app in the Apple App Store because it overlapped with Apple’s own phone functionality. Google responded by creating a mobile web app accessible from any browser, and Apple could do nothing to block it.

      If you’re making this choice, consider the complexity of your application. Simple applications, like schedules or menus, can likely be cheaply developed with a mobile web app, whereas more complex applications, like messaging and social networking, may benefit from having a native mobile app. Even well-established technology companies struggle with this choice. Initially, Facebook and LinkedIn created mobile web applications, but both have since shifted to primarily promoting and supporting native mobile apps. The companies cited better speed, memory management, and developer tools as some of the reasons for making the switch.

      Building mobile web apps

Although any website can be viewed with a mobile browser, those websites not optimized for mobile devices look a little weird; that is, they look as though the regular website font size and image dimensions are decreased to fit on a mobile screen. (See Figure 2-9.) By contrast, websites optimized for mobile devices have fonts that are readable, images that scale to the mobile device screen, and a vertical layout suitable for a mobile phone.

      FIGURE 2-9: Left: starbucks.com not optimized for mobile. Right: starbucks.com optimized for mobile.

      Building mobile web apps is done using HTML, CSS, and JavaScript. CSS controls the website appearance across devices based on the screen width. Screens with a small width, such as those on phones, are assigned one vertically based layout, whereas screens with a larger width, like those on tablets, are assigned a horizontally based layout. Because mobile web apps are accessed from the browser and aren’t installed on the user’s device, these web apps can’t send push notifications (alerts) to your phone, run in the background while the browser is minimized, or communicate with other apps.

      Although you can write HTML, CSS, and JavaScript for your mobile web app from scratch, mobile web frameworks allow you to develop from a base of prewritten code, much like the frameworks for programming languages I mention earlier. These mobile web frameworks include a collection of generic components that are reused frequently and allow developers to build, test, and launch websites more quickly. Twitter’s Bootstrap is one such mobile web framework, which I introduce in Book 4, Chapter 1.

      Building native mobile apps

Native mobile apps can be faster and more reliable and can look more polished than mobile web apps, as shown in Figure 2-10. Built using Java for use on Android devices, and Objective-C or Swift for use on Apple devices (iOS), native mobile apps must be uploaded to an app store, which may require approvals. The main benefit of an app store is its centralized distribution, and the app may be featured in parts of the app store that can drive downloads. Also, since native mobile applications are programs that are installed on the mobile device, they can be used in more situations without an Internet connection. Finally, and most importantly, users appear to prefer native mobile apps to mobile web apps by a wide margin, one that continues to increase.

      FIGURE 2-10: Left: facebook.com native mobile app. Right: facebook.com mobile web app.

      Native mobile apps can take advantage of features that run in the background while the app is minimized, such as push notifications, and communicate with other apps, and these features aren’t available when you’re creating a mobile web app. Additionally, native mobile apps perform better when handling graphics-intensive applications, such as games. To be clear, native mobile apps offer better performance and a greater number of features, but they require longer development times and are more expensive to build than mobile web apps.

      There