OLD | NEW |
---|---|
1 .. _overview: | 1 .. _overview: |
2 | 2 |
3 ################## | 3 ################## |
4 Technical Overview | 4 Technical Overview |
5 ################## | 5 ################## |
6 | 6 |
7 .. contents:: | 7 .. contents:: |
8 :local: | 8 :local: |
9 :backlinks: none | 9 :backlinks: none |
10 :depth: 2 | 10 :depth: 2 |
11 | 11 |
12 Introduction | 12 Introduction |
13 ============ | 13 ============ |
14 | 14 |
15 **Native Client** is an open-source technology for running native compiled code | 15 **Native Client** (NaCl) is an open-source technology for running native |
16 in the browser, with the goal of maintaining the OS portability and safety | 16 applications in the browser, with the goal of maintaining the portability |
17 that people expect from web apps. Native Client expands web programming | 17 and safety that people expect from web applications. Native Client expands web |
18 beyond JavaScript, enabling developers to enhance their web applications | 18 programming beyond JavaScript, enabling developers to enhance their web |
19 using their preferred language. This document describes a few of the key | 19 applications using their preferred language. This document describes a few of |
20 benefits of Native Client, as well as current limitations, common use cases, | 20 the key benefits of Native Client, as well as current limitations and common use |
21 and tips for getting started with Native Client. | 21 cases. |
22 | 22 |
23 Google has implemented the open-source | 23 Google has implemented the open-source `Native Client project |
24 `Native Client project <http://www.chromium.org/nativeclient>`_ in the Chrome | 24 <http://www.chromium.org/nativeclient>`_ in the Chrome browser on Windows, Mac, |
25 browser on Windows, Mac, Linux, and Chrome OS. The **Native Client Software | 25 Linux, and Chrome OS. The :doc:`Native Client Software Development Kit (SDK) |
26 Development Kit (SDK)**, itself an open-source project, lets developers create | 26 <sdk/index>`, itself an open-source project, lets developers create web |
27 web applications that use Native Client and run in Chrome across OS | 27 applications that use NaCl and run in Chrome across OS platforms. |
28 platforms. In addition to software libraries, the SDK includes a toolchain | 28 |
29 tailored to generate executable Native Client code, as well as a variety of | 29 A web application that uses NaCl generally consists of a combination of |
30 code examples and documentation. | 30 JavaScript, HTML, CSS, and a NaCl module that is written in a language supported |
31 | 31 by the SDK. The NaCl SDK currently supports C and C++. As compilers for |
32 A web application that uses Native Client generally consists of a combination | 32 additional languages are developed, the SDK will be updated to support those |
33 of JavaScript, HTML, CSS, and a Native Client module that is written in a | 33 languages as well. |
34 language supported by a Native Client compiler. The Native Client SDK | 34 |
35 currently supports C and C++. As compilers for additional languages are | 35 .. image:: /images/web-app-with-nacl.png |
36 developed, the SDK will be updated to support those languages as well. | |
37 | |
38 .. image:: /images/NaclBlock.png | |
39 | 36 |
40 Why use Native Client? | 37 Why use Native Client? |
41 ====================== | 38 ====================== |
42 | 39 |
43 The Native Client open-source technology is designed to run native compiled | 40 The Native Client open-source technology is designed to run compiled code |
44 code securely inside browsers. Native Client puts web applications on the same | 41 securely inside a browser at near-native speeds. Native Client puts web |
45 playing field as local applications, providing the raw speed needed to compete | 42 applications on the same playing field as traditional (locally-run) software; it |
46 with traditional software like 3D games, video editing, and other applications. | 43 provides the means to fully harness the system's computational resources for |
47 Native Client also gives languages like C and C++ (and eventually others as | 44 applications like 3D games and multimedia editors. Native Client also aims to |
48 well) the same level of portability and safety that JavaScript provides on the | 45 give C and C++ (and eventually other languages) the same level of portability |
binji
2013/09/04 21:51:07
should we call out additional languages here? We h
eliben
2013/09/05 18:15:31
Do you mean that we should list more languages, or
binji
2013/09/05 20:28:58
Sorry, my comment was unclear. I was suggesting th
| |
49 web today. | 46 and safety that JavaScript provides on the web today. |
50 | 47 |
51 Here are some of the key features that Native Client offers: | 48 Here are some of the key features that Native Client offers: |
52 | 49 |
53 * **Graphics, audio, and much more:** Run native code modules that render 2D | 50 * **Graphics, audio, and much more:** Run native code modules that render 2D |
54 and 3D graphics, play audio, respond to mouse and keyboard events, run on | 51 and 3D graphics, play audio, respond to mouse and keyboard events, run on |
55 multiple threads, and access memory directly---all without requiring | 52 multiple threads, and access memory directly - all without requiring |
binji
2013/09/04 21:51:07
Why not em-dash?
eliben
2013/09/05 18:15:31
Done.
| |
56 the user to install a plug-in. | 53 the user to install a plugin. |
57 * **Portability:** Write your apps once and you'll be able to run them on | 54 * **Portability:** Write your applications once and you'll be able to run them |
58 Windows, Linux, Mac, and Chrome OS. | 55 across operating systems (Windows, Linux, Mac, and Chrome OS) and CPU |
59 * **Security:** Installing a desktop app or a browser plug-in can present | 56 architectures (x86, ARM). |
60 serious security risks and deter potential users. Native Client uses a | 57 * **Easy migration path to the web:** Many developers and companies have years |
61 double sandbox designed to protect resources on the user's system. This | 58 of work invested in existing desktop applications. Native Client makes the |
62 framework offers the safety of traditional web apps in addition to the | 59 transition from the desktop to a web application significantly easier because |
63 performance benefits of native compiled code, without requiring users to | 60 it supports C and C++. |
64 install a plug-in. | 61 * **Security:** Native Client uses a double sandbox model designed to protect |
65 * **Easy migration path to the web:** Many developers and companies have | 62 the user's system from malicious or buggy applications. This model offers the |
66 years of work invested in existing desktop applications. Native Client | 63 safety of traditional web applications without sacrificing performance and |
67 makes the transition from desktop app to web app significantly easier | 64 without requiring users to install a plugin. |
68 because Native Client supports C and C++ (and will continue to add more | 65 * **Performance:** Native Client allows your application to run at a speed |
69 languages). | 66 comparable to a desktop app (within 5-15% of native speed); it also allows |
binji
2013/09/04 21:51:07
Do we want to be this explicit about speed here?
eliben
2013/09/05 18:15:31
Yeah, I think we do. We've also mentioned it expli
binji
2013/09/05 20:28:58
OK.
| |
70 * **Performance:** Native Client allows your app to run at a speed comparable | 67 harnessing all available CPU cores via a threading API. This capability |
71 to a desktop app. This capability enables demanding applications such as | 68 enables demanding applications such as console-quality games to run inside the |
72 console-quality games to run inside the browser. | 69 browser. |
73 | 70 |
74 Common use cases | 71 Common use cases |
75 ================ | 72 ================ |
76 | 73 |
77 Native Client enables you to extend web apps running in the browser with custom | 74 Typical use cases for Native Client include the following: |
78 features and proprietary code. Typical use cases for Native Client include the | 75 |
79 following: | 76 * **Existing software components:** With its C and C++ language support, Native |
80 | 77 Client enables you to reuse current software modules in a web application - |
binji
2013/09/04 21:51:07
emdash?
eliben
2013/09/05 18:15:31
Done.
| |
81 * **Existing software components:** With its native language support | 78 you don't need to spend time reinventing and debugging code that's already |
82 (currently C and C++), Native Client enables you to reuse current software | 79 proven to work well. |
83 modules in a web app---you don't need to spend time reinventing and debugging | |
84 code that's already proven to work well. | |
85 * **Legacy desktop applications:** Native Client provides a smooth migration | 80 * **Legacy desktop applications:** Native Client provides a smooth migration |
86 path from desktop application to web app. You can port and recompile | 81 path from desktop applications to the web. You can port and recompile existing |
87 existing code for the computation engine of your application directly to | 82 code for the computation engine of your application directly to Native Client, |
88 Native Client, and need repurpose only the user interface and event | 83 and need repurpose only the user interface and event handling portions to the |
89 handling portions to the new browser platform. Native Client allows you to | 84 new browser platform. Native Client allows you to embed existing functionality |
90 embed existing functionality directly into the browser at the same time | 85 directly into the browser. At the same time, your application takes advantage |
91 your application takes advantage of things the browser does well: handling | 86 of things the browser does well: handling user interaction and processing |
92 user interaction and processing events, based on the latest developments in | 87 events, based on the latest developments in HTML5. |
93 HTML5. | |
94 * **Enterprise applications that require heavy computation:** Native Client | 88 * **Enterprise applications that require heavy computation:** Native Client |
95 handles the number crunching required by large-scale enterprise apps. To | 89 handles the number crunching required by large-scale enterprise applications. |
96 ensure protection of user data, Native Client enables you to build complex | 90 To ensure protection of user data, Native Client enables you to build complex |
97 cryptographic algorithms directly into the browser so that unencrypted data | 91 cryptographic algorithms directly into the browser so that unencrypted data |
98 never goes out over the network. | 92 never goes out over the network. |
99 * **Multimedia apps:** Codecs for processing sounds, images, and movies can | 93 * **Multimedia applications:** Codecs for processing sounds, images, and movies |
100 be added to the browser in a Native Client web app. | 94 can be added to the browser in a Native Client module. |
101 * **Games:** Native Client enables a web app to run close to native speed, | 95 * **Games:** Native Client enables a web application to run close to native |
102 reusing existing multithreaded/multicore C/C++ code bases, combined with | 96 speed, reusing existing multithreaded/multicore C/C++ code bases, combined |
103 low-level access to low-latency audio and (coming soon) networking APIs and | 97 with low-level access to low-latency audio, networking APIs and OpenGL ES with |
104 OpenGL ES with programmable shaders. Programming to Native Client also | 98 programmable shaders. Programming to Native Client also enables your binary to |
105 enables your binary to run unchanged across many platforms. Native Client | 99 run unchanged across many platforms. Native Client is a natural fit for |
106 is a natural fit for running a physics engine or artificial intelligence | 100 running a physics engine or artificial intelligence module that powers a |
107 module that powers a sophisticated web game. | 101 sophisticated web game. |
108 | 102 * **Any application that requires acceleration**: Native Client fits seamlessly |
109 Compiling existing native code for your app helps protect the investment you've | 103 into any web application, so it is up to the developer to decide to what |
110 made in research and development. In addition to the protection offered by | 104 extent to utilize it. Native Client usage covers the full spectrum from |
111 Native Client compile-time restrictions, users benefit from the security | 105 complete applications to small optimized routines that accelerate vital parts |
112 offered by its runtime validator. The validator decodes modules and limits the | 106 of traditional web applications. |
113 instructions that can run in the browser, and the sandboxed environment proxies | |
114 system calls Users can run Native Client apps without installing a new | |
115 application or a browser plug-in, and you can update your app without requiring | |
116 user intervention. | |
117 | |
118 Current limitations | |
119 =================== | |
120 | |
121 Native Client currently has the following limitations: | |
122 | |
123 * no support for hardware exceptions | |
124 * no support for process creation / subprocesses | |
125 * no support for raw TCP/UDP sockets (analogous versions---websockets for TCP | |
126 and peer connect for UDP---are in the works and will be available soon) | |
127 * no support for query to available memory | |
128 * inline assembly must be compatible with the Native Client validator (you | |
129 can use the ncval utility in the SDK to check) | |
130 | |
131 Some of these limitations are required to execute code safely in a browser. To | |
132 understand the reasons for these limitations read the `Google Chrome technical | |
133 booklet <http://www.google.com/googlebooks/chrome/index.html>`_ and the `Native | |
134 Client technical paper | |
135 <http://src.chromium.org/viewvc/native_client/data/docs_tarball/nacl/googleclien t/native_client/documentation/nacl_paper.pdf>`_ | |
136 (PDF). | |
137 | 107 |
138 How Native Client works | 108 How Native Client works |
139 ======================= | 109 ======================= |
140 | 110 |
141 In order to be safe and portable for the web, the executable native code that | 111 Native Client is an umbrella name for a set of inter-related software components |
binji
2013/09/04 21:51:07
interrelated
eliben
2013/09/05 18:15:31
Done.
| |
142 is produced must be sandbox-safe. More specifically, it cannot cause any | 112 that work together to provide a way to develop C/C++ applications and run them |
143 malicious or harmful effects on an end-user's machine. Native Client achieves | 113 securely on the web. |
144 this security through a number of techniques, including API restrictions and | 114 |
145 use of a modified compilation process. | 115 At a high level, Native Client consists of: |
146 | 116 |
147 Even though it provides software-based fault isolation on the x86 architecture, | 117 * **Toolchains**: collections of development tools (compilers, linkers, etc.) |
148 Native Client still maintains the speed of native code---or thereabout. As of | 118 that transform C/C++ code to Native Client modules. |
149 current timings, the Native Client sandbox adds only about 5% overhead, which | 119 * **Runtime components**: embedded in the browser (or another host platform), |
150 makes it possible to do serious rendering and serious number-crunching in the | 120 that allow to execute Native Client modules securely and efficiently. |
151 browser without a big performance hit. | 121 |
152 | 122 The following diagram shows how these components interact: |
153 A compiled Native Client module (.nexe file) is loaded into a web page through | 123 |
154 an <embed> element. Once uploaded to a server, the .html page and the .nexe | 124 .. image:: /images/nacl-pnacl-component-diagram.png |
155 file(s) define a web application. | 125 |
156 | 126 Native Client executables and sandbox |
157 To the Native Client runtime system, a Native Client module is simply a set of | 127 ------------------------------------- |
158 machine code, formatted to adhere to a few special rules. No matter whether the | 128 |
159 code starts out as C or C++ or any other language, the Native Client runtime | 129 Since Native Client permits executing native code on the client's machine, |
160 system performs the steps shown in the following figure: | 130 special security measures have to be implemented. The security is achieved |
161 | 131 through the following means: |
162 .. image:: /images/NaClExecution.png | 132 |
163 | 133 * The NaCl sandbox ensures that code accesses system resources only through |
binji
2013/09/04 21:51:07
The rest of the document has one or more bold elem
eliben
2013/09/05 18:15:31
I'm not sure bolding makes sense here (maybe it sh
| |
164 To ensure that system resources are untouched, the Native Client runtime system | 134 safe, whitelisted APIs, and operates within its limits without attempting to |
165 prevents the following unsafe activities: | 135 interfere with other code running within the browser or outside it. |
166 | 136 * The NaCl validator is used prior to running native code to statically analyze |
167 * Manipulating devices or files directly (instead, a special file system API | 137 the code and make sure it only uses allowed and safe code and data patterns. |
168 is provided) | 138 |
169 * Directly accessing the operating system | 139 These come in addition to the existing sandbox in the browser - the Native |
binji
2013/09/05 20:28:58
another mdash
| |
170 * Using self-modifying code to hide the code's intent (such as attempts to | 140 Client module always executes within a process with restricted permissions. The |
171 write to protected memory) | 141 only interaction of this process with the outside world is through sanctioned |
172 | 142 browser interfaces. For this reason, we say that Native Client employs a *double |
173 Salt & Pepper | 143 sandbox* design. |
174 ------------- | 144 |
175 | 145 PNaCl and NaCl |
176 Native Client product names follow a salt & pepper theme. Native Client, | 146 -------------- |
177 abbreviated to **NaCl**, started the salt & pepper naming theme. | 147 |
178 | 148 An important part of the Native Client approach is *PNaCl* - Portable Native |
binji
2013/09/04 21:51:07
Maybe remove this line, and define PNaCl in the ne
eliben
2013/09/05 18:15:31
I want to be clear that PNaCl is part of NaCl. Any
binji
2013/09/05 20:28:58
Not sure ... this sentence just doesn't say much t
| |
179 The Pepper Plug-in API (PPAPI), called **Pepper** for convenience, is an | 149 Client. PNaCl employs state-of-the-art compiler technology to compile C/C++ |
180 open-source, cross-platform API for web browser plug-ins. From the point of | 150 source code to a portable bitcode executable (**pexe**). PNaCl bitcode is an |
181 view of Native Client, Pepper is a set of APIs that allow a C or C++ Native | 151 OS and architecture independent format that can be freely distributed on the |
binji
2013/09/04 21:51:07
OS- and architecture-independent
(I think)
eliben
2013/09/05 18:15:31
I'll add the second hyphen, but leave OS-? Really?
binji
2013/09/05 20:28:58
I found this link: http://english.stackexchange.co
| |
182 Client module to communicate with the hosting browser and get access to | 152 web and :ref:`embedded in web applications<link_nacl_in_web_apps>`. |
183 system-level functions in a safe and portable way. One of the security | 153 |
184 constraints in Native Client is that modules cannot make any OS-level calls. | 154 The *PNaCl translator* is a component embedded in the web browser; its task is |
185 Pepper provides analogous APIs that modules can target instead. You can use the | 155 to run a **pexe**. Internally, the translator compiles a **pexe** to a **nexe** |
186 Pepper APIs to: | 156 (a native executable for the host platform's architecture) and then executes it |
187 | 157 within the Native Client sandbox as described above. It also uses intelligent |
188 * `talk to the JavaScript code in your application | 158 caching to avoid this compilation if this **pexe** was already compiled on the |
189 <https://developers.google.com/native-client/devguide/coding/message-system>`_ | 159 client's browser. |
190 from the C++ code in your NaCl module | 160 |
191 * `do FileIO | 161 Native Client also supports running a **nexe** directly in the browser. However, |
192 <https://developers.google.com/native-client/devguide/coding/FileIO>`_ | 162 since a **nexe** contains architecture-specific machine code, distributing |
193 * `play audio | 163 **nexe** modules on the open web is impossible. **nexe** modules can only be |
binji
2013/09/04 21:51:07
impossible is inaccurate. Maybe "not allowed"?
eliben
2013/09/05 18:15:31
Done.
| |
194 <https://developers.google.com/native-client/devguide/coding/audio>`_ | 164 used as part of applications that are installed from the Chrome Web Store and in |
195 * `render 3D graphics | 165 browser plugins. |
binji
2013/09/04 21:51:07
what do you mean by "in browser plugins"?
eliben
2013/09/05 18:15:31
Should say extensions instead, perhaps?
[though P
binji
2013/09/05 20:28:58
I guess I was confused because extensions are inst
| |
196 <https://developers.google.com/native-client/devguide/coding/3D-graphics>`_ | 166 |
197 | 167 Toolchains |
198 The figure below illustrates how Pepper serves as a bridge between Native | 168 ---------- |
199 Client modules and the browser: | 169 |
200 | 170 A *toolchain* is a set of tools used to create an application from a set of |
201 .. image:: /images/pepper.jpg | 171 source files. In the case of Native Client, a toolchain consists of a compiler, |
202 | 172 linker, assembler and other tools that are used by the developer to convert an |
203 Pepper includes both a C API and a C++ API. The C++ API is a set of bindings | 173 application written in C/C++ into a module loadable by the browser. |
204 written on top of the C API. You can access reference documentation for both | 174 |
205 the C API and the C++ API through the left-nav on this site. For additional | 175 The Native Client SDK provides two toolchains: |
206 information about Pepper, see `Pepper Concepts | 176 |
207 <http://code.google.com/p/ppapi/wiki/Concepts>`_. | 177 * A PNaCl toolchain for generating portable NaCl modules (**pexe**). |
208 | 178 * A gcc-based toolchain (**nacl-gcc**) for generating native NaCl modules |
209 Application Structure | 179 (**nexe**). |
210 ===================== | 180 |
211 | 181 For most applications, the PNaCl toolchain is recommended. The **nacl-gcc** |
212 A Native Client application is divided into three main parts: | 182 toolchain should only be used if the application will not be available on the |
213 | 183 open web. |
214 * **HTML/JavaScript application:** Provides the user interface and event | 184 |
215 handling mechanisms as well as the main HTML document; can perform | 185 .. _link_nacl_in_web_apps: |
216 computation as well. | 186 |
217 * **Pepper API:** Enables the JavaScript code and the Native Client module to | 187 Native Client in a web application |
218 send messages to each other, and provides interfaces that allow Native | 188 ================================== |
219 Client modules to create and use browser resources. | |
220 * **Native Client module:** Typically, performs numerical computation and | |
221 other compute-intensive tasks. Handles large-scale data manipulation. Also | |
222 provides event handling APIs for apps such as games where the user interface | |
223 is integrated into the code that is run natively. | |
224 | |
225 The following diagram shows how Pepper provides the bridge between the Native | |
226 Client module's code and the browser's JavaScript: | |
227 | |
228 .. image:: /images/ProgramStructure.png | |
229 :align: center | |
230 :alt: Program Structure | |
231 | |
232 Files in a Native Client application | |
233 ------------------------------------ | |
234 | 189 |
235 A Native Client application consists of a set of files: | 190 A Native Client application consists of a set of files: |
236 | 191 |
237 * The **HTML web page**, **CSS**, and **JavaScript** files. Most Native Client | 192 * The **HTML web page**, **CSS**, and **JavaScript** files. Most Native Client |
238 apps contain at least an HTML document, optional CSS for styling of the web | 193 applications contain at least an HTML document, optional CSS for styling of |
239 page, and one or more supporting JavaScript files for user interface | 194 the web page, and one or more supporting JavaScript files for user interface |
240 objects, event handling, and simple programming tasks and calculations | 195 objects, event handling, and simple programming tasks and calculations |
241 suitable for the JavaScript layer. | 196 suitable for the JavaScript layer. |
binji
2013/09/04 21:51:07
mention communicating with the NaCl module?
eliben
2013/09/05 18:15:31
Done and made the paragraph shorter. I think "simp
binji
2013/09/05 20:28:58
I like the new paragraph better.
| |
242 * The **Native Client module**. This module contains the native compiled | 197 * The **pexe** (portable NaCl module). This module uses the :ref:`Pepper |
243 code, and uses the Pepper Library (included in the SDK), which provides the | 198 <link_pepper>` API, which provides the bridge to JavaScript and |
244 bridge between the Native Client module and JavaScript and browser | 199 browser resources. |
245 resources. Currently, the SDK supports the C and C++ languages for Native | 200 * A **manifest** file that specifies the **pexe** to load with some loading |
246 Client modules. When compiled, the extension for this filename is | 201 options. This manifest file is embedded into the HTML page through an |
247 *.nexe*. | 202 ``<embed>`` tag. |
248 * A **manifest** file that specifies modules to load for different | 203 |
249 processors. This file includes a set of key-value pairs, where a key is the | 204 .. image:: /images/nacl-in-a-web-app.png |
250 end-user's processor (for example, x86-32, x86-64, or ARM) and the | 205 |
251 corresponding value is the URL of the module compiled for that processor. | 206 For more details, see TODO (link to example walk-through). |
252 The extension for this filename is *.nmf*. | 207 |
253 | 208 .. _link_pepper: |
254 HTML file | 209 |
255 ^^^^^^^^^ | 210 Pepper Plugin API |
256 | 211 ----------------- |
257 The HTML file contains the ``<embed>`` tag that loads the Native Client module. | 212 |
258 For example:: | 213 The Pepper Plugin API (PPAPI), called **Pepper** for convenience, is an |
259 | 214 open-source, cross-platform C/C++ API for web browser plugins. From the point |
260 <embed name="nacl_module" | 215 of view of NaCl, Pepper allows a C/C++ NaCl module to communicate with the |
261 id="hello_world" | 216 hosting browser and get access to system-level functions in a safe and portable |
262 width=0 height=0 | 217 way. One of the security constraints in NaCl is that modules cannot make any |
263 src="hello_world.nmf" | 218 OS-level calls directly. Pepper provides analogous APIs that modules can target |
264 type="application/x-nacl"> | 219 instead. |
265 | 220 |
266 The mimetype for a Native Client module, specified in the ``type`` attribute, is | 221 You can use the Pepper APIs to gain access to the full array of browser |
267 ``application/x-nacl``. | 222 capabilities, including: |
268 | 223 |
269 Native Client modules are operating system independent, but they are not (yet) | 224 * :doc:`Talk to the JavaScript code in your application |
270 processor independent. Therefore, you must compile separate versions of a Native | 225 <devguide/coding/message-system>` from the C++ code in your NaCl module. |
271 Client module for x86 32-bit, x86 64-bit, ARM, and other processors. The | 226 * :doc:`Do file I/O <devguide/coding/FileIO>`. |
272 manifest file, specified in the ``src`` attribute of the ``<embed>`` | 227 * :doc:`Play audio <devguide/coding/audio>`. |
273 tag, specifies which version of the Native Client module to load depending on | 228 * :doc:`Render 3D graphics <devguide/coding/3D-graphics>`. |
274 the end-user's processor. | 229 |
275 | 230 Pepper includes both a C API and a C++ API. The C++ API is a set of bindings |
276 Native Client module | 231 written on top of the C API. For additional information about Pepper, see |
277 ^^^^^^^^^^^^^^^^^^^^ | 232 `Pepper Concepts <http://code.google.com/p/ppapi/wiki/Concepts>`_. |
278 | 233 |
279 You can write a Native Client module in C or C++, and use existing libraries | 234 Salt and Pepper |
binji
2013/09/04 21:51:07
This seems out of place now. Maybe just remove?
eliben
2013/09/05 18:15:31
Gladly
| |
280 and modules compatible with that language. After you've implemented your | 235 ^^^^^^^^^^^^^^^ |
281 functions in the module, you can use the Pepper API to pass messages to and | 236 |
282 receive messages from the JavaScript/browser side of the application. | 237 Native Client product names follow a salt & pepper theme. Native Client, |
283 | 238 abbreviated to **NaCl** (the checmical formula for sodium chloride, also known |
284 | 239 as common salt), started the salt & pepper naming theme. |
285 Creating a Native Client application | 240 |
286 ==================================== | 241 Where to go next |
287 | 242 ================ |
288 Native Client is extremely flexible, allowing for numerous ways to develop an | 243 |
289 application. The following is one of the more common approaches: | 244 The :doc:`quick start <quick-start>` document provides links to downloads and |
290 | 245 documentation that should help you get started with developing and distributing |
291 1. :doc:`Download <sdk/download>` the Native Client SDK. You may also need to | 246 NaCl applications. |
292 download and install Python, which is required to run a number of tools in | |
293 the SDK. | |
294 2. Write the application: | |
295 | |
296 a. Create a user interface using HTML, JavaScript, and CSS. | |
297 b. If necessary, port existing libraries to compile with your Native Client | |
298 module. If you find yourself missing a common library, have a look at | |
299 `NaCl ports <http://code.google.com/p/naclports>`_, a repository for open | |
300 source libraries. Contributions are welcome. | |
301 c. Create the Native Client module and `build | |
302 <https://developers.google.com/native-client/devguide/devcycle/building>`_ | |
303 it using one of the NaCl toolchains in the SDK. | |
304 3. `Run | |
305 <https://developers.google.com/native-client/devguide/devcycle/running>`_ the | |
306 application. | |
307 4. `Distribute | |
308 <https://developers.google.com/native-client/devguide/distributing>`_ the | |
309 application. | |
310 | |
311 For detailed, step-by-step instructions on how to create a Native Client | |
312 application, see the `Getting Started Tutorial | |
313 <https://developers.google.com/native-client/devguide/tutorial>`_. The tutorial | |
314 includes a basic set of template files that you can modify for your project. | |
315 | |
316 Using existing code | |
317 =================== | |
318 | |
319 The Native Client SDK comes with a modified version of the GNU toolchain | |
320 (including GCC and G++) that produces sandbox-safe native code to be run in the | |
321 browser. This opens the browser to 3D games, video editing, and other | |
322 applications that can be moved to the web with relatively little effort. Some | |
323 work is required, however, to keep code safe for execution on the web. For | |
324 instance, OS-level calls must be redirected to target the Pepper API, and there | |
325 are also restrictions on how file IO and threading operations work. | |
326 | |
327 Distributing a Native Client application | |
328 ======================================== | |
329 | |
330 The Chrome browser only runs Native Client applications published through the | |
331 `Chrome Web Store | |
332 <https://chrome.google.com/webstore/search/%22native%20client%22%20OR%20nativecl ient%20OR%20nacl>`_ | |
333 (CWS). To distribute an application, you must compile the application for both | |
334 the 32-bit and 64-bit x86 architectures, and publish the application in the | |
335 CWS. | |
336 | |
337 Native Client has not been standardized yet, and currently it requires | |
338 compilation for specific instruction set architectures. Google only allows | |
339 Native Client applications into the CWS if the applications are available for | |
340 both 32-bit and 64-bit x86 architectures; developers are also strongly | |
341 encouraged to provide a build for the ARM architecture. The intent behind the | |
342 current policy of requiring applications to be compiled for multiple | |
343 architectures is not to bake one instruction set into the web, and to make sure | |
344 that future architectures are supported as well. | |
345 | |
346 Note that this is only a temporary requirement: The ultimate plan is to create | |
347 a new version of Native Client executables that can run on any processor. This | |
348 new Native Client technology is called Portable Native Client (PNaCl, | |
349 pronounced "pinnacle"), and it is already under development. Instead of | |
350 generating x86 code or ARM code, PNaCl transforms high-level code into bitcode | |
351 using a compiler based on the open source LLVM (low-level virtual machine) | |
352 project. When the browser downloads the bitcode, PNaCl then translates it to | |
353 native machine code and validates it in the same way Native Client validates | |
354 machine code today. | |
355 | |
356 PNaCl could potentially give Native Client the same reach as JavaScript, but | |
357 there are still hurdles to overcome. Part of the problem is that PNaCl has more | |
358 overhead. Currently PNaCl can execute much faster than JavaScript, but it does | |
359 not yet start up as quickly. Before officially launching PNaCl, Google wants to | |
360 make sure to close that gap. | |
361 | |
362 The Native Client SDK | |
363 ===================== | |
364 | |
365 The Native Client SDK includes the following: | |
366 | |
367 * GNU-based toolchains: gcc, g++, as, ld, gdb, and other tools customized for | |
368 Native Client | |
369 * API libraries (Pepper, POSIX) | |
370 * Makefiles for building Native Client applications | |
371 * Examples | |
372 * Documentation | |
373 | 247 |
374 Versioning | 248 Versioning |
binji
2013/09/04 21:51:07
Seems strange to have versioning below "where to g
eliben
2013/09/05 18:15:31
Done.
| |
375 ========== | 249 ========== |
376 | 250 |
377 Chrome releases on a six week cycle, and developer versions of Chrome are | 251 Chrome releases on a six week cycle, and developer versions of Chrome are |
378 pushed to the public beta channel three weeks before release. As with any | 252 pushed to the public beta channel three weeks before release. As with any |
379 software, each release of Chrome includes changes to Native Client and the | 253 software, each release of Chrome includes changes to Native Client and the |
380 Pepper interfaces that may require modification to existing applications. | 254 Pepper interfaces that may require modification to existing applications. |
381 However, modules compiled for one version of Pepper/Chrome should generally | 255 However, modules compiled for one version of Pepper/Chrome should generally |
382 work with subsequent versions of Pepper/Chrome. The SDK includes multiple | 256 work with subsequent versions of Pepper/Chrome. The SDK includes multiple |
383 `versions <https://developers.google.com/native-client/version>`_ of the Pepper | 257 `versions <https://developers.google.com/native-client/version>`_ of the Pepper |
384 APIs to help developers make adjustments to API changes and take advantage of | 258 APIs to help developers make adjustments to API changes and take advantage of |
385 new features. | 259 new features. |
OLD | NEW |