From cb0f7855b23b71d0a2d5b79378dea1743c54b5e7 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Thu, 17 Oct 2019 11:36:42 +0200 Subject: [PATCH] I did stuff --- src/foreword/implementation.tex | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/foreword/implementation.tex b/src/foreword/implementation.tex index 2d82da2..cb34573 100644 --- a/src/foreword/implementation.tex +++ b/src/foreword/implementation.tex @@ -48,9 +48,10 @@ There are two most important geometry classes in THREE.js: \subsection{Rust} -In this section, we explain the specificities of Rust and why it is a great language for those tasks. +\subsubsection{Borrow checker} + +In this section, we explain the specificities of Rust and why it is a great language for writing efficient native software safely. -\subsubsection{Specificity of Rust} Rust is a system programming language focused on safety. It is made to be efficient (and effectively has performances comparable to C or C++) but with some extra features. C++ users might see it as a language like C++ but that forbids undefined behaviours.\footnote{in Rust, when you need to execute code that might lead to undefined behaviours, you need to put it inside an \texttt{unsafe} block. Many operations will not be available outside an \texttt{unsafe} block (e.g., dereferencing a pointer, or mutating a static variable). The idea is that you can use \texttt{unsafe} blocks when you require it, but you should avoid it as much as possible and when you do it, you must be particularly careful.} @@ -114,13 +115,35 @@ And effectively, the borrow checker will crash the compiler with the error in Li This example is one of the many examples of how powerful the borrow checker is: in Rust code, there can be no dangling reference, and all the segmentation faults coming from them are detected by the compiler. The borrow checker may seem like an enemy to newcomers because it often rejects code that seem correct, but once you get used to it, you understand what is the problem with the code and either fix the problem easily, or realise that the whole architecture is wrong and understand why. +It is probably for those reasons that Rust is the \emph{most loved programming language} according to the Stack Overflow Developer Survey in~\citeyear{so-survey-2016,so-survey-2017,so-survey-2018} and~\citeyear{so-survey-2019}. + \subsubsection{Tooling} + Even better, Rust comes with great tooling. \begin{itemize} - \item \href{https://github.com/rust-lang/rust}{\textbf{\texttt{rustc}}} is the Rust compiler. It is very confortable due to the nice error messages it displays. + \item \href{https://github.com/rust-lang/rust}{\textbf{\texttt{rustc}}} is the Rust compiler. It is very comfortable due to the nice error messages it displays. \item \href{https://github.com/rust-lang/cargo}{\textbf{\texttt{cargo}}} is the official Rust's project and package manager. It manages compilation, dependencies, documentation, tests, etc. \item \href{https://github.com/racer-rust/racer}{\textbf{\texttt{racer}}}, \href{https://github.com/rust-lang/rls}{\textbf{\texttt{rls}} (Rust Language Server)} and \href{https://github.com/rust-analyzer/rust-analyzer}{\textbf{\texttt{rust-analyzer}}} are software that manage automatic compilation to display errors in code editors as well as providing semantic code completion. \item \href{https://github.com/rust-lang/rustfmt}{\textbf{\texttt{rustfmt}}} auto formats code. \item \href{https://github.com/rust-lang/rust-clippy}{\textbf{\texttt{clippy}}} is a linter that detects unidiomatic code and suggests modifications. \end{itemize} -It is probably for those reasons that Rust is the \emph{most loved programming language} according to the Stack Overflow Developper Survey in~\citeyear{so-survey-2016,so-survey-2017,so-survey-2018} and~\citeyear{so-survey-2019}. + +\subsubsection{Glium} + +When we need to perform rendering for 3D content analysis or for evaluation, we use the \href{https://github.com/glium/glium}{\texttt{glium}} library. +Glium has many advantages over using raw OpenGL calls. +Its objectives are: + +\begin{itemize} + \item to be easy to use: it exposes functions that are higher level than raw OpenGL calls, but still low enough level to let the developer free; + \item to be safe: debugging OpenGL code can be a nightmare, and glium does its best to use the borrow checker to its advantage to avoid OpenGL bugs; + \item to be fast: the binary produced use optimized OpenGL functions calls; + \item to be compatible: glium seeks to support the latest versions of OpenGL functions and falls back to older functions if the most recent ones are not supported on the device. +\end{itemize} + +\subsubsection{Conclusion} + +In our work, many tasks will consist in 3D content analysis, reorganising and 3D rendering evaluation. +Many of these tasks require long computations, lasting from hours to entire days. +To perform them, we need a programming language that has best performances (Rust has comparable performance with C or C++) and the extra features that Rust provides ease development tremendously, and this is why we use Rust for all tasks that do not require having a web interface. +