Slide 1

Slide 1 text

Incredibly Strange Programming Languages! Craig Stuntz Slides are already online

Slide 2

Slide 2 text

Incredibly Strange Programming Languages! Craig Stuntz https://speakerdeck.com/craigstuntz Slides are already online

Slide 3

Slide 3 text

• Today, many languages look mostly the same • “Mainstream” languages will change • There are specific reasons why they change • Just learning about certain languages can help you learn how to write interesting code Spoiler alert! I’m going to give you a whirlwind tour of more than ten different languages. You probably won’t walk out of here productive in all of them. That’s not my goal. Learning interesting languages give you insight into the code you may be writing in 5-10 years. Also, I’d like to suggest that learning languages for their own sake can help you learn new ways of solving problems in any language

Slide 4

Slide 4 text

My challenge to you, when you leave this talk, is to choose at least one of the languages you see here which happens to tickle your fancy, and Google it. (Unless it’s P#, which is totally un-Googleable, but I’ll give you the link for that.) Picking one really odd PL you’ve never heard of and diving into it for an evening will help you understand computation in a new light.

Slide 5

Slide 5 text

My challenge to you, when you leave this talk, is to choose at least one of the languages you see here which happens to tickle your fancy, and Google it. (Unless it’s P#, which is totally un-Googleable, but I’ll give you the link for that.) Picking one really odd PL you’ve never heard of and diving into it for an evening will help you understand computation in a new light.

Slide 6

Slide 6 text

https://upload.wikimedia.org/wikipedia/commons/0/06/Human_computers_-_Dryden.jpg And that’s what this is really about: Understanding computation, via the languages we use to communicate our thoughts about it. Human computers in the National Advisory Committee for Aeronautics (NACA) High Speed Flight Station "Computer Room", Dryden Flight Research Center Facilities, 1949 Computer science computing on a computer

Slide 7

Slide 7 text

http://jsforcats.com/ First, though, let’s ask the obvious question: Why bother? Today, you can call yourself a “full stack” developer if you know only JavaScript. Why bother looking at any other language? Didn’t Turing tell us they’re all equivalent anyway?

Slide 8

Slide 8 text

https://www.flickr.com/photos/lenore-m/2514975647/ Languages are tools we use to express the solution to problems, and sometimes it’s helpful to have more than one tool.

Slide 9

Slide 9 text

https://commons.wikimedia.org/wiki/File:Kitchen-knife-santoku-form.jpg Some people would say that you only need a good knife and a cast iron pan to cook anything.

Slide 10

Slide 10 text

Some people will say that you can cook anything with a Ronco Veg-O-Matic

Slide 11

Slide 11 text

https://www.flickr.com/photos/40726522@N02/9385054093/ You can make delicious hummus using only a pot and a hammer, but if you want to make it from dried chick peas in under an hour, (click) you need a pressure cooker. Using the right tools does matter!

Slide 12

Slide 12 text

https://www.flickr.com/photos/40726522@N02/9385054093/ You can make delicious hummus using only a pot and a hammer, but if you want to make it from dried chick peas in under an hour, (click) you need a pressure cooker. Using the right tools does matter!

Slide 13

Slide 13 text

Also, we will probably do things differently in the future. In programming, “the future” isn’t the year 2364, it’s next decade.

Slide 14

Slide 14 text

But don’t all languages mostly work the same anyway?

Slide 15

Slide 15 text

var query = from total in Enumerable.Range(0,100).Reverse() select (total > 0) ? string.Format("{0} bottles of beer on the wall\n{0} bottles of beer\nTake one down, pass it around", total) : string.Format("{0} bottles left", total); foreach (var item in query) { Console.WriteLine(item); } http://rosettacode.org/wiki/99_Bottles_of_Beer If I want to print the lyrics to “99 bottles of beer on the wall,” I could write a program in C#

Slide 16

Slide 16 text

plural = 's' 99.downto(1) do |i| puts "#{i} bottle#{plural} of beer on the wall," puts "#{i} bottle#{plural} of beer" puts "Take one down, pass it around!" plural = '' if i - 1 == 1 if i > 1 puts "#{i-1} bottle#{plural} of beer on the wall!" puts else puts "No more bottles of beer on the wall!" end end http://rosettacode.org/wiki/99_Bottles_of_Beer Ruby

Slide 17

Slide 17 text

var beer = 99; while (beer > 0) { var verse = [ beer + " bottles of beer on the wall,", beer + " bottles of beer!", "Take one down, pass it around", (beer - 1) + " bottles of beer on the wall!" ].join("\n"); console.log(verse); beer--; } http://rosettacode.org/wiki/99_Bottles_of_Beer JavaScript

Slide 18

Slide 18 text

"#>,_ "#Beer Song>,_ #include using namespace std; int main(){ for( int b=-1; b<99; cout $% '\n') for ( int w=0; w<3; cout $% ".\n"){ if (w==2) cout $% (( b--) ?"Take one dow" "n and pass it arou" "nd":"Go to the sto" "re and buy some mo" "re"); if (b<0) b=99 ; do{ if (w) cout $% ", "; if (b) cout $% b; else cout $% ( (w) ? 'n' : 'N') $% "o more"; cout $% " bottle" ; if (b&'1) cout $% 's' ; cout $% " of beer"; if (w&'1) cout $% " on th" "e wall" ;} while (!w++);} return 0 ; } "# "# by barrym 2011-05-01 "# no bottles were harmed in the "# making of this program!!! http://rosettacode.org/wiki/99_Bottles_of_Beer C++

Slide 19

Slide 19 text

def sing(b, end): print(b or 'No more','bottle'+('s' if b-1 else ''), end) for i in range(99, 0, -1): sing(i, 'of beer on the wall,') sing(i, 'of beer,') print('Take one down, pass it around,') sing(i-1, 'of beer on the wall.\n') http://rosettacode.org/wiki/99_Bottles_of_Beer Python And they kinda all look the same. Why do so many programming languages all look so similar?

Slide 20

Slide 20 text

https://www.quora.com/Are-all-programming-languages-based-on-C There are may families of programming languages. Don’t worry about trying to see the details here; just take my word there are lots. (click) Point is, mainstream development today uses a super-limited branch of this big chart.

Slide 21

Slide 21 text

https://www.quora.com/Are-all-programming-languages-based-on-C There are may families of programming languages. Don’t worry about trying to see the details here; just take my word there are lots. (click) Point is, mainstream development today uses a super-limited branch of this big chart.

Slide 22

Slide 22 text

Lineage 1960 1970 1980 ALGOL LISP APL ML Prolog ALGOL BCPL C C++ 1990 2000 C# Java JavaScript Ruby ML OCaml F# 2010 Swift LISP Scheme Clojure APL J SASL SASL Miranda Haskell Prolog Erlang Elixir PHP Here is a simpler, some would say vastly oversimplified, representation. What does this tell us? ALGOL-based languages really common. You can consider yourself a polyglot knowing only ALGOL family languages, even if you’ve used ALGOL! For many of us, our day jobs are 100% in this pool. 1972 was a very interesting year for PLs! C, ML, Prolog, and SASL 1995 brought us Java, JavaScript, PHP, Ruby, and OCaml Recently, we’ve seen a resurgence of ML languages: F#, Swift, Elm Why is that? Why do these waves exist? Will there be another fundamental change in how we’ll program in the future?

Slide 23

Slide 23 text

Mainstream Programming Paradigm Shifts 1950s “Beats machine code” (Assembler) 1960s - mid-1970s “Beats assembler” (FORTRAN, COBOL) mid-1970s - mid-1990s “The Great Leap Backwards” (C, C++) mid-1990s - today? “Safer, Web” (Java, JavaScript) Mainstream programmers don't change languages very often, but it does happen, and it is instructive to consider the reasons why. This chart is a vast overgeneralization, but it's a starting point for discussion. 1950s used ASM because compilers not invented. 60s-70s growth of real applications + maintenance. In the late 70s we moved towards smaller computers with less processing power and storage than your WiFi light bulbs today. Language capabilities similarly downscaled during this era. 1990s moved to safer languages for wrong reasons (worried about leaks; should have worried about security, but OK….)

Slide 24

Slide 24 text

Change is coming • Quantum computing • Distributed systems • End of Moore’s Law - Storage faster than CPU • Safety and privacy We will change again. JavaScript is not the perfect language which we will use until the end of time. I’m not sure what the mainstream language of 2025 will be, but I’m going to show you some features JS will probably never have, and speculate on what we might see in the future.

Slide 25

Slide 25 text

Is This Some Kind of Joke? HAI 1.2 CAN HAS STDIO? VISIBLE "HAI WORLD!!!1!" KTHXBYE http://lolcode.org/ When you heard the title,"Incredibly Strange Programming Languages," you might have thought about joke languages. Some of them are pretty funny! The example on the side is a real programming language called LOLCode. I got a good laugh out of this, but it didn't really make me think about programming any differently.

Slide 26

Slide 26 text

– Harold Abelson and Gerald Jay Sussman with Julie Sussman Structure and Interpretation of Computer Programs “Establishing new languages is a powerful strategy for controlling complexity in engineering design; we can often enhance our ability to deal with a complex problem by adopting a new language that enables us to describe (and hence to think about) the problem in a different way…” I'm after something different. I want to find languages which teach me new approaches to common problems which I can use in my day-to-day work, even if I am not implementing my code in that language.

Slide 27

Slide 27 text

What’s In a Name? Does it matter what you call your language? Does it matter what the reserved words are? If Ruby were instead called “Yukihiro”, would that change anything? Maybe! You see, the answer possibly depends on the character set used.

Slide 28

Slide 28 text

Console.WriteLine("Hello, World!"); There are a lot of assumptions baked into our programming languages, tools, and libraries. One of them is that we will write code mostly in ASCII, left to right text.

Slide 29

Slide 29 text

Console.WriteLine("֦অӮኴ"); C# has better Unicode support than many languages, but the language itself and the libraries are still ASCII.

Slide 30

Slide 30 text

var hello = "Hello, World!".Substring(0, 5); Far worse, though, is that we program based on assumptions which are simply false, like the notion that characters and Unicode code units and code points are the same thing. But we can get away with that, right, because our software is mostly used by English speakers, or, well, at least not Klingons, right?

Slide 31

Slide 31 text

http://www.unicode.org/reports/tr51/index.html#Emoji_ZWJ_Sequences Sorry. Emoji are ruining everything. (click) So we’re just going to have to live with the realities of Unicode. It is not safe to presume code points are characters. It is not safe to presume encoding or text direction. It would be helpful to consider what happens when you abandon these assumptions.

Slide 32

Slide 32 text

http://www.unicode.org/reports/tr51/index.html#Emoji_ZWJ_Sequences " = U+1F1E8 REGIONAL INDICATOR SYMBOL LETTER C U+1F1E6 REGIONAL INDICATOR SYMBOL LETTER A Sorry. Emoji are ruining everything. (click) So we’re just going to have to live with the realities of Unicode. It is not safe to presume code points are characters. It is not safe to presume encoding or text direction. It would be helpful to consider what happens when you abandon these assumptions.

Slide 33

Slide 33 text

بلق http://nas.sr/%D9%82%D9%84%D8%A8/ I want to tell you about a language called ‘alb. If you speak Arabic, please come up to the podium after the presentation and accept my apologies for my mispronunciations. بلق means Heart, but is actually an Arabic recursive acronym for ةجمرب ةغل :بلق ‘alb: lughat barmajeh meaning Heart: A Programming Language. Designed by Ramsey Nasser Roughly half a billion people speak Arabic. Not quite as many as English, but still pretty common. So why not have a programming language in Arabic? What could possibly go wrong?

Slide 34

Slide 34 text

A whole lot, it turns out! There’s a strong technical bias in our tooling which favors left-to-right, ASCII code.

Slide 35

Slide 35 text

At least the web is Unicode. Oh, wait.

Slide 36

Slide 36 text

Git diff doesn’t work so well.

Slide 37

Slide 37 text

You know what else won’t work? Your terminal. Any text editors you might try. (RTL handled incorrectly in Atom, Sublime, others)

Slide 38

Slide 38 text

http://nas.sr/%D9%82%D9%84%D8%A8/ “The Arabs have a rich tradition of calligraphy and poetry attached to the text of their language. Computer scientists have a strangely similar relationship with the text that they write as well, and that overlap was something I became fascinated with.” -Ramsey Nasser Ramsey said at this point it became an art project to try to continue, so he ran with it! Kufic-style tile mosaic of بلق implementation of Fibonacci sequence

Slide 39

Slide 39 text

Mainstream languages depend on punctuation which doesn’t really work in Arabic. Curly braces, semicolons, commas, and the like would have to go. But () are OK, so he used LISP syntax. I’ve added the translations. Ramsey’s REPL is strictly Arabic. Note the ligatures in the name. Also the Arabic numerals. Program to compute Fibonacci numbers print Fibonacci 10 => 55 The language itself is less surprising than the fact that he got it to work at all given such adversarial tooling.

Slide 40

Slide 40 text

Mainstream languages depend on punctuation which doesn’t really work in Arabic. Curly braces, semicolons, commas, and the like would have to go. But () are OK, so he used LISP syntax. I’ve added the translations. Ramsey’s REPL is strictly Arabic. Note the ligatures in the name. Also the Arabic numerals. Program to compute Fibonacci numbers print Fibonacci 10 => 55 The language itself is less surprising than the fact that he got it to work at all given such adversarial tooling.

Slide 41

Slide 41 text

Mainstream languages depend on punctuation which doesn’t really work in Arabic. Curly braces, semicolons, commas, and the like would have to go. But () are OK, so he used LISP syntax. I’ve added the translations. Ramsey’s REPL is strictly Arabic. Note the ligatures in the name. Also the Arabic numerals. Program to compute Fibonacci numbers print Fibonacci 10 => 55 The language itself is less surprising than the fact that he got it to work at all given such adversarial tooling.

Slide 42

Slide 42 text

http://nas.sr/بلق/ You can learn more at Ramsey’s site. Not easy to type if you don’t have an Arabic keyboard installed.

Slide 43

Slide 43 text

Is Turing Completeness a Good Idea? Another assumption you hear a lot is that languages are all equivalent due to Turing completeness. Turing completeness is widely misunderstood. A Turing complete language can implement any function whose values can be computed by an algorithm, a series of steps. Nearly all programming languages are Turing complete, but some language designers have experimented with more limited languages. Why would you ever want that?

Slide 44

Slide 44 text

“You theorized a machine that could solve any problem. It didn’t just do one thing; it did everything.” (fictional) Joan Clarke to (fictional) Alan Turing The Imitation Game (2014) http://theimitationgamemovie.com/#blog/104786411214 A Misunderstanding Here’s a quote from a Hollywood movie. It is fiction. The real Joan Clarke had a double first degree in math from Cambridge and would never say this. Turing never claimed his machines could solve any problem. To the contrary, his purpose was to prove that problems existed which they could not solve!

Slide 45

Slide 45 text

BlooP FlooP GlooP I’m going to tell you about three languages, BlooP, FlooP, and GlooP. BlooP is not Turing complete. It is less powerful than the languages you use every day. The other two add some additional features for more power. All three come from Douglas Hofstadter’s book Gödel Escher Bach

Slide 46

Slide 46 text

The book became kinda popular. Apparently moreso than Kurt Gödel himself. Anyway, I’m going to talk about chapter XIII

Slide 47

Slide 47 text

BlooP DEFINE PROCEDURE “PRIME?” [N]: BLOCK 0: BEGIN IF N = 0 THEN: QUIT BLOCK O; CELL(0) (() 2; LOOP AT MOST MINUS [N,2] TIMES: BLOCK 1: BEGIN IF REMAINDER [N,CELL(0)] = 0, THEN: QUIT BLOCK 0; CELL(0) (() CELL(0) + 1; BLOCK 1: END; OUTPUT (() YES; BLOCK 0: END. BlooP looks like a standard 1970s PL until you look closely at its loops. This function is a predicate which determines if the argument is prime. The interesting thing about the looping construct in BlooP is you can’t have a loop without a bound. This turns out to be the only meaningful restriction on the language. There are really no other surprises. Important point is we were able to find an algorithm which works with a bounded loop. There exist algorithms which can’t be expressed with bounded loops. Notably, we should be able to write a universal mahcine, a program which evaluates BlooP source code, and we can, but not in BlooP!

Slide 48

Slide 48 text

FlooP MU-LOOP: BLOCK n: BEGIN . . . BLOCK n: END. FlooP adds exactly one additional feature: an unbounded loop. Hence, it’s a more powerful language. This power comes at a high price. Not all FlooP programs terminate with a sensible result. Some loop forever. But! You can implement a program which evaluates all BlooP code. That’s really useful! But you cannot write a program in FlooP which determines if an arbitrary FlooP program will terminate; Turing and Alonzo Church proved that. So we’ve solved one problem and created another!

Slide 49

Slide 49 text

GlooP So we need a more powerful language to determine if FlooP programs terminate. GlooP is a language which is more powerful than FlooP. This slide is blank because it doesn’t — and can’t — exist. Hofstadter points out that a language like this would be magical. You could prove a number of open problems in mathematics by implementing them in FlooP and then using GlooP to see if they terminate for all inputs. So GlooP is impossible.

Slide 50

Slide 50 text

Is obvious why you might want a Turing complete language. With such a language, you can implement any algorithm. Why would you want a Turing complete language? In some domains, decidability is a feature. For example, the C# type system is not Turing complete, which means that the C# compiler can always give you an answer as to whether or not your code typechecks. There should never be a time when the compiler runs forever and never returns an answer. This is not true of all programming languages! Turing complete features in PLs include the Scala type system and C++ templates.

Slide 51

Slide 51 text

Another example is in cryptography, where you want successful and unsuccessful decryption to take precisely the same amount of time to avoid insecurity via timing oracles. This is hard and there are entire books on the subject, but one of the keys is choosing a subset of your language which leads to deterministic execution paths.

Slide 52

Slide 52 text

Client Server Data Cyphertext Result Cyphertext Computation Data Plaintext Result Plaintext Another example is homomorphic encryption, which allows doing computations on encrypted data. You give your encrypted financial data to a cloud service, and it computes your encrypted tax return — without ever decrypting your cyphertext! Of course there are restrictions, because you can’t branch based on a value in data, since it’s encrypted. The limitations end up looking a lot like BlooP, so it’s really useful to know how to do useful work in that world.

Slide 53

Slide 53 text

Best place to learn more…

Slide 54

Slide 54 text

Does Order of Operation Matter? When we look at source code, we can generally figure out in which order things happen. Async features of some languages make this a bit harder, but at least within a method it should be clear what’s going on, right? Maybe.

Slide 55

Slide 55 text

https://www.flickr.com/photos/lusoldi/3018045218/ I’m going to talk about laziness. What does it mean for a language to be lazy?

Slide 56

Slide 56 text

C# if (true *+ LaunchMissiles()) { !" do stuff Well, you’ve seen this before. In C#, are there any missiles flying after this code executes?

Slide 57

Slide 57 text

C# IEnumerable stuff = from i in new[] { 1, 2, 3 } select i * i; !" Line A DoStuff(); !" Line B DoStuffWithStuff(stuff); !" Line C We see a similar effect with enumerables; in which order do the labeled statements execute? (BCA, probably) But for the most part, you can generally look at code in C# and it will be obvious in which order stuff executes.

Slide 58

Slide 58 text

“Now I'm a pretty lazy person and am prepared to work quite hard in order to avoid work.” Martin Fowler Refactoring https://www.flickr.com/photos/adewale_oshineye/2933030620/ Haskell, by contrast, is lazy by default. As the programmer, however, you may have to work a little harder. What does this mean?

Slide 59

Slide 59 text

There’s a function called increment. Adds 1 to its argument. Line 5 traces when it’s called. Line 6 adds 1 to the argument to the function and returns that value. In the main function, we call the increment function 3 times and store the results in local variables. Then we print two of those results. Look at the order of execution! The first call to increment never appears, and the second two are out of order! That’s laziness at work. None of the calls to increment are invoked until the time at which the result value is needed, in the putStrLn. In practice, you can’t look at nontrivial Haskell code and guess the order of operations, so you write programs where it doesn’t matter.

Slide 60

Slide 60 text

f x = x + 1 g x = x + 3 composed = f . g OK, so what’s the point? Doesn’t that just make everything harder? One of the principal benefits of laziness is that it enables easier composition of functions. I’ll start by defining composition, since the syntax may be unfamiliar. Composition simply combines two functions. Haskell uses the period operator, reminiscent of the circle used in math for function composition. First we define two functions, f and g, then we define a third which is their composition. It’s equivalent to calling g and then calling f on its result. All three take one argument and return a value of the same type. Does the code on the slide make sense? Again, I just want to make it clear what that dot operator does.

Slide 61

Slide 61 text

The huge win of composition is you can write methods which are simple and correct. I want to write a function to find the minimum value in a list. If you sort a list and take the first, you’ll get the minimum, right? But there’s a problem here, and it’s not correctness. What is it? (Performance)

Slide 62

Slide 62 text

minimum :: Ord a &. [a] "→ a minimum = head . sort The Haskell sort, by contrast, is so lazy that it only finds the smallest element when we use “head” to ask for the first result from the sort, and its performance is on the same order as other efficient methods of finding the minimum. This code will never sort the entire list (click) Calling the minimum function is the same as taking the head of the sorted list, and performance is similar to other methods of taking the minimum. Downside of lazy eval: Difficult to reason about performance. Haskell programmers know that taking the head of the sort is efficient, but it’s not obvious from looking at the code. However, performance is often non-obvious in many environments! So lazy evaluation helps produce obviously correct and efficient code.

Slide 63

Slide 63 text

minimum :: Ord a &. [a] "→ a minimum = head . sort minimum [3, 2, 1] = head . sort $ [3, 2, 1] The Haskell sort, by contrast, is so lazy that it only finds the smallest element when we use “head” to ask for the first result from the sort, and its performance is on the same order as other efficient methods of finding the minimum. This code will never sort the entire list (click) Calling the minimum function is the same as taking the head of the sorted list, and performance is similar to other methods of taking the minimum. Downside of lazy eval: Difficult to reason about performance. Haskell programmers know that taking the head of the sort is efficient, but it’s not obvious from looking at the code. However, performance is often non-obvious in many environments! So lazy evaluation helps produce obviously correct and efficient code.

Slide 64

Slide 64 text

https://www.schoolofhaskell.com/ Good place to learn more.

Slide 65

Slide 65 text

If What Order Wrong Happen Things? The notion of “order of operation” is even harder in a distributed system. Because our CPUs aren't getting much faster these days, many programs behave as distributed systems, even if they happen to be running on a single computer.

Slide 66

Slide 66 text

Explain farmer puzzle. Of course, Most of you will immediately realize that this is simply a distributed consensus problem. (click) the two sides of the river, naturally, represent two networked systems. (click) the river itself is a potential network partition, (click) and our goal is to prove that given the specification of the problem, there exists an invariant that no one gets eaten. We’re using this example because it’s easier to explain than Paxos. The real problem is that, like many client requests, this might turn out to be impossible. Perhaps you have seen this problem before and knows that a solution exists, but (click) what if I threw them a cobra and a honey badger? Is there a solution then, and what is it? Many real-world distributed systems problems turn out to be quite complicated!

Slide 67

Slide 67 text

System A System B Explain farmer puzzle. Of course, Most of you will immediately realize that this is simply a distributed consensus problem. (click) the two sides of the river, naturally, represent two networked systems. (click) the river itself is a potential network partition, (click) and our goal is to prove that given the specification of the problem, there exists an invariant that no one gets eaten. We’re using this example because it’s easier to explain than Paxos. The real problem is that, like many client requests, this might turn out to be impossible. Perhaps you have seen this problem before and knows that a solution exists, but (click) what if I threw them a cobra and a honey badger? Is there a solution then, and what is it? Many real-world distributed systems problems turn out to be quite complicated!

Slide 68

Slide 68 text

System A System B Possible Network Partition Explain farmer puzzle. Of course, Most of you will immediately realize that this is simply a distributed consensus problem. (click) the two sides of the river, naturally, represent two networked systems. (click) the river itself is a potential network partition, (click) and our goal is to prove that given the specification of the problem, there exists an invariant that no one gets eaten. We’re using this example because it’s easier to explain than Paxos. The real problem is that, like many client requests, this might turn out to be impossible. Perhaps you have seen this problem before and knows that a solution exists, but (click) what if I threw them a cobra and a honey badger? Is there a solution then, and what is it? Many real-world distributed systems problems turn out to be quite complicated!

Slide 69

Slide 69 text

System A System B Possible Network Partition THEOREM Spec ⇒ ☐NobodyGetsEaten Explain farmer puzzle. Of course, Most of you will immediately realize that this is simply a distributed consensus problem. (click) the two sides of the river, naturally, represent two networked systems. (click) the river itself is a potential network partition, (click) and our goal is to prove that given the specification of the problem, there exists an invariant that no one gets eaten. We’re using this example because it’s easier to explain than Paxos. The real problem is that, like many client requests, this might turn out to be impossible. Perhaps you have seen this problem before and knows that a solution exists, but (click) what if I threw them a cobra and a honey badger? Is there a solution then, and what is it? Many real-world distributed systems problems turn out to be quite complicated!

Slide 70

Slide 70 text

System A System B Possible Network Partition THEOREM Spec ⇒ ☐NobodyGetsEaten Explain farmer puzzle. Of course, Most of you will immediately realize that this is simply a distributed consensus problem. (click) the two sides of the river, naturally, represent two networked systems. (click) the river itself is a potential network partition, (click) and our goal is to prove that given the specification of the problem, there exists an invariant that no one gets eaten. We’re using this example because it’s easier to explain than Paxos. The real problem is that, like many client requests, this might turn out to be impossible. Perhaps you have seen this problem before and knows that a solution exists, but (click) what if I threw them a cobra and a honey badger? Is there a solution then, and what is it? Many real-world distributed systems problems turn out to be quite complicated!

Slide 71

Slide 71 text

https://lorinhochstein.wordpress.com/2014/06/04/crossing-the-river-with-tla/ This is a formal specification of the crossing the river problem in TLA+, a language created by Leslie Lamport of MSR. TLA+ lets you formally define properties of systems which change over time and space using temporal logic. One thing you may notice is it’s beautiful, meant to be easier to read than to write. Distributed consensus problems are often the most error-prone pieces of a system, especially if implemented ad hoc. TLA+ doesn’t implement this code, rather, it just makes sure that the algorithm you want to implement is even correct and complete.

Slide 72

Slide 72 text

Also a model checker to ensure system is satisfiable.

Slide 73

Slide 73 text

If we assert that the problem cannot be solved, the TLA+ model checker will find a counterexample showing that it can be solved. However, a limitation of TLA+ is that it can only verify the soundness of your model. It cannot verify that you have implemented your model in executable code correctly.

Slide 74

Slide 74 text

http://research.microsoft.com/en-us/um/people/lamport/tla/formal-methods-amazon.pdf Despite this limitation, however, it turns out to be extraordinarily useful. Amazon now uses TLA+ for all of its AWS internal protocols, and they have found a number of bugs in the protocols themselves with it, as summarized by the chart on the side.

Slide 75

Slide 75 text

http://research.microsoft.com/en-us/um/people/lamport/tla/formal-methods-amazon.pdf Good place to start… More detail….

Slide 76

Slide 76 text

http://research.microsoft.com/en-us/um/people/lamport/tla/hyperbook.html Best way to learn more is the TLA+ Hyperbook

Slide 77

Slide 77 text

https://github.com/p-org/PSharp/ Still, you might want to find bugs in your implementation as well as your model. So I’m going to tell you about another language out of MSR. You’ve heard of Microsoft C# and maybe F#. What about P#? Like TLA+, P# formally models a distributed system. But it compiles to C#, so the models are executable. Model on the screen is a server. There are a couple events, ping and pong. When the server receives ping, it sends pong. Pretty simple system. But it fits on a slide

Slide 78

Slide 78 text

P# is translated via Roslyn to a somewhat more verbose and difficult to read syntax in C#. But this is not really that interesting.

Slide 79

Slide 79 text

Like TLA+, it can explore the entire model space and find errors in the conceptual model. Unlike TLA+ P# can directly translate to executable code, and it finds the model errors by running exhaustive tests on the real-world system instead of the model. P# does this by augmenting the model with liveness and safety monitors which track execution of the system.

Slide 80

Slide 80 text

The examples on the screen represent real results from finding errors in the design of production Microsoft Azure Storage tools which are mostly written in C#. The team wrote a test driver which injected “fake” node failures into the system, chaos monkey style, and the test harness watched how or if the system recovered. P# then exhaustively explores the entire state space of the model.

Slide 81

Slide 81 text

http://p-org.github.io/PSharp/ If you want to learn more, it might seem like it’s reasonable to start at the P# homepage, which links to the docs. Also….

Slide 82

Slide 82 text

http://research.microsoft.com/pubs/260939/paper.pdf The homepage doesn’t link this paper, which is, I think, the best short introduction to P#.

Slide 83

Slide 83 text

Is Real Privacy Even Possible? When we share data with an online service, even if we trust the service itself, how can we be sure they won’t accidentally leak our data?

Slide 84

Slide 84 text

It’s certainly easy to screw this up. FB story Jeeves is a system for enforcing privacy at the language level. It can be laid as a DSL over Scala, Python, etc.

Slide 85

Slide 85 text

https://github.com/jeanqasaur/jeeves/blob/master/demo/jcal/tests.py Here is what Jeeves does, at the most basic level. Django app for Calendar / Events. Alice is holding a surprise party for Eve. Real privacy is more complicated.

Slide 86

Slide 86 text

https://github.com/jeanqasaur/jeeves/blob/master/demo/jcal/jcal/models.py Have an event. Looks like a normal Django model. (click) Special method to identify private events (click) This code notes the event should be visible to the host and guests, but not to the public (click) Special values for properties of private events. The Jeeves runtime will ensure that even if we compute derived values from this data, anonymity will be preserved in all contexts.

Slide 87

Slide 87 text

https://github.com/jeanqasaur/jeeves/blob/master/demo/jcal/jcal/models.py Have an event. Looks like a normal Django model. (click) Special method to identify private events (click) This code notes the event should be visible to the host and guests, but not to the public (click) Special values for properties of private events. The Jeeves runtime will ensure that even if we compute derived values from this data, anonymity will be preserved in all contexts.

Slide 88

Slide 88 text

https://github.com/jeanqasaur/jeeves/blob/master/demo/jcal/jcal/models.py Have an event. Looks like a normal Django model. (click) Special method to identify private events (click) This code notes the event should be visible to the host and guests, but not to the public (click) Special values for properties of private events. The Jeeves runtime will ensure that even if we compute derived values from this data, anonymity will be preserved in all contexts.

Slide 89

Slide 89 text

https://github.com/jeanqasaur/jeeves/blob/master/demo/jcal/tests.py So again, flipping back to the tests, we can see that Jeeves is hiding the data when the current user is Eve. This would also be true using data derived from this event.

Slide 90

Slide 90 text

http://arxiv.org/pdf/1507.03513v5.pdf The core idea is to keep trust policy in a small and easily understood segment of the application. “allows programmers to factor out information flow policies from the rest of web programs and rely on a web framework to dynamically enforce the policies.”

Slide 91

Slide 91 text

http://jeeveslang.org/ To learn more…

Slide 92

Slide 92 text

What Is the Fundamental Data Type?

Slide 93

Slide 93 text

If you program in JavaScript or C#, it might not be obvious that the language has a fundamental type, unless it’s null or undefined.

Slide 94

Slide 94 text

C Bag of bits C# , Java Object (ref. types) Value types Lisp Atom List Haskell Algebraic data types Julia, MATLAB Vector, Matrix APL, J Array Idris Theorem The data types provided in languages like C and C# are so under specified that it is difficult to think of them as having a fundamental datatype at all. So we have these boring arguments about whether enforcing them at compile time or runtime is a good idea at all. But many other languages are built around a more specific datatype which permits making functions which work on broad array of values. More importantly, a more powerful type theory allows the compiler to assist the programmer in producing correct and expressive code.

Slide 95

Slide 95 text

Idris

Slide 96

Slide 96 text

This isn't what I would call idiomatic Idris code, but I'm trying to make it recognizable to developers who typically work in other languages. It’s also written to demonstrate a very specific point, as you’ll see in a second. I want to write a function to compute the average of a list of integers. If I call it with []… How can I fix that?

Slide 97

Slide 97 text

I’ve added an implicit argument ({}) stating there must be a proof that the list is non-empty. Tells us something interesting about the types in Idris. We often think of types as denoting the sorts of values an argument might contain. But in Idris types also denote the behavior of the code. Here, the type signature says, “All code which calls this function must first test the list to make sure it is non-empty.” So when I compile, even with a non-empty list, the compiler tells me I haven’t proven it’s non-empty, because I can call formatAverage with any old list. How can we check the non-emptiness of a variable at compile time?

Slide 98

Slide 98 text

Empty lists

Slide 99

Slide 99 text

https://www.manning.com/books/type-driven-development-with-idris To learn more…

Slide 100

Slide 100 text

https://github.com/munificent/vigil Vigil. Augments standard Python with two additional statements. implore and swear. (click)

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

No content

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

Appropriate punishment? I wonder what that could be? Let’s run a quick git diff…

Slide 105

Slide 105 text

Very simple. Vigil deletes the offending method from the source code. Of course, now our innocent_fn which calls the now-nonexistent say_hello isn’t so innocent anymore….

Slide 106

Slide 106 text

Soooo…..

Slide 107

Slide 107 text

It’s deleted as well. There’s not much left, is there? And innocent_fn doesn’t exist anymore. Uh oh!

Slide 108

Slide 108 text

What could there possibly be left to delete?

Slide 109

Slide 109 text

This is hard to read, but vigil is now deleting itself. Because all errors must be punished.

Slide 110

Slide 110 text

Best place to learn about Vigil is GitHub. There’s an article in WIRED, but to hell with WIRED.

Slide 111

Slide 111 text

What If Future Computers Aren’t Silicon?

Slide 112

Slide 112 text

Weird Machines Finally, I’m going to talk about weird machines. I won’t try to explain much about these, because, to be honest, I don’t fully understand them.

Slide 113

Slide 113 text

LIQUi|̼ let circUa = CompileUa N a qs "# Compile 1 Shor step let count = circUa.GateCount() ∗ n∗2 let hits, misses = "# Get total gate count Gate.CacheStats() "# Get gate caching stats let gp = GrowPars(30, 2, false) "# Params for growing let circUa = circUa.GrowGates(k, gp ) "# Grow the circuit circUa.Dump() "# Dump circuit to file ShorRun circUa rslt n a qs "# Run Shor let m = Array.m api "# Accumulate all the ( fun i bit "→ bit <<< i ) rslt "# ..phase estim ation bits |> Array.sum "# ..m = quantum result let permG, permS, permN = k.Perms "# Get permutation stats http://stationq.github.io/Liquid/ You’ve heard of Language Integrated Query, now there’s Language Integrated Quantum operations! LIQUi|> is a Domain Specific Language and runtime for simulation of quantum computing on classical hardware. There is good reason to believe that quantum computing hardware is possible, but we don’t know how to build it.

Slide 114

Slide 114 text

We can simulate the hardware and run quantum algorithms (albeit much, much slower) on classical hardware. So we can learn how to program quantum computers in parallel with learning how to build them.

Slide 115

Slide 115 text

We can simulate the hardware and run quantum algorithms (albeit much, much slower) on classical hardware. So we can learn how to program quantum computers in parallel with learning how to build them.

Slide 116

Slide 116 text

http://stationq.github.io/Liquid/ LIQUi|> is not easy to Google, but…

Slide 117

Slide 117 text

Kappa %agent: A(b,c) %agent: B(a,c) %agent: C(b,a) ## %var: ’V’ 1 %var: ’k1’ INF %var: ’k2’ 1.0E-4/’V’ %var: ’k_off’ 0.1 ## ’a.b’ A(b),B(a) "→ A(b!1),B(a!1) @ ’k2’ (’k1’) ’a.c’ A(c),C(a) "→ A(c!1),C(a!1) @ ’k2’ (’k1’) ’b.c’ B(c),C(b) "→ B(c!1),C(b!1) @ ’k2’ (’k1’) ## ’a..b’ A(b!a.B) "→ A(b) @ ’k_off’ ’a..c’ A(c!a.C) "→ A(c) @ ’k_off’ ’b..c’ B(c!b.C) "→ B(c) @ ’k_off’ ## %var: ’n’ 1000 ## %init: ’n’ A(),B(),C() %mod: [E] > 10000 do \$STOP %def: "dotSnapshots" "true" Kappa, one member of the growing family of rule-based languages.

Slide 118

Slide 118 text

Rule-based modeling has attracted recent attention because they allows one to deal with the combinatorial complexity of multi-state and multi-component biological molecules. What does that mean? Kappa programs simulate biological processes.

Slide 119

Slide 119 text

Rule-based modeling has attracted recent attention because they allows one to deal with the combinatorial complexity of multi-state and multi-component biological molecules. What does that mean? Kappa programs simulate biological processes.

Slide 120

Slide 120 text

www.kappalanguage.org To learn about Kappa…

Slide 121

Slide 121 text

What Have We Learned? There are lots of interesting languages you can play with today. Many look nothing like the languages you use in your day job They will help you learn to think about computing differently.

Slide 122

Slide 122 text

Craig Stuntz @craigstuntz Craig.Stuntz@Improving.com http://blogs.teamb.com/craigstuntz http://www.meetup.com/Papers-We-Love-Columbus/ https://speakerdeck.com/craigstuntz