From 726b56bc3602231982f083ccd172496ae1fa7b04 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Wed, 29 May 2019 10:35:52 -0300 Subject: [PATCH 1/2] added a few notes --- porque-rust.html | 91 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/porque-rust.html b/porque-rust.html index c1638b3..8a327d8 100644 --- a/porque-rust.html +++ b/porque-rust.html @@ -80,6 +80,12 @@

Porque Você DEVE Aprender Rust

+ +
@@ -108,6 +114,14 @@
  • Versão atual: 1.35
  • + +
    @@ -117,7 +131,6 @@ -

    Basic (com números e estruturado) @@ -138,10 +151,27 @@ , Scala , Rust.

    + +
    + +
    @@ -153,6 +183,18 @@
    -- Alan Perlis, "ALGOL"
    + +
    @@ -220,10 +262,25 @@
    + +
    + +
    @@ -240,6 +297,22 @@ fn main() { println!("{}", a); } + +
    @@ -269,6 +342,11 @@ fn main() { 4 | a = 3; | ^^^^^ cannot assign twice to immutable variable + +
    @@ -281,10 +359,21 @@ fn main() { 4 | a = 3; | ^^^^^ cannot assign twice to immutable variable + +
    + +
    From be78f87e94270c415a363b07c9d04da3bc683662 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Thu, 27 Jun 2019 13:06:49 -0300 Subject: [PATCH 2/2] Tried to create a faster/quicker presentation for Rust --- quick-rust.html | 713 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 713 insertions(+) create mode 100644 quick-rust.html diff --git a/quick-rust.html b/quick-rust.html new file mode 100644 index 0000000..b0348a4 --- /dev/null +++ b/quick-rust.html @@ -0,0 +1,713 @@ + + + + + + Rápida Introdução ao Rust + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +

    Rápida Introdução ao Rust

    +
    +
    + +
    +
    + Me + +
    + +
    +
    +
    + +
    +
    +

    História

    + +
      +
    • Criada em 2006 por Graydon Hoare.
    • +
    • Patrocinada pela Mozilla em 2009.
    • +
    • Versão 1.0 em 2015.
    • +
    • Versão atual: 1.35
    • +
    • Objetivo: Criar uma linguagem rápida mas com seguraça de memória.
    • +
    +
    + + +
    + +
    +
    +

    + História + +

    + +

    + Basic + (com números e estruturado) + , dBase III Plus + , Clipper + , Pascal + , Cobol + , Delphi (ObjectPascal) + , C + , C++ + , ActionScript (Flash) + , PHP + , JavaScript + , Python + , Objective-C + , Clojure + , Java + , Scala + , Rust. +

    + + +
    + +
    + + + +
    + +
    +
    + A language that doesn't affect the way you think + about programming, is not worth knowing. +
    + +
    + -- Alan Perlis, "ALGOL" +
    + + +
    +
    + +
    +
    +

    Meu Primeiro Rust

    + +
    
    +fn main() {
    +    println!("Hello, world!");
    +}
    +                        
    + + +
    + +
    +

    Meu Primeiro Rust

    + +

    Tempo para gerar esse código:

    + +

    0 segundos

    +
    + +
    +

    Meu Primeiro Rust

    + + cargo init + + +
    +
    + +
    +
    +

    + + Cargo + +

    + +

    "Cargo is the Rust package manager"

    + +

    + "Cargo downloads your Rust package’s dependencies, + compiles your packages, makes distributable + packages, and uploads them to crates.io, the Rust + community’s package registry." +

    + + +
    +
    + +
    +
    +

    Mas De Volta Ao Rust

    + +
    
    +fn main() {
    +    let a:u8 = 2;
    +    println!("{}", a);
    +}
    +                        
    +
    + + + +
    +

    Mas De Volta Ao Rust

    + +
    
    +fn main() {
    +    let a = 2u8;
    +    println!("{}", a);
    +}
    +                        
    +
    + + + +
    +

    Mas De Volta Ao Rust

    + +
    
    +fn main() {
    +    let a = 2;
    +    println!("{}", a);
    +}
    +                        
    +
    + + + +
    +

    Mas De Volta ao Rust

    + +
    
    +fn factorial(i: u64) -> u64 {
    +    match i {
    +        0 => 1,
    +        n => n * factorial(n-1)
    +    }
    +}
    +                        
    +
    + + + +
    +

    Mas De Volta ao Rust

    + +
    
    +fn is_pred(i: u64) -> Bool {
    +    if i % 2 == 0 {
    +       True
    +    } else {
    +       False
    +    }
    +}
    +                        
    + + +
    + +
    +

    Mas De Volta ao Rust

    + +
    
    +fn is_pred(i: u64) -> Bool {
    +    i % 2 == 0
    +}
    +                        
    + + +
    + +
    +

    Mas De Volta ao Rust

    + +
    
    +enum IPAddr {
    +    IPV4,
    +    IPV6
    +}
    +                        
    + + +
    + +
    +

    Mas De Volta ao Rust

    + +
    
    +enum IPAddr {
    +    IPV4(String),
    +    IPV6(String)
    +}
    +                        
    +
    + +
    +

    Mas De Volta ao Rust

    + +
    
    +let home = IpAddr::V4(String::from("127.0.0.1");
    +
    +match home {
    +    V4(ipv4_address) => println!("IPv4 addr: {}", ipv4_address),
    +    V6(ipv6_address) => println!("Ipv6 addr: {}", ipv6_address),
    +}
    +                        
    +
    +
    + +
    +
    +

    E Aquela "Segurança de Memória"?

    +
    + +
    +

    1. No Null Pointers

    + +
    
    +match may_not_exist(value: Option<String>) {
    +    match value {
    +        Some(the_string) => println!("I got a string! {}", the_string),
    +        None => println!("I got nothing")
    +    }
    +}
    +                        
    + + +
    + +
    +

    2. No Shared Memory

    + +
    
    +fn main() {
    +   let a = String::from("A reference to a string in the code section copied to the stack");
    +   let b = a;
    +   println!("The string is: {}", a);
    +}
    +                        
    +
    + +
    + + + +
    + +
    +

    2. No Shared Memory

    + +
    
    +fn main() {
    +   let a = String::from("A reference to a string in the code section copied to the stack");
    +   let b = &a;
    +   println!("The string is: {}", a);
    +}
    +                        
    +
    + +
    + +
    + +
    +
    presente := Presente { ... }
    +canal <- presente
    + 
    + + +
    + +
    +
    presente := Presente { ... }
    +canal <- presente
    +presente.abrir()
    + + +
    + +
    +

    3. Immutable variables by default

    + +
    
    +fn main() {
    +    let a = 3;
    +    a = 5;
    +}
    +                        
    +
    +
    + +
    +
    +

    Error Control

    +
    + +
    +
    
    +enum Result<T, E> {
    +    Ok(T),
    +    Err(E),
    +}
    +                        
    +
    + +
    +
    
    +match File::create("something.txt") {
    +    Ok(fp) => fp.write_all(b"Hello world"),
    +    Err(err) => println!("Failure! {}", err),
    +}
    +                        
    +
    +
    + +
    +
    +

    Compilador Chato mas Amigável

    +
    + +
    +
    
    +fn main() {
    +    let a = 2;
    +    a = 3;
    +    println!("{}", a);
    +}
    +                        
    +
    + +
    +
    
    +3 |     let a = 2;
    +  |         -
    +  |         |
    +  |         first assignment to `a`
    +  |         help: make this binding mutable: `mut a`
    +4 |     a = 3;
    +  |     ^^^^^ cannot assign twice to immutable variable
    +                        
    + + +
    + +
    +
    
    +3 |     let a = 2;
    +  |         -
    +  |         |
    +  |         first assignment to `a`
    +  |         help: make this binding mutable: `mut a`
    +4 |     a = 3;
    +  |     ^^^^^ cannot assign twice to immutable variable
    +                        
    + + +
    + +
    +
    
    +3 |     let a = 2;
    +  |         -
    +  |         |
    +  |         first assignment to `a`
    +  |         help: make this binding mutable: `mut a`
    +4 |     a = 3;
    +  |     ^^^^^ cannot assign twice to immutable variable
    +                        
    + + +
    + +
    + + + +
    +
    + +
    +
    +

    + + A linguagem mais amada segundo o StackOverflow + Survey 2019 + + +

    ... pelo 4⁰ ano seguido.

    + + +

    +
    +
    + +
    +

    E agora?

    + + +
    + +
    +
    + +
    +
    +
    +
    + + + + + + + +