class: middle # Eat your **Greens** -
A philosophy for language design. --- class: middle ## **Hi** ### *name -* Peter Saxton ### *@internets -* CrowdHailer ### *works -* Experimenting in building better languages and tools at [eyg.run](https://eyg.run)
--- class: middle  ??? Look at the derogatory version. JavaScript Wat --- class: middle  ??? Look at the first simile. --- class: middle **Predictable**: - No undefined behaviour. - Never crash. - Same answer every time. **Useful**: - Build the required applications. - Be useful in several ways, *but which ones?* --- class: middle ## Scale matters  ??? Why I got started - End user programming - Own your own software --- class: middle ## Rating language **features** Existing languages have already had to make choices that affect predictability and usability. --- class: middle  ??? Everything is deterministic and Turing complete. Rust has Zero Cost abstractions. structural typing applies to slightly more things i.e databases --- class: middle ## Find a **philosophy**  --- class: middle ## Eat Your **Greens** > Beyond diet, "eat your greens" can symbolize doing things that are good for you, even if they're not immediately enjoyable or easy. --- class: middle ## Who likes **types**? - Static? - Strong? - Gradual? -- Did you apprecate them the first day you were coding? --- class: middle ## Type systems are a **vegetable** ```py print("Hello, World!") ``` What do types add to this Python program? --- class: middle ## Types make things **harder** - Structured IO - JSON deserialization - SQL interop - Object creation - Foreign function interfaces -- Types are great for compounding value over time. --- class: middle  --- class: middle ## Gall's Law > A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works and cannot be patched up to make it work. You have to start over with a working simple system *The Systems Bible: The Beginner's Guide to Systems Large and Small* --- class: middle  --- class: middle  ??? WASM --- class: middle ## EYG the **Basics** - Statically typed - Structurally typed - Sound type inference - Algebraic effects - Closure serialization - Strongly typed REPL - Inline references (for another time) - Minimal AST (for another time) *I'll be talking about the other two later in the year.* --- class: middle ### EYG is **statically** typed ??? embed code and see the type --- class: middle ### EYG is **structurally** typed --- class: middle ### EYG is **soundly** typed This extends to effects. --- class: middle EYG is a **browser native** runtime. --- class: middle ## **Algebraic** effects An abstraction to represent all impure behaviour including: - Input and output operations - Non determinism i.e. random - Time - Exceptions - Concurrency - Mutability --- class: middle ### What is a **function**? > A function is the relation between a set of inputs and a set of outputs, so that every set of inputs has exactly one output.  --- class: middle Functions compose.  Functions can be values.  --- class: middle ### Side **effects** and side **causes**  --  --- class: middle Side effects depend on the whole world.  --- class: middle A quick aside for **continuations**  *The best resource explaining continuations is. [Delimited Continuations, Demystified by Alexis King](https://www.youtube.com/watch?v=TE48LsgVlIU)* --- class: middle Programs **perform** effects with the remaining program captured as a continuation.  --- class: middle Runtimes **resume** programs by calling the stored continuation  --- class: middle Effects can be inferred
--- class: middle --- class: middle ## **Closure serialization** > The process of converting a closure into a format that can be stored or transmitted. A closure is a function along with its captured environment. --- class: middle Serialized code can be handled, i.e. copy pasted.
--- class: middle Serialized code can be transpiled --- class: middle Is closure serialization possible in other languages? - short answer: yes - long answer: ermmmmmmmmmmmmmmmmmmmm... --- class: middle  --- class: middle ### Why do closure serialization  ??? We already do but the packages are really inefficient Kill build scripts Sending types through time and space --- class: middle --- class: middle --- class: middle ### The **first** environment > A read-eval-print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user --- class: middle ### Typing a **REPL** - Types are refined - The result of `eval` can be typed - Type checking is optional ??? {"0":"a","f":{"0":"b","l":"eval"},"a":{"0":"a","f":{"0":"a","f":{"0":"c"},"a":{"0":"a","f":{"0":"t","l":"Let"},"a":{"0":"s","v":"x"}}},"a":{"0":"a","f":{"0":"a","f":{"0":"c"},"a":{"0":"a","f":{"0":"t","l":"Integer"},"a":{"0":"i","v":100}}},"a":{"0":"a","f":{"0":"a","f":{"0":"c"},"a":{"0":"a","f":{"0":"t","l":"Variable"},"a":{"0":"s","v":"x"}}},"a":{"0":"ta"}}}}} --- class: middle
--- class: middle ## **Structural** or **Nominal** typing? Java ```java class Person { public name: string; } ``` TypeScript ```ts interface Person { name: string; } ``` --- class: middle ## **Structural** or **Nominal** typing? - Structural types are universal - Nominal types have a bounded validity, *usually a single compilation.* - Nominal typing requires type declarations --- class: middle ## Eat your **Greens** A simple type system leveraged everywhere is more interesting than a complex one limited to the application. - Development environments - Build servers - CI/CD - codegen - Backend/frontend - Service workers - Background queues - Infra provisioning - Database queries A single typed program should extend over the whole stack --- class: middle # One more thing Code **reloading** .. if we have time. --- class: middle # Questions? - [eyg.run](https://eyg.run) - Join the mailing list --- class: middle There is more coming ... 