1 of 111

Bending the curve

A personal tutor at your fingertips

Esteban Küber

he / him

@ekuber

@estebank

2 of 111

3 of 111

Bending the curve

A personal tutor at your fingertips

Esteban Küber

he / him

@ekuber

@estebank

4 of 111

Bending the curve

A personal tutor at your fingertips

Esteban Küber

he / him

@ekuber

@estebank

5 of 111

Bending the curve

So you want to write a programming language

A personal tutor at your fingertips

that people use

Esteban Küber

he / him

@ekuber

@estebank

6 of 111

7 of 111

8 of 111

9 of 111

10 of 111

  • Map
  • Explore
  • Travel guide/neighbour/friend

11 of 111

12 of 111

  • Map
  • Explore
  • Travel guide/neighbour/friend

13 of 111

Explore

Mental map

14 of 111

[pizza place pic next to red house]

15 of 111

  • Map
  • Explore
  • Travel guide/neighbour/friend

16 of 111

[fancy pizza shop]

17 of 111

[city bus pic in the background with travel card in the foreground]

18 of 111

[intentionally left blank]

19 of 111

20 of 111

21 of 111

[pizza place pic next to red house]

[CODE]

22 of 111

23 of 111

24 of 111

25 of 111

Why design a

programming language?

26 of 111

Why design a

programming language?

Objectives

27 of 111

[copyrighted character missing]

28 of 111

Objectives

  • Runtime and design flexibility
    • Restrict performance
  • Final execution speed
    • Slower compilation speed
    • Restrict dynamism
  • Compilation speed
    • Restrict features and ergonomics

29 of 111

[crate and code showing file split]

30 of 111

31 of 111

Don’t try to read this 🙃

32 of 111

33 of 111

Objectives

  • Runtime and design flexibility
    • Restrict performance
  • Final execution speed
    • Slower compilation speed
    • Restrict dynamism
  • Compilation speed
    • Restrict features and ergonomics

34 of 111

Objectives

  • Runtime and design flexibility
    • Restrict performance
  • Final execution speed
    • Slower compilation speed
    • Restrict dynamism
  • Compilation speed
    • Restrict features and ergonomics
  • Learnability

35 of 111

Language design

  • Syntax / Grammar
  • Semantics
  • Features

36 of 111

37 of 111

Type[ParamA, ParamB]

Type<ParamA, ParamB>

38 of 111

Type[ParamA, ParamB]

Type<ParamA, ParamB>

Type::<ParamA, ParamB>

39 of 111

null

40 of 111

  • Borrow checker
  • Non-representability of null
  • Immutability by default
  • etc

41 of 111

42 of 111

Steve Klabnik

43 of 111

Don’t try to read this 🙃

44 of 111

45 of 111

46 of 111

47 of 111

Arc<RefCell<T>>

48 of 111

49 of 111

50 of 111

51 of 111

52 of 111

TL;DR:

  • “Borrow” liberally from other languages
    • Make sure it fits with the rest of your language

53 of 111

54 of 111

55 of 111

56 of 111

Many things affect how easy to learn a language

  • Libraries
  • Documentation
  • Tooling
  • Platform support
  • Community

57 of 111

58 of 111

💸

59 of 111

Many things affect how easy to learn a language

  • Libraries
  • Documentation
  • Tooling
  • Platform support
  • Community

60 of 111

Many things affect how easy to learn a language

  • Libraries
  • Documentation
  • Tooling
    • Code formatters
    • Linters
    • Debuggers
    • Package managers
    • IDEs
  • Platform support
  • Community

61 of 111

62 of 111

63 of 111

64 of 111

65 of 111

66 of 111

“Introducing a new tool to aid your learning”

67 of 111

“Introducing a new tool to aid your learning”

Tuto.rs

68 of 111

“Introducing a new tool to aid your learning”

Tuto.rs

69 of 111

“Introducing a new tool to aid your learning”

  • Optional
  • Undiscoverable
  • “Second child” syndrome

Tuto.rs

70 of 111

71 of 111

72 of 111

[citation needed]

73 of 111

74 of 111

Types of errors

  • Parse errors

75 of 111

[Extra > in path]

76 of 111

77 of 111

78 of 111

Type ascription

  • Nightly only
  • Annotates any expression with a type
  • <expr>: <type>
    • Looks like let binding with types, function argument bindings and struct field bindings
  • Extremely easy to make a typo that looks like it

79 of 111

80 of 111

Types of errors

  • Parse errors
  • “Negative space” boundary errors

81 of 111

82 of 111

[Cartesian space IN/OUT b&w]

[Cartesian space IN/OUT b&shades of grey]

83 of 111

84 of 111

the tutor needs context,�knowledge of the tutee

85 of 111

the tutor needs context,�knowledge of the tutee

86 of 111

the tutor needs context,�knowledge of the tutee

and it has it

87 of 111

[contextless error that we already handle]

88 of 111

[“oracle” diagnostics paper front or conclussions page]

89 of 111

&str vs String

String

h

e

l

l

o

,

w

o

r

l

d

h

e

l

l

o

,

w

o

r

l

d

len

ptr

12

h

e

l

l

o

,

w

o

r

l

d

capacity

len

ptr

12

12

&str

str

this is in the heap!

std::string::

90 of 111

&str vs String

h

e

l

l

o

,

w

o

r

l

d

this is in the heap!

String

capacity

len

ptr

12

12

std::string::

91 of 111

&str vs String

len

ptr

2

h

e

l

l

o

,

w

o

r

l

d

&str

&str

this is in the heap!

len

ptr

5

&str

len

ptr

12

String

capacity

len

ptr

12

12

std::string::

92 of 111

&str vs String

h

e

l

l

o

,

w

o

r

l

d

h

e

l

l

o

,

w

o

r

l

d

len

ptr

12

h

e

l

l

o

,

w

o

r

l

d

&str

str

this is in the heap!

String

capacity

len

ptr

12

12

std::string::

93 of 111

&str vs String

h

e

l

l

o

,

w

o

r

l

d

h

e

l

l

o

,

w

o

r

l

d

len

ptr

12

h

e

l

l

o

,

w

o

r

l

d

&str

str

this is in the heap!

Vec<u8>

Vec<char>

Utf-8�Utf-16

utf-32

&String

impl Deref<Target=&str> for &String

OsString

Path�\0

Sized

?Sized

‘a

String

capacity

len

ptr

12

12

std::string::

94 of 111

&str vs String

h

e

l

l

o

,

w

o

r

l

d

h

e

l

l

o

,

w

o

r

l

d

len

ptr

12

h

e

l

l

o

,

w

o

r

l

d

&str

str

this is in the heap!

If you’re coming from Java,

this is a StringBuffer

If you’re coming from C,

this is string literal in your binary

If you’re coming from C++,

this is string_view

String

capacity

len

ptr

12

12

std::string::

95 of 111

96 of 111

97 of 111

Don’t try to read this 🙃

98 of 111

99 of 111

Don’t try to read this 🙃

100 of 111

101 of 111

Don’t try to read this 🙃

102 of 111

103 of 111

104 of 111

105 of 111

106 of 111

107 of 111

108 of 111

[XML vs JSON: simplicity of the language has a benefit]

109 of 111

110 of 111

111 of 111

To summarize

  • To make your language easy to use, steal from others
  • There are things beyond “the language” that makes people learn it and stick around
  • Your compiler can and should do more
  • Demand better from your tools