Coding All-in-One For Dummies. Nikhil AbrahamЧитать онлайн книгу.
Time magazine named the website as one of 50 Best Websites of 2013, and the Wall Street Journal also reviewed the website. While not every startup or app will initially receive this much media coverage, it can be helpful to know what is possible when a solution really solves a problem.
Having a goal, like a website or app you want to build, is one of the best ways to learn how to code. When facing a difficult bug or a hard concept, the idea of bringing your website to life will provide the motivation you need to keep going. Just as important, do not learn how to code to become rich and famous, as the probability of your website or app becoming successful is largely due to factors out of your control.
Code comes in different flavors called programming languages. Some popular programing languages are shown in Figure 1-4.
FIGURE 1-4: Some popular programming languages.
You can think of programming languages as being similar to spoken languages because they both share many of the same characteristics, such as the following:
❯❯ Functionality across languages: Programming languages can all create the same functionality similar to how spoken languages can all express the same objects, phrases, and emotions.
❯❯ Syntax and structure: Commands in programming languages can overlap just like words in spoken languages overlap. To output text to a screen in Python or Ruby, you use the Print command, just like imprimer and imprimir are the verbs for “print” in French and Spanish.
❯❯ Natural lifespan: Programming languages are “born” when a programmer thinks of a new or easier way to express a computational concept. If other programmers agree, they adopt the language for their own programs, and the programming language spreads. However, just like Latin or Aramaic, if the programming language is not adopted by other programmers or a better language comes along, then the programming language slowly dies from lack of use.
Despite these similarities, programming languages also differ from spoken languages in a few key ways:
❯❯ One creator: Unlike spoken languages, programming languages can be created by one person in a short period of time, sometimes in just a few days.
Popular languages with a single creator include JavaScript (Brendan Eich), Python (Guido van Rossum), and Ruby (Yukihiro Matsumoto).
❯❯ Written in English: Unlike spoken languages (except, of course, English), almost all programming languages are written in English. Whether they’re programming in HTML, JavaScript, Python, or Ruby, Brazilian, French, or Chinese, almost all programmers use the same English keywords and syntax in their code. Some non-English programming languages do exist, such as languages in Hindi or Arabic, but none of these programming languages are widespread or mainstream.
Comparing low-level and high-level programming languages
One way to classify programming languages is as either low-level languages or high-level languages. Low-level languages interact directly with the computer processor or CPU, are capable of performing very basic commands, and are generally hard to read. Machine code, one example of a low-level language, uses code that consists of just two numbers, 0 and 1. Figure 1-5 shows an example of machine code. Assembly language, another low-level language, uses keywords to perform basic commands, such as read data, move data, and store data.
FIGURE 1-5: Machine code consists of 0s and 1s.
By contrast, high-level languages use natural language, so it is easier for people to read and write. Once code is written in a high-level language, like C++, Python, or Ruby, an interpreter or compiler must translate this high-level language into low-level code that a computer can understand.
Contrasting compiled code and interpreted code
Interpreted languages are considered more portable than compiled languages, while compiled languages execute faster than interpreted languages. However, the speed advantage compiled languages have is starting to fade in importance as improving processor speeds make performance differences between interpreted and compiled languages negligible.
High-level programming languages like JavaScript, Python, and Ruby are interpreted. For these languages, the interpreter executes the program directly, translating each statement one line at a time into machine code. High-level programming languages like C++, COBOL, and Visual Basic are compiled. For these languages, after the code is written, a compiler translates all the code into machine code, and an executable file is created. This executable file is then distributed via the Internet, CD-ROMs, or other media and run. Software you install on your computer, like Microsoft Windows or Mac OS X, are coded using compiled languages, usually C or C++.
Programming for the web
Software accessible on websites is gradually starting to take over installed software. Think of the last time you downloaded and installed software for your computer – you may not even remember! Installed software like Windows Media Player and Winamp that play music and movies have been replaced with websites like YouTube and Netflix. Traditional installed word processor and spreadsheet software like Microsoft Word and Excel is starting to see competition from web software like Google Docs and Sheets. Google is even selling laptops called Chromebooks that contain no installed software, and instead rely exclusively on web software to provide functionality.
The remainder of this book focuses on developing and creating web software, not just because web software is growing rapidly but also because programs for the web are easier to learn and launch than traditional installed software.
With all this talk of programming, let us actually take a look at a web application built with code. Yelp.com is a website that allows you to search and find crowd-sourced reviews for local businesses like restaurants, nightlife, and shopping. As shown in Figure 1-6, Yelp did not always look as polished as it does today, but its purpose has stayed relatively constant over the years.
FIGURE 1-6: Yelp’s website in 2004 and in 2014.
Defining the app’s purpose and scope
Once you understand an app’s purpose, you can identify a few actionable tasks a user should be able to perform to achieve that purpose. Regardless of design, the Yelp’s website has always allowed users to do the following:
❯❯ Search local listings based on venue type and location.
❯❯ Browse listing results for address, hours, reviews, photos, and location on a map.
Successful web applications generally allow for completing only a few key tasks when using the app. Adding too many features to an app is called scope creep, which dilutes