Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Incredibly Strange Programming Languages

Incredibly Strange Programming Languages

If you've ever suspected that “all programming languages are pretty much the same; they just have different syntax,” well, you will never suspect that again! Covering languages from the unusually powerful (Idris) to the illuminated (قلب) to the profoundly limited (BlooP), and all points in between, these languages will help you think differently about approaches to software problems you face in your day job. Of course we’ll have a lot of fun, but these languages are no joke. The practical benefit of an impractical language is the power to find new approaches to common problems.

Craig Stuntz

May 06, 2016
Tweet

More Decks by Craig Stuntz

Other Decks in Programming

Transcript

  1. Incredibly Strange
    Programming Languages!
    Craig Stuntz
    Slides are already online

    View full-size slide

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

    View full-size slide


  3. • 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

    View full-size slide

  4. 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.

    View full-size slide

  5. 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.

    View full-size slide

  6. 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

    View full-size slide

  7. 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?

    View full-size slide

  8. 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.

    View full-size slide

  9. 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.

    View full-size slide

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

    View full-size slide

  11. 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!

    View full-size slide

  12. 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!

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. 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#

    View full-size slide

  16. 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

    View full-size slide

  17. 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

    View full-size slide

  18. "#>,_
    "#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++

    View full-size slide

  19. 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?

    View full-size slide

  20. 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.

    View full-size slide

  21. 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.

    View full-size slide

  22. 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?

    View full-size slide

  23. 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….)

    View full-size slide

  24. 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.

    View full-size slide

  25. 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.

    View full-size slide

  26. – 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.

    View full-size slide

  27. 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.

    View full-size slide

  28. 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.

    View full-size slide

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

    View full-size slide

  30. 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?

    View full-size slide


  31. 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.

    View full-size slide


  32. 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.

    View full-size slide

  33. بلق
    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?

    View full-size slide

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

    View full-size slide

  35. At least the web is Unicode. Oh, wait.

    View full-size slide

  36. Git diff doesn’t work so well.

    View full-size slide

  37. You know what else won’t work?

    Your terminal.

    Any text editors you might try. (RTL handled incorrectly in Atom, Sublime, others)

    View full-size slide

  38. 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

    View full-size slide

  39. 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.

    View full-size slide

  40. 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.

    View full-size slide

  41. 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.

    View full-size slide

  42. http://nas.sr/بلق/
    You can learn more at Ramsey’s site.

    Not easy to type if you don’t have an Arabic keyboard installed.

    View full-size slide

  43. 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?

    View full-size slide

  44. “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!

    View full-size slide

  45. 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

    View full-size slide

  46. The book became kinda popular. Apparently moreso than Kurt Gödel himself.

    Anyway, I’m going to talk about chapter XIII

    View full-size slide

  47. 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!

    View full-size slide

  48. 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!

    View full-size slide

  49. 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.

    View full-size slide

  50. 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.

    View full-size slide

  51. 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.

    View full-size slide

  52. 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.

    View full-size slide

  53. Best place to learn more…

    View full-size slide

  54. 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.

    View full-size slide

  55. https://www.flickr.com/photos/lusoldi/3018045218/
    I’m going to talk about laziness.

    What does it mean for a language to be lazy?

    View full-size slide

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

    View full-size slide

  57. 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.

    View full-size slide

  58. “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?

    View full-size slide

  59. 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.

    View full-size slide

  60. 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.

    View full-size slide

  61. 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)

    View full-size slide

  62. 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.

    View full-size slide

  63. 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.

    View full-size slide

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

    View full-size slide

  65. 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.

    View full-size slide

  66. 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!

    View full-size slide

  67. 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!

    View full-size slide

  68. 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!

    View full-size slide

  69. 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!

    View full-size slide

  70. 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!

    View full-size slide

  71. 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.

    View full-size slide

  72. Also a model checker to ensure system is satisfiable.

    View full-size slide

  73. 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.

    View full-size slide

  74. 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.

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  77. 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

    View full-size slide

  78. P# is translated via Roslyn to a somewhat more verbose and difficult to read syntax in C#.

    But this is not really that interesting.

    View full-size slide

  79. 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.

    View full-size slide

  80. 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.

    View full-size slide

  81. 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….

    View full-size slide

  82. 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#.

    View full-size slide

  83. 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?

    View full-size slide

  84. 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.

    View full-size slide

  85. 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.

    View full-size slide

  86. 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.

    View full-size slide

  87. 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.

    View full-size slide

  88. 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.

    View full-size slide

  89. 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.

    View full-size slide

  90. 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.”

    View full-size slide

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

    View full-size slide

  92. What Is the
    Fundamental
    Data Type?

    View full-size slide

  93. 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.

    View full-size slide

  94. 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.

    View full-size slide

  95. 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?

    View full-size slide

  96. 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?

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  100. 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….

    View full-size slide

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

    View full-size slide

  102. What could there possibly be left to delete?

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  105. What If Future
    Computers
    Aren’t Silicon?

    View full-size slide

  106. 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.

    View full-size slide

  107. 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.

    View full-size slide

  108. 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.

    View full-size slide

  109. 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.

    View full-size slide

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

    View full-size slide

  111. 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.

    View full-size slide

  112. 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.

    View full-size slide

  113. 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.

    View full-size slide

  114. www.kappalanguage.org
    To learn about Kappa…

    View full-size slide

  115. 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.

    View full-size slide

  116. Craig Stuntz
    @craigstuntz
    [email protected]
    http://blogs.teamb.com/craigstuntz
    http://www.meetup.com/Papers-We-Love-Columbus/
    https://speakerdeck.com/craigstuntz

    View full-size slide