Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
An introduction to the Rust ecosystem
Search
Zbigniew Siciarz
May 18, 2015
Programming
5
1.8k
An introduction to the Rust ecosystem
Slides from my talk at Rust Warsaw #1.
Zbigniew Siciarz
May 18, 2015
Tweet
Share
More Decks by Zbigniew Siciarz
See All by Zbigniew Siciarz
What if Socrates was a dev?
zsiciarz
0
95
Calling Rust from other languages
zsiciarz
3
620
Python3-only Django project - the benefits
zsiciarz
1
330
My God, it's full of stars! (and planets and Python)
zsiciarz
0
3k
PostgreSQL & Django - a tasty mix
zsiciarz
2
400
Building an online PDF editor from scratch
zsiciarz
3
1k
IPython: tips, tricks & magic
zsiciarz
8
3.5k
ShiningPanda: simple CI hosting for Python
zsiciarz
1
100
requests, czyli HTTP dla ludzi
zsiciarz
1
110
Other Decks in Programming
See All in Programming
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
1.9k
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
890
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
880
最新TCAキャッチアップ
0si43
0
140
Click-free releases & the making of a CLI app
oheyadam
2
110
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
580
C++でシェーダを書く
fadis
6
4.1k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Adopting Sorbet at Scale
ufuk
73
9.1k
Designing for humans not robots
tammielis
250
25k
How to Ace a Technical Interview
jacobian
276
23k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Navigating Team Friction
lara
183
14k
For a Future-Friendly Web
brad_frost
175
9.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Transcript
Zbigniew Siciarz @zsiciarz Rust Warsaw #1 2015-05-18
http://mickmcdee.deviantart.com/art/Fungi-ecosystem-272294806
Zbigniew Siciarz @zsiciarz Rust Warsaw #1 2015-05-18 The language itself
„a systems programming language that runs blazingly fast, prevents nearly
all segfaults, and guarantees thread safety.”
<graydon> I think I named it after fungi. rusts are
amazing creatures. https://www.flickr.com/photos/basf/4837713556/
memory safety no data races zero-cost abstractions
rustup.sh distro package Windows installer
https://www.flickr.com/photos/tschaut/857853764/ https://www.flickr.com/photos/101307973@N04/13254114423/ https://www.flickr.com/photos/101307973@N04/17099131997/
https://github.com/brson/multirust manages multiple toolchains local overrides
Zbigniew Siciarz @zsiciarz Rust Warsaw #1 2015-05-18 The package manager
fetches dependencies compiles code runs build scripts
[package] name = "rustwarsaw" version = "0.0.1" authors = ["Zbigniew
Siciarz <
[email protected]
>"] [dependencies] rustc-serialize = "~0.3.14" docopt = "~0.6.64" iron = "~0.1.17" mount = "~0.0.7" staticfile = "~0.0.2"
unit tests integration tests doctests examples
#[cfg(test)] mod test { #[test] fn test_solution() { assert_eq!(2 *
21, 42); } }
uploads package to crates.io
/// Gets the CPU clock frequency in MHz. /// ///
The underlying implementation uses several methods to discover CPU /// speed, including direct measurement. If all these methods fail, function /// returns `None`. pub fn clock_frequency() -> Option<i32> { // ... }
rustfmt? future! guidelines http://doc.rust-lang.org/1.0.0/style/
Zbigniew Siciarz @zsiciarz Rust Warsaw #1 2015-05-18 when stdlib doesn’t
cut it
#[derive(RustcDecodable, RustcEncodable)] struct Movie { title: String, pub_year: usize, }
let mut reader = Reader::from_file(path).unwrap(); for row in reader.decode() { let movie: Movie = row.unwrap(); println!("{}", movie.title); }
fn get_content(url: &str) -> hyper::Result<String> { let mut client =
Client::new(); let mut response = try!(client.get(url).send()); let mut buf = String::new(); try!(response.read_to_string(&mut buf)); Ok(buf) } println!("{:?}", get_content("http://www.google.com"));
use hyper::server::{Request, Response}; fn hello(_: Request, res: Response) { res.send(b"Hello
Rust Warsaw!").unwrap(); } fn main () { hyper::Server::http(hello).listen("127.0.0.1:3000"); }
let mut sha = Sha256::new(); sha.input_str("Hello world!"); println!("{}", sha.result_str()); let
mut cipher = aes::ctr(KeySize::KeySize128, &key, &nonce); let secret = "I like Nickelback"; let mut out: Vec<u8> = repeat(0u8).take(secret.len()).collect(); cipher.process(secret.as_bytes(), &mut out[..]); println!("Ciphertext: {}", out.to_base64(STANDARD));
3D game engine http://www.piston.rs/ https://github.com/PistonDevelopers /piston-examples
rusqlite postgres redis mysql
anymap capnproto chrono conrod docopt fuse gl glutin html5ever image
iron itertools nalgebra openssl quickcheck rand regex rustache rustless sodiumoxide ssh2 time winapi zmq ...
Zbigniew Siciarz @zsiciarz Rust Warsaw #1 2015-05-18 FFI to&from other
languages
#[link(name = "cpuid")] extern { pub fn cpuid_present() -> c_int;
pub fn cpuid_lib_version() -> *const c_char; pub fn cpuid_error() -> *const c_char; // ... } pub fn is_present() -> bool { unsafe { ffi::cpuid_present() == 1 } }
extern crate libc; use std::ffi::CStr; use libc::c_char; #[no_mangle] pub extern
"C" fn count_substrings(value: *const c_char, substr: *const c_char) -> i32 { let c_value = unsafe { CStr::from_ptr(value).to_bytes() }; let c_substr = unsafe { CStr::from_ptr(substr).to_bytes() }; // ... }
#include <stdint.h> #include <stdio.h> int32_t count_substrings(const char* value, const char*
substr); int main() { printf("%d\n", count_substrings("banana", "na")); return 0; }
import ctypes library_name = "../target/debug/libstringtools.so" stringtools = ctypes.CDLL(library_name) print(stringtools.count_substrings(b"banana", b"na"))
var ffi = require('ffi'); var library_name = '../target/debug/libstringtools.so'; var stringtools = ffi.Library(library_name, { 'count_substrings': ['int', ['string', 'string']] }); console.log(stringtools.count_substrings("banana", "na"));
https://github.com/zsiciarz/rust-ffi-stringtools https://github.com/alexcrichton/rust-ffi-examples https://doc.rust-lang.org/book/ffi.html
Zbigniew Siciarz @zsiciarz Rust Warsaw #1 2015-05-18 Show me the
real deal
None
None
None
None
None
standard library docs rustbyexample.com users.rust-lang.org /r/rust #rustlang zsiciarz.github.io/24daysofrust
Zbigniew Siciarz @zsiciarz Rust Warsaw #1 2015-05-18
Zbigniew Siciarz @zsiciarz Rust Warsaw #1 2015-05-18