Dias do futuro presente da programação
-
Upload
luiz-borba -
Category
Technology
-
view
513 -
download
2
Transcript of Dias do futuro presente da programação
Java 8
C#
Swift
C
PHP
Python
Ruby
Javascript
Dart
Scala
Go
Clojure
Rust
Groovy
Erlang
Elixir
Coffeescript
C++
Objective-C
Haskell
F#
Julia
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
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
Vs
"Though my tip though for the long term replacement of javac is Scala. I'm very impressed with it! I can honestly say if someone had shown me the Programming in Scala book by by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I'd probably have never created Groovy.”
(James Strachan)
def fib(n: int) -> None: a, b = 0, 1 while a < n: print(a) a, b = b, a+b
def connect(r -> Stream, c -> Client) -> Fiber
<?hhclass MyClass { const int MyConst = 0; private string $x = ''; public function increment(int $x): int { $y = $x + 1; return $y; }}
/* @flow */function foo(x: string, y: number): string { return x.length * y;}foo('Hello', 42);
• Estamos vivendo um momento acentuado de divergência
• Tecnologias estabelecidas no mainstream estão sendo desafiadas
Dias do Futuro Presente da Programação
Luiz Borba http://borba.blog.br
Obrigado!