48
c 2013 Andrei Alexandrescu 1 / 46 Quo Vadis? Andrei Alexandrescu Research Scientist Facebook

Andrei Alexandrescu - DConfdconf.org/2013/talks/alexandrescu.pdf · “Meh” features c 2013 Andrei Alexandrescu 4 / 46 • @property • synchronized’s interplay with shared •

  • Upload
    dokhanh

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

c© 2013 Andrei Alexandrescu 1 / 46

Quo Vadis?

Andrei Alexandrescu

Research Scientist

Facebook

aspirations

c© 2013 Andrei Alexandrescu 2 / 46

Principled & Practical

c© 2013 Andrei Alexandrescu 3 / 46

• Slices

• Approach to modularity

• Support for generic programming

• Error handling done right: scope

• Qualifiers

• Approach to @safety

“Meh” features

c© 2013 Andrei Alexandrescu 4 / 46

• @property

• synchronized’s interplay with shared

• delete

• foreach_reverse

• qualified postblit

Features that don’t exist (but work)

c© 2013 Andrei Alexandrescu 5 / 46

• Attribute inference

• Compile-Time Function Evaluation

• Scoped imports

• Value Range Propagation (no-pain conversions)

• Relaxed purity

Functional Factorial (yawn)

c© 2013 Andrei Alexandrescu 6 / 46

ulong factorial(uint n) {

return n <= 1 ? 1 : n * factorial(n - 1);

}

• It’s PSPACE!

• Somebody should do hard time for this

However, it’s pure

c© 2013 Andrei Alexandrescu 7 / 46

pure ulong factorial(uint n) {

return n <= 1 ? 1 : n * factorial(n - 1);

}

• Pure is good

Functional Factorial, Fixed

c© 2013 Andrei Alexandrescu 8 / 46

pure ulong factorial(uint n) {

ulong crutch(uint n, ulong result) {

return n <= 1

? result

: crutch(n - 1, n * result);

}

return crutch(n, 1);

}

• Threads state through as parameters

• You know what? I don’t care for it

Honest Factorial

c© 2013 Andrei Alexandrescu 9 / 46

ulong factorial(uint n) {

ulong result = 1;

for (uint i = 2; i <= n; ++i) {

result *= i;

}

return result;

}

• But no longer pure!

• Well allow me to retort

Pure is as pure does

c© 2013 Andrei Alexandrescu 11 / 46

• “Pure functions always return the same result for the

same arguments”

• No reading and writing of global variables

◦ (Global immutables okay)

• No calling of impure functions

• Who said anything about local, transient state inside the

function?

Transitive State

c© 2013 Andrei Alexandrescu 12 / 46

pure void reverse(T)(T[] a) {

foreach (i; 0 .. data.length / 2) {

swap(data[i], data[$ - i - 1]);

}

}

• Possibility: disallow

• More useful: relaxed rule

• Operate with transitive closure of state reachable

through parameter

• Not functional pure, but an interesting superset

• No need for another annotation, it’s all in the signature!

User-defined types

c© 2013 Andrei Alexandrescu 13 / 46

pure BigInt factorial(uint n) {

BigInt result = 1;

foreach (i; 1 .. n + 1) {

result *= i;

}

return result;

}

• Works, but not in released version

• Not all stdlib “purified” yet

Aftermath

c© 2013 Andrei Alexandrescu 14 / 46

• If parameters reach mutable state:

◦ Relaxed pure—no globals, no I/O, no impure calls

• If parameters can’t reach mutable state:

◦ “Haskell-grade” observed purity

◦ Yet imperative implementation possible

◦ As long as it’s local only

c© 2013 Andrei Alexandrescu 15 / 46

comprehensive != big

c© 2013 Andrei Alexandrescu 16 / 46

comprehensive != perfect

Allocators

c© 2013 Andrei Alexandrescu 17 / 46

• We want a comprehensive design

• (not a big/complex/perfect one)

• It should work

Allocation Archetypes

c© 2013 Andrei Alexandrescu 18 / 46

• Garbage collected

• Garbage collected + free

• malloc-based

• Region-based

Composability

c© 2013 Andrei Alexandrescu 19 / 46

• Allocators must stack efficiently

• Example: freelist over region

• (Related work: HeapLayers)

Safety

c© 2013 Andrei Alexandrescu 20 / 46

• Some allocators safe (GC)

• Some unsafe (malloc)

• Some can be made safe (regions)

vision

c© 2013 Andrei Alexandrescu 22 / 46

Fable

c© 2013 Andrei Alexandrescu 23 / 46

Neophyte: “What should I do to be a

better person?”

Fable

c© 2013 Andrei Alexandrescu 24 / 46

Guru: “Do what a good person does.”

Applied

c© 2013 Andrei Alexandrescu 25 / 46

We: “What should we do to scale to 1M

users?”

That means

c© 2013 Andrei Alexandrescu 26 / 46

• Stability

• Quality, quality, quality

• Expanding platform base

• Operational professionalism

c© 2013 Andrei Alexandrescu 27 / 46

Stability

c© 2013 Andrei Alexandrescu 28 / 46

Quality

c© 2013 Andrei Alexandrescu 29 / 46

Expanding platform base

c© 2013 Andrei Alexandrescu 30 / 46

Operational professionalism

Two-pronged Approach

c© 2013 Andrei Alexandrescu 31 / 46

• Play into strengths

• Improve on weaknesses

Strategic strengths

c© 2013 Andrei Alexandrescu 32 / 46

• Active community

• Incredibly fast turnaround

• Compile-Time Function Execution

• Domain-Specific Embedded Languages

• Libraries

• Ranges and algorithms; bulk processing

• Concurrency and parallelism

• One-stop shop for getting work done

Weaknesses

c© 2013 Andrei Alexandrescu 34 / 46

• Quality of implementation

• Formal definition

• Available libraries; package management

• Ecosystem tools

• Documentation and tutorials

• Process and roadmap

people

c© 2013 Andrei Alexandrescu 35 / 46

c© 2013 Andrei Alexandrescu 38 / 46

Make DConf an annual

rallying point

The People Connection

c© 2013 Andrei Alexandrescu 39 / 46

• Any community needs nurturing

• Focus on increasing participation

• Welcoming new community members

• D Summer of Code (DSOC)?

• forum.dlang.org dedicated discussions place

“D is totally useless”

c© 2013 Andrei Alexandrescu 40 / 46

“When i tried to rewrite example to D, i was

shocked. [...] Dlang is a toy in outer space. [...]

One can only to write a+b program in schools in it.

Now I understand, that’s why D doesn’t have

popularity after 10+ years of existence.”

– Temtaime (tinyurl.com/d-useless)

On second thought. . .

c© 2013 Andrei Alexandrescu 41 / 46

“I investigated a little more in it. Thanks to Jack

Applegame, we made a copy of gl/gl.h and

opengl32.lib for DMD.

(http://acomirei.ru/u/gl.d,

http://acomirei.ru/u/opengl32.lib). I

hope it will be included in DMD, now it’s first draft

of our work.”

– Temtaime

c© 2013 Andrei Alexandrescu 42 / 46

Community

c© 2013 Andrei Alexandrescu 43 / 46

Academics

c© 2013 Andrei Alexandrescu 44 / 46

Corporate

Summary

c© 2013 Andrei Alexandrescu 45 / 46

Summary

c© 2013 Andrei Alexandrescu 46 / 46

aspirations

Summary

c© 2013 Andrei Alexandrescu 46 / 46

aspirations

vision

Summary

c© 2013 Andrei Alexandrescu 46 / 46

aspirations

vision

people