Coding All-in-One For Dummies. Nikhil Abraham
Чтение книги онлайн.
Читать онлайн книгу Coding All-in-One For Dummies - Nikhil Abraham страница 4
❯❯ Design: After creating a web page or a digital design, designers must persuade other designers and eventually developers to actually program their drawings into a product. Designers who code can more easily bring their designs to life and can more effectively advocate for specific designs by creating working prototypes that others can interact with.
❯❯ Public relations: Companies constantly measure how customers and the public react to announcements and news. For instance, if a celebrity spokesperson for a company does or says something offensive, should the company dump the celebrity? Public relations people who code query social media networks like Twitter or Facebook and analyze hundreds of thousands of individual messages in order to understand market sentiment.
❯❯ Operations: Additional profit can be generated, in part, by analyzing a company’s costs. Operations people who code write programs to try millions of combinations in an attempt to optimize packaging methods, loading routines, and delivery routes.
Scratching your own itch (and becoming rich and famous)
Using code built by others and coding in the workplace may cause you to think of problems you personally face that you could solve with code of your own. You may have an idea for a social network website, a better fitness app, or something new altogether. The path from idea to functioning prototype used by others involves a good amount of time and work, but might be more achievable than you think. For example, take Coffitivity, a productivity website that streams ambient coffee shop sounds to create white noise. The website was created by two people who had just learned how to program a few months prior. Shortly after Coffitivity launched, 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