11 historias e 1 segredo
DESCRIPTION
Curiosidades sobre linguagens de programação. Apresentação realizada no Startup Dev Day.TRANSCRIPT
![Page 2: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/2.jpg)
1989
Estu
dant
e
1991
Prog
ramad
or
1994
Empr
eend
edor
Anali
sta de
Tecno
logia
1998
Líder
Técnico
2000
2001
Arquiteto de
Software
2005
Scrum Master
2010
Consultor em
Tecnologia
2014(?)
Consultor em
NegóciosQuem é
Luiz Borba?http://borba.blog.br
![Page 3: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/3.jpg)
O Pirulito
![Page 4: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/4.jpg)
“All non-trivial abstractions, to some degree, are leaky.”
- Joel Spolsky
![Page 5: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/5.jpg)
Linguagens de programação são leaky
abstractions.
![Page 6: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/6.jpg)
![Page 7: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/7.jpg)
Temos obrigação de conhecer o que a
linguagem que utilizamos faz por debaixo dos panos.
![Page 8: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/8.jpg)
“When someone says: ‘I want a programming
language in which I need only say what I wish done’,
give him a lollipop.”
- Alan J. Perlis
![Page 9: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/9.jpg)
Mergulhe
![Page 10: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/10.jpg)
O bug existencial
![Page 11: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/11.jpg)
“The most likely way for the world to be destroyed, most
experts agree, is by accident. That's where we come in; we're
computer professionals. We cause accidents.”
- Nathaniel Borenstein
![Page 12: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/12.jpg)
Qual a melhor forma de
aprender uma linguagem?
![Page 13: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/13.jpg)
A Internet não esteve sempre
por aqui...
![Page 14: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/14.jpg)
NÃO HÁ NADA DE ERRADO EM
LER LIVROS
![Page 15: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/15.jpg)
Não programe por coincidência.
![Page 16: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/16.jpg)
Aprenda
![Page 17: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/17.jpg)
Eis o mistério da FÉ
![Page 18: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/18.jpg)
|”May 2013” can’t be found|
”””May 2013”” can’t be found”
”\”May 2013\” can’t be found”
‘”May 2013” can\’t be found’
![Page 19: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/19.jpg)
#include <stdio.h> main()[ int value = 1; while(value<=3) [ printf(|Value is %d\n|, value); value++; ] return array{1};]
![Page 20: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/20.jpg)
Qual a origem do QWERTY?
![Page 21: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/21.jpg)
O KALQ vinga?
![Page 22: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/22.jpg)
![Page 23: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/23.jpg)
Não há progresso sem desafios. Desafie o
“status quo”
![Page 24: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/24.jpg)
Desafie
![Page 25: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/25.jpg)
Tanto faz dá na cabeça quanto na
cabeça dá?
![Page 26: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/26.jpg)
sort(lista) ou
lista.sort()
![Page 27: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/27.jpg)
Reflita
![Page 28: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/28.jpg)
Mister M
![Page 29: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/29.jpg)
salvar(objeto) { broker.beginTrans(); broker.save(objeto); broker.commit();}
![Page 30: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/30.jpg)
salvar(objeto) { broker.save(objeto);}
<transactional-methods> <method>salvar</method></transactional-methods>
![Page 31: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/31.jpg)
@Transactionalsalvar(objeto) { broker.save(objeto);}
![Page 32: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/32.jpg)
Aspect-Oriented Programming
(AOP) é bacana
![Page 33: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/33.jpg)
Aspect-Oriented Programming
(AOP) é pura bosta
![Page 34: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/34.jpg)
Esse livro é bom pra
caralho
![Page 35: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/35.jpg)
...já esse livro é uma
merda
![Page 36: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/36.jpg)
“Eu vou desdizerAquilo tudo que eu lhe disse antesEu prefiro serEssa metamorfose ambulanteDo que ter aquela velha opiniãoFormada sobre tudo”
![Page 37: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/37.jpg)
Mude
![Page 38: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/38.jpg)
Funcional ou Orientado a Objeto?
![Page 39: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/39.jpg)
“Software is getting slower faster than hardware
becomes faster.”
- Niklaus Wirth
![Page 40: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/40.jpg)
•Funções de alta ordem•Imutabilidade•Sem efeitos colaterais•Pattern Matching•Recursão•Currying•Lazy Evaluation•Continuations•Closures•Functional Composition•Referencial Transparency•Monads
![Page 41: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/41.jpg)
Linguagens Multi-Paradigmáticas
![Page 42: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/42.jpg)
Antene-se
![Page 43: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/43.jpg)
Vietnã da computação
![Page 44: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/44.jpg)
Object-Relational Mapping (ORM)
Linguagens Orientadas a Objetos
Banco de Dados Relacionais
![Page 45: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/45.jpg)
NoSQL
mas nada é para sempre
![Page 46: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/46.jpg)
Experimente
![Page 47: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/47.jpg)
COBOL morreu
![Page 48: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/48.jpg)
ou CONSERVADORA
Java é uma linguagem REVOLUCIONÁRIA
![Page 49: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/49.jpg)
![Page 50: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/50.jpg)
![Page 51: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/51.jpg)
ENTERRE
![Page 52: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/52.jpg)
A Pior Linguagem do Mundo
![Page 53: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/53.jpg)
‘5’ + 3 = 53‘5’ - 2 = 2
‘’ == ‘0’ // false 0 == ‘’ // true
false == undefined // falsefalse == null // falsenull == undefined // true
![Page 54: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/54.jpg)
Qual a linguagem?
![Page 55: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/55.jpg)
ACEITE
![Page 56: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/56.jpg)
Linguagem Verde
![Page 57: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/57.jpg)
Consumo de energia é cada dia mais importante
![Page 58: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/58.jpg)
Teremos linguagens onde poderemos medir o consumo do código
produzido?
![Page 59: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/59.jpg)
Viaje
![Page 60: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/60.jpg)
O que você quer ser quando
crescer?
![Page 61: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/61.jpg)
É possível ser programador e ganhar
dinheiro?
![Page 62: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/62.jpg)
SEJA FIEL A VOCÊ
![Page 63: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/63.jpg)
...e o segredo?
![Page 64: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/64.jpg)
Rust
![Page 65: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/65.jpg)
“Rust is a general purpose, multi-paradigm, compiled
programming language developed by Mozilla Research”
- Wikipedia
![Page 66: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/66.jpg)
Está sendo usada para criar o Servo, um novo browser
engine experimental
![Page 67: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/67.jpg)
![Page 68: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/68.jpg)
C++ não é apropriada para criar sistemas paralelos e seguros ao mesmo tempo
![Page 69: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/69.jpg)
Rust foi projetada para ter a mesma performance de C/C++ mas sem o mesmo
risco de bugs ou falhas de segurança
![Page 70: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/70.jpg)
fn main() { println(“hello world”);}
![Page 71: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/71.jpg)
use core::rand::RngUtil;
fn main() { for ["Alice", "Bob", "Carol"].each |&name| { do spawn { let v = rand::Rng().shuffle([1, 2, 3]); for v.each |&num| { print(fmt!("%s says: '%d'\n", name, num)) } } }}
![Page 72: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/72.jpg)
Type
Memory safety
Concurrency
Generics
Exception handling
Memory model
Compilation model
system static, nominal, linear, algebraic, locally inferred
no null or dangling pointers, no buffer overflows
lightweight tasks with message passing, no shared memory
type parameterization with type classes
unrecoverable unwinding with task isolation
optional task-local GC, safe pointer types with region analysis
ahead-of-time, C/C++ compatible
![Page 73: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/73.jpg)
let hi = "hi";let mut count = 0;
while count < 10 { io::println(fmt!("count: %?", count)); count += 1;}
Imutável por default
![Page 74: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/74.jpg)
fn angle(vector: (float, float)) -> float { let pi = float::consts::pi; match vector { (0f, y) if y < 0f => 1.5 * pi, (0f, y) => 0.5 * pi, (x, y) => float::atan(y / x) }}
Pattern Matching
![Page 75: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/75.jpg)
struct Point { x: float, y: float}
let mut mypoint = Point { x: 1.0, y: 1.0 };let origin = Point { x: 0.0, y: 0.0 };
mypoint.y += 1.0; // mypoint is mutable, and its fields as wellorigin.y += 1.0; // ERROR: assigning to immutable field
Structs
![Page 76: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/76.jpg)
fn line(a: int, b: int, x: int) -> int { a * x + b}
Funções
![Page 77: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/77.jpg)
Owning Pointers (~)
fn f() { let x: ~int = ~1024; // allocate space and initialize an int // on the heap println(fmt!("%d", *x)); } // <-- the memory that x pointed at is automatically freed here
let x = ~5;let z = x; // no new memory allocated, x can no longer be used
![Page 78: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/78.jpg)
fn foo() { let x: @int = @1024; // allocate space and initialize an int // on the heap bar(x); // pass it to `bar` println(fmt!("%d", *x)); // print it on the screen} // <-- the memory can be freed here
fn bar(x: @int) { let y: @int = x; // make a new smart pointer to `x`} // <-- despite `y` going out of scope,the memory is *not* freed here
Managed Pointers (@)
![Page 79: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/79.jpg)
fn dogshow() { let dogs: [~Dog * 3] = [ ~Dog { name: ~"Spot" }, ~Dog { name: ~"Fido" }, ~Dog { name: ~"Snoopy" }, ]; let winner: &Dog = dogs[1];// note use of `&` to form a reference for dogs.each |dog| { println(fmt!("Say hello to %s", dog.name)); } println(fmt!("And the winner is: %s!", winner.name));} // <-- all dogs destroyed here
Borrowed Pointers (&)
![Page 80: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/80.jpg)
Freezing
let mut x = 5;{ let y = &x; // x is now frozen, it cannot be modified}// x is now unfrozen again
![Page 81: 11 historias e 1 segredo](https://reader034.vdocuments.mx/reader034/viewer/2022042713/5471cc08b4af9fb90a8b4c8d/html5/thumbnails/81.jpg)
use core::task::spawn;
// Print something profound in a different task using a named functionfn print_message() { println("I am running in a different task!"); }spawn(print_message);
// Print something more profound in a different task using a lambda expressionspawn( || println("I am also running in a different task!") );
// The canonical way to spawn is using `do` notationdo spawn { println("I too am running in a different task!");}
Tasks