11 historias e 1 segredo

Preview:

DESCRIPTION

Curiosidades sobre linguagens de programação. Apresentação realizada no Startup Dev Day.

Citation preview

11 HISTÓRIAS E 1 SEGREDO

Luiz Borbahttp://borba.blog.br

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

O Pirulito

“All non-trivial abstractions, to some degree, are leaky.”

- Joel Spolsky

Linguagens de programação são leaky

abstractions.

Temos obrigação de conhecer o que a

linguagem que utilizamos faz por debaixo dos panos.

“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

Mergulhe

O bug existencial

“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

Qual a melhor forma de

aprender uma linguagem?

A Internet não esteve sempre

por aqui...

NÃO HÁ NADA DE ERRADO EM

LER LIVROS

Não programe por coincidência.

Aprenda

Eis o mistério da FÉ

|”May 2013” can’t be found|

”””May 2013”” can’t be found”

”\”May 2013\” can’t be found”

‘”May 2013” can\’t be found’

#include <stdio.h> main()[ int value = 1;  while(value<=3) [ printf(|Value is %d\n|, value); value++; ]  return array{1};]

Qual a origem do QWERTY?

O KALQ vinga?

Não há progresso sem desafios. Desafie o

“status quo”

Desafie

Tanto faz dá na cabeça quanto na

cabeça dá?

sort(lista) ou

lista.sort()

Reflita

Mister M

salvar(objeto) { broker.beginTrans(); broker.save(objeto); broker.commit();}

salvar(objeto) { broker.save(objeto);}

<transactional-methods> <method>salvar</method></transactional-methods>

@Transactionalsalvar(objeto) { broker.save(objeto);}

Aspect-Oriented Programming

(AOP) é bacana

Aspect-Oriented Programming

(AOP) é pura bosta

Esse livro é bom pra

caralho

...já esse livro é uma

merda

“Eu vou desdizerAquilo tudo que eu lhe disse antesEu prefiro serEssa metamorfose ambulanteDo que ter aquela velha opiniãoFormada sobre tudo”

Mude

Funcional ou Orientado a Objeto?

“Software is getting slower faster than hardware

becomes faster.”

- Niklaus Wirth

•Funções de alta ordem•Imutabilidade•Sem efeitos colaterais•Pattern Matching•Recursão•Currying•Lazy Evaluation•Continuations•Closures•Functional Composition•Referencial Transparency•Monads

Linguagens Multi-Paradigmáticas

Antene-se

Vietnã da computação

Object-Relational Mapping (ORM)

Linguagens Orientadas a Objetos

Banco de Dados Relacionais

NoSQL

mas nada é para sempre

Experimente

COBOL morreu

ou CONSERVADORA

Java é uma linguagem REVOLUCIONÁRIA

ENTERRE

A Pior Linguagem do Mundo

‘5’ + 3 = 53‘5’ - 2 = 2

‘’ == ‘0’ // false 0 == ‘’ // true

false == undefined // falsefalse == null // falsenull == undefined // true

Qual a linguagem?

ACEITE

Linguagem Verde

Consumo de energia é cada dia mais importante

Teremos linguagens onde poderemos medir o consumo do código

produzido?

Viaje

O que você quer ser quando

crescer?

É possível ser programador e ganhar

dinheiro?

SEJA FIEL A VOCÊ

...e o segredo?

Rust

“Rust is a general purpose, multi-paradigm, compiled

programming language developed by Mozilla Research”

- Wikipedia

Está sendo usada para criar o Servo, um novo browser

engine experimental

C++ não é apropriada para criar sistemas paralelos e seguros ao mesmo tempo

Rust foi projetada para ter a mesma performance de C/C++ mas sem o mesmo

risco de bugs ou falhas de segurança

fn main() { println(“hello world”);}

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)) } } }}

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

let hi = "hi";let mut count = 0;

while count < 10 { io::println(fmt!("count: %?", count)); count += 1;}

Imutável por default

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

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

fn line(a: int, b: int, x: int) -> int { a * x + b}

Funções

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

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 (@)

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 (&)

Freezing

let mut x = 5;{ let y = &x; // x is now frozen, it cannot be modified}// x is now unfrozen again

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

OBRIGADO!

Luiz Borbahttp://borba.blog.br