What is Google Colaboratory?
Google Colaboratory, sometimes called Colaboratory for short, is a Google cloud-based service that replicates Jupyter Notebook in the cloud. You don’t have to install anything on your system to use it. In most respects, you use Colaboratory as you would a desktop installation of Jupyter Notebook. Google Colaboratory is primarily for those readers who use something other than a standard desktop setup to work through the examples.
The most important thing to remember is that Colaboratory isn’t a replacement for Jupyter Notebook and the examples aren’t tested to specifically work with it, but you can try it with your alternative device if desired to follow the examples.
To use Colaboratory, you must have a Google account and then access Colaboratory using your account. Otherwise, most of the Colaboratory features won’t work.
As with Jupyter Notebook, you can use Colaboratory to perform specific tasks in a cell-oriented paradigm. If you’ve used Jupyter Notebook before, you notice a strong resemblance between Notebook and Colaboratory. Of course, you also want to perform other sorts of tasks, such as creating various cell types and using them to create notebooks that look like those you create with Notebook.
Defining Google Colaboratory
Google Colaboratory is the cloud version of Jupyter Notebook. In fact, the Welcome page makes this fact apparent. It even uses IPython (the previous name for Jupyter) Notebook (.ipynb) files for the site. That’s right, you’re viewing a Jupyter Notebook right there in your browser. Even though the two applications are similar and they both use .ipynb files, they do have some differences that you need to know about.
Understanding what Google Colaboratory does
You can use Colaboratory to perform many tasks, such as to write and run code, create its associated documentation, and display graphics, just as you do with Jupyter Notebook. The techniques you use are similar, in fact, to using Jupyter Notebook, but there are small differences between the two.
Jupyter Notebook is a localized application in that you use local resources with it. You could potentially use other sources, but doing so could prove inconvenient or impossible in some cases. For example, according to Github, your Jupyter Notebook files will appear as static HTML pages when you use a GitHub repository. In fact, some features won’t work at all. Colaboratory enables you to fully interact with your Jupyter Notebook files using GitHub as a repository. In fact, Colaboratory supports a number of online storage options, so you can regard Colaboratory as your online partner in creating Python code.
The other reason that you really need to know about Colaboratory is that you can use it with your alternative device. During the writing process, some of the example code was tested on an Android-based tablet (an ASUS ZenPad 3S 10). The target tablet has Chrome installed and executes the code well enough to follow the examples. All this said, you likely won’t want to try to write code using a tablet of that size — the text was incredibly small, for one thing, and the lack of a keyboard could be a problem, too. The point is that you don’t absolutely have to have a Windows, Linux, or OS X system to try the code, but the alternatives might not provide quite the performance you expect.
Google Colaboratory generally doesn’t work with browsers other than Chrome or Firefox. In most cases, you see an error message and no other display if you try to start Colaboratory in a browser that it doesn’t support. Your copy of Firefox may also need some configuration to work properly. The amount of configuration that you perform depends on which Colaboratory features you choose to use. Many examples work fine in Firefox without any modification.
The online coding difference between Google Colaboratory and Jupyter Notebook
For the most part, you use Colaboratory just as you would Jupyter Notebook. However, some features work differently. For example, to execute the code within a cell, you select that cell and click the run button (right-facing arrow) for that cell. The current cell remains selected, which means that you must actually initiate the selection of the next cell as a separate action. A block next to the output lets you clear just that output without affecting any other cell. Hovering the mouse over the block tells you when someone executed the content. On the right side of the cell, you see a vertical ellipsis that you can click to see a menu of options for that cell. The result is the same as when using Notebook, but the process for achieving the result is different.
The actual process for working with the code also differs from Notebook. Yes, you still type the code as you always have and the resulting code executes without problem in Jupyter Notebook. The difference is in the way you can manage the code. You can upload code from your local drive as desired and then save it to a Google Drive or GitHub. The code becomes accessible from any device at this point by accessing those same sources. All you need to do is load Colaboratory to access it.
If you use Chrome when working with Colaboratory and choose to sync your copy of Chrome among various devices, all your code becomes available on any device you choose to work with. Syncing transfers your choices to all your devices as long as those devices are also set to synchronize their settings. Consequently, you can write code on your desktop, test it on your tablet, and then review it on your smart phone. It’s all the same code, all the same repository, and the same Chrome setup, just a different device.
What you may find, however, is that all this flexibility comes at the price of speed and ergonomics. In reviewing the various options, a local copy of Jupyter Notebook executes code faster than a copy of Colaboratory using any of the available configurations (even when working with a local copy of the .ipynb file). So, you trade speed for flexibility when working with Colaboratory. In addition, viewing the source code on a tablet is hard; viewing it on a smart phone is nearly impossible. If you make the text large enough to see, you can’t see enough of the code to make any sort of reasonable editing possible. At best, you could review the code one line at a time to determine how it works.
Using Jupyter Notebook has other benefits, too. For example, when working with Colaboratory, you have options to download your source files only as .ipynb or .py files. Colaboratory doesn’t include all the other download options, including (but not limited to) HTML, LaTeX, and PDF. Consequently, your options for creating presentations from the online content are also limited to some extent. In short, using Colaboratory and Jupyter Notebook provides different coding experiences to some degree. They’re not mutually exclusive, however, because they share file formats. Theoretically, switching between the two as needed is possible.
One thing to consider when using Jupyter Notebook and Colaboratory is that the two products use most of the same terminology and many of the same features, but they’re not completely the same. The methods used to perform tasks differ, and some of the terminology does as well. For example, a Markdown cell in Jupyter Notebook is a Text cell in Colaboratory.
Using local runtime support
The only time you really need local runtime support is when you want to work within a team environment and you need the speed or resource access advantage offered by a local runtime. Using a local runtime normally produces better speed than you obtain when relying on the cloud. In addition, a local runtime enables you to access files on your machine. A local runtime also gives you control over the version of Jupyter Notebook used to execute code. You can read more about local runtime support.
You need to consider several issues when determining the need for local runtime support. The most obvious is that you need a local runtime, which means that this option won’t work with your laptop or tablet unless your laptop has Windows, Linux, or OS X and the appropriate version of Jupyter Notebook installed. Your laptop or tablet will also need an appropriate browser; Internet Explorer is almost guaranteed to cause problems, assuming that it works at all.
The most important consideration when using a local runtime, however, is that your machine is now open to possible infection from Jupyter Notebook code. You need to trust the party supplying the code. The local runtime option doesn’t open your machine to others that you share code with, however; they must either use their own local runtimes or rely on the cloud to execute code.
When working with Colaboratory on using local runtime support and Firefox, you must perform some special setups. Make sure to read the Browser Specific Setups section on the Local Runtimes page to ensure that you have Firefox configured correctly. Always verify your setup. Firefox may appear to work correctly with Colaboratory. However, a configuration issue arises when you perform tasks with it, and Colaboratory shows error messages that say the code didn’t execute (or something else that isn’t particularly helpful).