Читать книгу Deep Learning for Physical Scientists - Edward O. Pyzer-Knapp - Страница 8
2 Setting Up a Python Environment for Deep Learning Projects 2.1 Python Overview
ОглавлениеWhy use python? There are a lot of programming languages out there – and they all have their plus and minuses. In this book, we have chosen to use Python as our language of choice. Why is this?
First of all, is the ease of understanding. Python is sometimes known as “executable pseudo code,” which is a reference to how easy it is to write basic code. Now this is obviously a slight exaggeration (and it is very possible to write illegible code in Python!), but Python does represent a good trade‐off between compactness and legibility. There is a philosophy which went into developing Python which states “There should be one (and preferably only one) obvious way to do a task.” To give you an illustrative example, here is how you print a string in Python:
print("Hello World!")
It is clear what is going on! In Java it is a little more obscure, to deal with system dependencies:
system.out.println("Hello World!")
And in C, it is not obvious at all what is going on (C is a compiled language so it really only needs to tell the compiler what it needs to do):
“Hello World!" >> cout
In fact, C code can be so hard to read that there is actually a regular competition to write obfuscated C code, so unreadable it is impossible to work out what is going on – take a look at https://www.ioccc.org/ and wonder at the ingenuity. So by choosing to use Python in this book even if you are not a regular Python user you should be able to have a good understanding of what is going on.
Second is the transferability. Python is an interpreted language, and you do not need to compile it into binary in order to run it. This means that whether you run on a Mac, Windows, or Linux machine, so long as you have the required packages installed you do not have to go through any special steps to make the code you write on one machine run on another. I recommend the use of a Python distribution known as Anaconda to take this to a new level, allowing very fast and simple package installation which takes care of package dependencies. Later on, in this chapter, we will step through installing Anaconda and setting up your Python environment.
One other reason for using Python is the strong community, which has resulted in a huge amount of online support for those getting into the language. If you have a problem when writing some code for this book, online resources such as stackoverflow.com are full of people answering questions for people who have had the exact same problem. This community has resulted in the surfacing of common complaints, and the community collectively building solutions to make libraries for solving these problems and to deliver new functionality. The libraries publically available for Python are something quite special, and are one of the major reasons it has become a major player in the data science and machine learning communities.