presentation-rust-introduction/rust-intro.org

105 lines
4.2 KiB
Org Mode
Raw Normal View History

#+STARTUP: beamer
#+OPTIONS: ':nil *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline
#+OPTIONS: author:t broken-links:nil c:nil creator:nil
#+OPTIONS: d:(not "LOGBOOK") date:t e:t email:nil f:t inline:t num:t
#+OPTIONS: p:nil pri:nil prop:nil stat:t tags:t tasks:t tex:t
#+OPTIONS: timestamp:t title:t toc:t todo:t |:t
#+TITLE: \includesvg[height=.25\textheight]{img/rust-logo-blk}\newline An introduction to Rust
#+DATE: \today
#+AUTHOR: \href{mailto:finga@onders.org}{finga}
#+EMAIL: finga@onders.org
#+SUBTITLE: A language empowering everyone to build reliable and efficient software.
#+DESCRIPTION:
#+LANGUAGE: en
#+KEYWORDS: rust programming
#+SELECT_TAGS: export
#+EXCLUDE_TAGS: noexport
#+CREATOR: Emacs 26.1 (Org mode 9.1.9)
#+OPTIONS: H:2
#+LATEX_CLASS: beamer
#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_act(Act) %4BEAMER_col(Col) %8BEAMER_opt(Opt)
#+LATEX_HEADER: \usepackage{svg}\hypersetup{colorlinks=true,linkcolor=black,urlcolor=gray}
#+BEAMER_THEME: Frankfurt
#+BEAMER_COLOR_THEME: seagull
#+BEAMER_FONT_THEME:
#+BEAMER_INNER_THEME:
#+BEAMER_OUTER_THEME:
#+LaTeX_CLASS_OPTIONS: [smaller]
* Rust
** Abstract
#+BEGIN_CENTER
#+LaTeX:\includegraphics[width = 0.5\textwidth]{img/Bruine_roest_op_tarwe_(Puccinia_recondita_f.sp._tritici_on_Triticum_aestivum).jpg}
[fn:1]
#+END_CENTER
*** Rust, the language
- A bit more than 10 years old (2010)
- Memory safe without gcing, optional ref counting
- Ownership, lifetimes, traits, functional paradigms
- Variables are immutable by default and can be shadowed
- Performance of idiomatic Rust is comparable to the performance
of idiomatic C++
- A well designed language and ecosystem
** Strengths and Weaknesses[fn:2]
*** Things Rust does measurably really well
- Compiled code [[https://benchmarksgame-team.pages.debian.net/benchmarksgame/which-programs-are-fastest.html][about same performance as C / C++]], and excellent
[[https://dl.acm.org/doi/10.1145/3136014.3136031][memory and energy efficiency]].
- Can [[https://www.chromium.org/Home/chromium-security/memory-safety][avoid 70% of all safety issues]] present in C / C++, and most
memory issues.
- Strong type system prevents [[https://doc.rust-lang.org/nomicon/races.html][data races]], brings [[https://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html]['fearless
concurrency']] (amongst others).
- Seamless C interop, and [[https://doc.rust-lang.org/rustc/platform-support.html][dozens of supported platforms]] (based on
LLVM).[fn:3]
- [[https://insights.stackoverflow.com/survey/2021#technology-most-loved-dreaded-and-wanted]["Most loved language"]] for 6 years in a row.
- Modern tooling: ~cargo~ (builds just work), ~clippy~ (450+ code
quality lints), ~rustup~ (easy toolchain mgmt).
** Strengths and Weaknesses[fn:2]
*** Points you might run into
- Steep learning curve[fn:4] compiler enforcing (esp. memory)
rules that would be "best practices" elsewhere.
- Missing Rust-native libs in some domains, target platforms
(esp. embedded), IDE features.[fn:4]
- Longer compile times than "similar" code in other
languages.[fn:4][fn:5]
- No formal language specification, can prevent legal use in some
domains (aviation, medical, ...).[fn:6]
- Careless (use of ~unsafe~ in) libraries can secretly break
safety guarantees.
* Cargo
** Cargo
#+ATTR_LaTeX: :height 0.4\textwidth
[[./img/cargo.png]]
** What is it?
- Package manager
- Build tool
* Setup
* Hands on
* IDE support
* Cargo plugins
* WebDev
* Embedded
* (Standard?) crates
* Further information
* Footnotes
[fn:1] [[https://commons.wikimedia.org/wiki/File:Bruine_roest_op_tarwe_(Puccinia_recondita_f.sp._tritici_on_Triticum_aestivum).jpg][Wikimedia]]
[fn:2] Copied list from: https://cheats.rs.
[fn:3] Work on GCC: [[https://rust-gcc.github.io/][rust-gcc]] and [[https://news.ycombinator.com/item?id=27775544][gcc rust backend]].
[fn:4] [[https://blog.rust-lang.org/2020/04/17/Rust-survey-2019.html#why-not-use-rust][Rust survey]]
[fn:5] [[https://news.ycombinator.com/item?id=23538220][The Rust compiler isn't slow; we are]]
[fn:6] [[https://people.mpi-sws.org/%7Ejung/thesis.html][Understanding and Evolving the Rust Programming Language]]