Skip to content
Snippets Groups Projects
Commit 94d81101 authored by Ashwin Vishnu's avatar Ashwin Vishnu
Browse files

Begin polishing python...

parent 0b102999
No related branches found
No related tags found
No related merge requests found
......@@ -307,7 +307,7 @@
encyclopedia \href{https://www.wikipedia.org/}{Wikipedia} or the community
driven forum \href{https://stackoverflow.com/}{Stack Overflow}, where people
write thousands of questions and answers on programming each week. IRC protocol
has continued to sustain the test of time and channels such as
has continued to sustain the test of time. Instant messaging channels such as
\codeinline{\#python} on Freenode facilitate interactive discussions and a form
of community-level support system --- a role which used to be filled by mailing
lists alone in the past. Alternatives such as Riot (Matrix protocol), Gitter,
......@@ -311,6 +311,7 @@
\codeinline{\#python} on Freenode facilitate interactive discussions and a form
of community-level support system --- a role which used to be filled by mailing
lists alone in the past. Alternatives such as Riot (Matrix protocol), Gitter,
and Slack have gained traction offering different integrations solutions.
and Slack have gained traction offering different integrations solutions on top
of instant messaging.
\subparagraph{Automatic web documentations built on servers.}
......@@ -315,8 +316,12 @@
\subparagraph{Automatic web documentations built on servers.}
%todo
Doxygen, Sphinx, Read the Docs...
%fixme:bookmark
Documentation generators such as Sphinx (for Python) and Doxygen (for many
languages including C, C++, Fortran and Python) ``automagically" convert in-line
comments into documentations as PDF, HTML and more. Read the Docs has in the
recent years become the main host for building and publishing documentation on
servers as web pages, thus easing the process for developers and considerably
improving access to information.
\subsection*{Python, a programming language adapted for open-science}
The Python language has been designed to boost the communication of technical
......@@ -320,7 +325,8 @@
\subsection*{Python, a programming language adapted for open-science}
The Python language has been designed to boost the communication of technical
ideas between humans. Thus, the code is as simple as possible in particular to
emphasizes code readability. Humans can focus on the ideas.
ideas between humans. Thus, the code is as simple as possible due to the
inherent emphasis on readability. Humans can focus on the ideas. Python differs
from other mainstream languages for a variety of reasons:
\begin{itemize}
......@@ -325,18 +331,22 @@
\begin{itemize}
\item The syntax is nice and elegant. Blocks of code are defined with the
indentation.
\item There are explicit guidelines (PEP~8) supporting the regularity (and
thereby readability) of the code.
\item Python is a dynamical language. The variables (names) are not attached
for life to an object. The types of the objects are inferred from the code and
in many situations, one does not need to write them explicitly.
\item Automatic memory management. The user do not have to handle by hand the
memory allocation and deallocation. There are of course ways to control the
memory usage of a program, though not as precisely as for low-level languages.
\item The standard way\footnote{There are also tools to compile Python code
(usually via C or C++ code, for example Cython and Pythran).} to run a Python
code is to ``interpret'' it. A program called the interpreter executes
instruction by instruction the code, with very few optimization.
\item \textbf{Aesthetics.} The syntax is nice and elegant. Blocks of code are
defined with the indentation.
Maintaining and modifying existing code is also eased by the very good code
readability associated with the language.
\item \textbf{Code style.} There are explicit guidelines
(\href{https://www.python.org/dev/peps/pep-0008/}{PEP~8}) supporting the
regularity (and thereby readability) of the code.
\item \textbf{Dynamic typing.} The variables (names) are not attached for life
to an object. The types of the objects are inferred from the code and in many
situations, one does not need to write them explicitly.
\item \textbf{Automatic memory management.} The user do not have to handle by
hand the memory allocation and deallocation. There are of course ways to
control the memory usage of a program, though not as precisely as for low-level
languages.
\item \textbf{Interpreted.} The standard way\footnote{There are also tools to
compile Python code (usually via C or C++ code, for example Cython and
Pythran).} to run a Python code is to ``interpret'' it. A program called the
interpreter executes the code instruction-by-instruction, with very few
optimizations.
%
......@@ -342,5 +352,5 @@
%
In contrast to other compiled languages as Fortran, C or C++, there is no
proper compilation: the code is not translated to optimized machine
instructions but only to Python bytecode.
In contrast to other compiled languages such as Fortran, C or C++, there is no
proper compilation step: the code is not translated to optimized machine
instructions, but only to Python bytecode.
%
......@@ -346,4 +356,4 @@
%
We will discuss in the following the disadvantages of this characteristic. Two
evident advantages are the shorter development cycle and the possibility of
We will discuss shortly the disadvantages of this characteristic. Two
evident advantages are rapid development cycle and the possibility of
interactive workflow (usually with IPython or Jupyter notebooks).
......@@ -349,3 +359,4 @@
interactive workflow (usually with IPython or Jupyter notebooks).
Developing with Python is much faster and easy than with many other languages.
Note that there are many implementations of Python interpreters\footnote{We can
......@@ -350,7 +361,7 @@
Note that there are many implementations of Python interpreters\footnote{We can
site CPython (written in C), Jython (Java), IronPython (C\#), PyPy (Rpython, a
cite CPython (written in C), Jython (Java), IronPython (C\#), PyPy (Rpython, a
subset of Python) and micropython (C, targeted to micro-controllers).}. The
default and most widely used implementation is written in C and is called
CPython.
......@@ -353,12 +364,10 @@
subset of Python) and micropython (C, targeted to micro-controllers).}. The
default and most widely used implementation is written in C and is called
CPython.
\end{itemize}
Python is simple but also very powerful:
\item \textbf{Simple, yet powerful.}
\begin{itemize}
\item Python supports multiple programming paradigms, including imperative,
object-oriented and functional.
......@@ -360,11 +369,11 @@
\begin{itemize}
\item Python supports multiple programming paradigms, including imperative,
object-oriented and functional.
\item It is easy to interact with code written in other languages (in
\item It is easy to interface with code written in other languages (in
particular C, C++ and Fortran).
\item Python comes with a large and high quality \href{https://docs.python.org%
/3/library/index.html}{standard library}.
......@@ -366,7 +375,7 @@
particular C, C++ and Fortran).
\item Python comes with a large and high quality \href{https://docs.python.org%
/3/library/index.html}{standard library}.
\item Python can be run on many different machines with different operating
\item Python can be deployed on many different machines with different operating
systems (Linux, Windows, OSX, Android) and architectures (from a
......@@ -372,4 +381,4 @@
systems (Linux, Windows, OSX, Android) and architectures (from a
microcontroller - with micropython - to a Blue Gene supercomputer).
microcontroller --- with micropython --- to a Blue Gene supercomputer).
\end{itemize}
......@@ -374,3 +383,4 @@
\end{itemize}
\end{itemize}
......@@ -376,12 +386,7 @@
Developing with Python is much faster and easy than with many other
languages. Less bugs are introduced by the developers only because there are
much less lines of code.
%
Thus, Python is one of the best "glue" languages for fast prototyping.
%
Maintaining and modifying existing code is also eased by the very good code
readability associated with the language.
Thus, Python is one of the best ``glue'' languages for fast prototyping. Less
bugs are introduced by the developers simply because there are much less lines
of code.
Another consequence of the apparent simplicity of Python is that the learning
curve has a nice shape. Learning Python is very easy at the beginning and the
......@@ -385,7 +390,7 @@
Another consequence of the apparent simplicity of Python is that the learning
curve has a nice shape. Learning Python is very easy at the beginning and the
complexity gradually increases while the level of the developer increases.
complexity gradually increases as the level of the developer increases.
%
Therefore, Python is good for developers of all levels: very gentle for
beginners and very powerful for advanced users.
......@@ -396,5 +401,5 @@
\item A hard and controversial decision was taken to clean up Python from its
historical incoherences by having a new Python 3 backwards-incompatible versions
of the language. Python 3.0 was released in December 2008. After a long and
difficult process, the transition Python 2 to Python 3 is now (2018) behind us
difficult process, the transition from Python 2 to Python 3 is now (2018) behind us
for nearly all important packages. Especially for scientific applications, we
......@@ -400,10 +405,10 @@
for nearly all important packages. Especially for scientific applications, we
can now work only in Python 3. As a result, \href{https://github.com/%
numpy/numpy/blob/master/doc/neps/dropping-python2.7-proposal.rst}{next releases
of \numpy will drop compatibility with Python 2}. Finally, the difficult
transition leads to very clean and coherent recent versions of
Python. Therefore, one should not used Python 2 for science anymore and instead
prefer the newer versions (3.5 or 3.6 in 2018).
can now work only in Python 3. For instance, \href{https://github.com/%
numpy/numpy/blob/master/doc/neps/dropping-python2.7-proposal.rst}{future releases
of \numpy will drop compatibility with Python 2}. These changes open doors to
very clean, coherent and potentially faster Python experience. Therefore, one
should not use Python 2 for science anymore and instead, adopt the newer
versions (3.5 or 3.6 in 2018).
\item New versions of Python have nice new features to adapt to new usages and
to recent trends in computer science. For example, three new features were
......@@ -440,7 +445,7 @@
for teaching programming and computer science.
\item Science!
%fixme:Bookmark
Python is now widely used in scientific applications. It has now a mature and
powerful scientific ecosystem with well-established based packages (\numpy for
N-dimensional homogeneous arrays, \pack{scipy} for fundamental feature of
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment