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

Incredibly Strange Programming Languages - CodeMash 2017 - with notes

Incredibly Strange Programming Languages - CodeMash 2017 - with notes

This version of the deck has speaker notes. I've published another version here without notes.

Craig Stuntz

January 13, 2017
Tweet

More Decks by Craig Stuntz

Other Decks in Programming

Transcript

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

    People sometimes want a programming language offering a familiar and comfortable way of solving a problem and sometimes a language with a new and intellectually
    stimulating approach to the problem.

    View Slide

  2. print *,"Hello world!"
    I like to talk to computers and tell them what to do. Sometimes it’s pretty simple. When I was in high school, we used Fortran…

    View Slide

  3. Console.WriteLine("Hello, World!");
    …and today I write a lot of C#. Now these may look kind of similar

    View Slide

  4. S3
    S1 S2 S3
    c a t
    var aaa = new Regex("cat");
    https://en.wikipedia.org/wiki/Van_cat#/media/File:Turkish_Van_Cat.jpg
    But sometimes we need to write more complicated programs. For that, it’s helpful to have a good computational model of what you’re trying to do. This slide shows two
    ways to model the same problem, namely if a string is equal (click) to the value “cat”. Depending on the subtleties of your problem, one approach may be more useful
    than the other. Because when we write software we’re not just typing and lighting up pixels on the screen, we’re automating computation.

    View Slide

  5. S3
    S1 S2 S3
    c a t
    var aaa = new Regex("cat");
    https://en.wikipedia.org/wiki/Van_cat#/media/File:Turkish_Van_Cat.jpg
    But sometimes we need to write more complicated programs. For that, it’s helpful to have a good computational model of what you’re trying to do. This slide shows two
    ways to model the same problem, namely if a string is equal (click) to the value “cat”. Depending on the subtleties of your problem, one approach may be more useful
    than the other. Because when we write software we’re not just typing and lighting up pixels on the screen, we’re automating computation.

    View Slide

  6. https://upload.wikimedia.org/wikipedia/commons/0/06/Human_computers_-_Dryden.jpg
    These women are computers (that’s their professional title) in the National Advisory Committee for Aeronautics (NACA) High Speed Flight Station "Computer Room",
    Dryden Flight Research Center Facilities, 1949. Some early programming languages like Lisp and APL were designed to model and better understand this kind of
    computation. The programming languages we use today lean more towards being understandable by a machine. That’s kind of a shame, but it’s changing.

    View Slide


  7. • 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
    I’m going to give you a whirlwind tour of 9 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 Slide

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

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

  10. 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 Slide

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

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

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

    View Slide

  14. https://www.flickr.com/photos/[email protected]/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 Slide

  15. https://www.flickr.com/photos/[email protected]/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 Slide

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

    View Slide

  17. But there are lots and lots of languages, and don’t all languages mostly work the same anyway?

    View Slide

  18. 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 Slide

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

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

  21. "#>,_
    "#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 Slide

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

  23. 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 Slide

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

  25. 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? (click)

    ALGOL-based languages really common. You can consider yourself a polyglot knowing only ALGOL family languages, even if you’ve never used ALGOL! For many of us,
    our day jobs are 100% in this pool. (click)

    1972 was a very interesting year for PLs! C, ML, Prolog, and SASL (click)

    1995 brought us Java, JavaScript, PHP, Ruby, and OCaml (click)

    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 Slide

  26. 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? (click)

    ALGOL-based languages really common. You can consider yourself a polyglot knowing only ALGOL family languages, even if you’ve never used ALGOL! For many of us,
    our day jobs are 100% in this pool. (click)

    1972 was a very interesting year for PLs! C, ML, Prolog, and SASL (click)

    1995 brought us Java, JavaScript, PHP, Ruby, and OCaml (click)

    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 Slide

  27. 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? (click)

    ALGOL-based languages really common. You can consider yourself a polyglot knowing only ALGOL family languages, even if you’ve never used ALGOL! For many of us,
    our day jobs are 100% in this pool. (click)

    1972 was a very interesting year for PLs! C, ML, Prolog, and SASL (click)

    1995 brought us Java, JavaScript, PHP, Ruby, and OCaml (click)

    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 Slide

  28. 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? (click)

    ALGOL-based languages really common. You can consider yourself a polyglot knowing only ALGOL family languages, even if you’ve never used ALGOL! For many of us,
    our day jobs are 100% in this pool. (click)

    1972 was a very interesting year for PLs! C, ML, Prolog, and SASL (click)

    1995 brought us Java, JavaScript, PHP, Ruby, and OCaml (click)

    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 Slide

  29. 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? (click)

    ALGOL-based languages really common. You can consider yourself a polyglot knowing only ALGOL family languages, even if you’ve never used ALGOL! For many of us,
    our day jobs are 100% in this pool. (click)

    1972 was a very interesting year for PLs! C, ML, Prolog, and SASL (click)

    1995 brought us Java, JavaScript, PHP, Ruby, and OCaml (click)

    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 Slide

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

  31. Change is coming
    • Hardware: GPU / FPGA / 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 Slide

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

  33. – 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. So let’s ask some deeper questions.

    View Slide

  34. 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 Slide

  35. 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 Slide

  36. Console.WriteLine("你好世界");
    C# has better Unicode support than many languages, but the language itself and the libraries are still ASCII.

    View Slide

  37. 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 Slide


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


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

  40. بلق
    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 Slide

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

    View Slide

  42. Git diff doesn’t work so well.

    View Slide

  43. You know what else won’t work?

    Your terminal.

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

    View Slide

  44. 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! This is a Kufic-style tile mosaic of بلق implementation of Fibonacci sequence

    View Slide

  45. 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. (click) here’s Hello world (click)

    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 Slide

  46. 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. (click) here’s Hello world (click)

    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 Slide

  47. 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. (click) here’s Hello world (click)

    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 Slide

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

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

  50. “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 maths 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 Slide

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

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

    Anyway, I’m going to talk about chapter XIII

    View Slide

  53. 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 Slide

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

  55. 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 Slide

  56. 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 Slide

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

  58. 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 helpful to know how to do useful work in that world.

    View Slide

  59. Best place to learn more…

    View Slide

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

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

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

    View Slide

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

  64. “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 Slide

  65. There’s a function called (click) increment. Adds 1 to its argument.

    (click) Line 5 traces when it’s called. (click) Line 6 adds 1 to the argument to the function and returns that value.

    (click) In the main function, we call the increment function 3 times and store the results in local variables.

    Then (click) we print two of those results. (click) 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 Slide

  66. There’s a function called (click) increment. Adds 1 to its argument.

    (click) Line 5 traces when it’s called. (click) Line 6 adds 1 to the argument to the function and returns that value.

    (click) In the main function, we call the increment function 3 times and store the results in local variables.

    Then (click) we print two of those results. (click) 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 Slide

  67. There’s a function called (click) increment. Adds 1 to its argument.

    (click) Line 5 traces when it’s called. (click) Line 6 adds 1 to the argument to the function and returns that value.

    (click) In the main function, we call the increment function 3 times and store the results in local variables.

    Then (click) we print two of those results. (click) 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 Slide

  68. There’s a function called (click) increment. Adds 1 to its argument.

    (click) Line 5 traces when it’s called. (click) Line 6 adds 1 to the argument to the function and returns that value.

    (click) In the main function, we call the increment function 3 times and store the results in local variables.

    Then (click) we print two of those results. (click) 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 Slide

  69. There’s a function called (click) increment. Adds 1 to its argument.

    (click) Line 5 traces when it’s called. (click) Line 6 adds 1 to the argument to the function and returns that value.

    (click) In the main function, we call the increment function 3 times and store the results in local variables.

    Then (click) we print two of those results. (click) 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 Slide

  70. There’s a function called (click) increment. Adds 1 to its argument.

    (click) Line 5 traces when it’s called. (click) Line 6 adds 1 to the argument to the function and returns that value.

    (click) In the main function, we call the increment function 3 times and store the results in local variables.

    Then (click) we print two of those results. (click) 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 Slide

  71. There’s a function called (click) increment. Adds 1 to its argument.

    (click) Line 5 traces when it’s called. (click) Line 6 adds 1 to the argument to the function and returns that value.

    (click) In the main function, we call the increment function 3 times and store the results in local variables.

    Then (click) we print two of those results. (click) 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 Slide

  72. 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. (click) First we define two
    functions, f and g, then we (click) define a third which is their composition. (click) 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 Slide

  73. 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. (click) First we define two
    functions, f and g, then we (click) define a third which is their composition. (click) 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 Slide

  74. 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. (click) First we define two
    functions, f and g, then we (click) define a third which is their composition. (click) 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 Slide

  75. 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. (click) First we define two
    functions, f and g, then we (click) define a third which is their composition. (click) 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 Slide

  76. 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 Slide

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

  78. 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 Slide

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

    View Slide

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

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

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

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

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

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

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

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

    View Slide

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

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

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

    View Slide

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

    View Slide

  92. 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, (click) ping and pong.

    When the server (click) receives ping, it sends pong. Pretty simple system. But it fits on a slide

    View Slide

  93. 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, (click) ping and pong.

    When the server (click) receives ping, it sends pong. Pretty simple system. But it fits on a slide

    View Slide

  94. 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, (click) ping and pong.

    When the server (click) receives ping, it sends pong. Pretty simple system. But it fits on a slide

    View Slide

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

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

  97. 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. The P# team became involved in this project when the Azure Storage team was unable to reproduce an
    intermittent error over the course of many months; (click) the P# model found dozens of them in mere minutes.

    View Slide

  98. 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. The P# team became involved in this project when the Azure Storage team was unable to reproduce an
    intermittent error over the course of many months; (click) the P# model found dozens of them in mere minutes.

    View Slide

  99. http://p-org.github.io/PSharp/
    If you want to learn more, start at the P# homepage, which links to the docs. Also….

    View Slide

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

  101. 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 Slide

  102. 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 Slide

  103. 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. So there’s a unit test to insure this is displayed correctly

    Real privacy is more complicated.

    View Slide

  104. 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. 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 Slide

  105. 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. 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 Slide

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

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

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

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

    View Slide

  110. What Is the
    Fundamental
    Data Type?

    View Slide

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

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

  113. Idris

    View Slide

  114. 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. (click)

    I want to write a function to compute the average of a list of integers. Have to do some casting since Idris is strict about conversion of numeric types, but it’s just the sum
    divided by the number of items in the list as you’d expect.

    (click) If I call it with []… (click) I get a less than ideal result

    How can I fix that?

    View Slide

  115. 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. (click)

    I want to write a function to compute the average of a list of integers. Have to do some casting since Idris is strict about conversion of numeric types, but it’s just the sum
    divided by the number of items in the list as you’d expect.

    (click) If I call it with []… (click) I get a less than ideal result

    How can I fix that?

    View Slide

  116. 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. (click)

    I want to write a function to compute the average of a list of integers. Have to do some casting since Idris is strict about conversion of numeric types, but it’s just the sum
    divided by the number of items in the list as you’d expect.

    (click) If I call it with []… (click) I get a less than ideal result

    How can I fix that?

    View Slide

  117. 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. (click)

    I want to write a function to compute the average of a list of integers. Have to do some casting since Idris is strict about conversion of numeric types, but it’s just the sum
    divided by the number of items in the list as you’d expect.

    (click) If I call it with []… (click) I get a less than ideal result

    How can I fix that?

    View Slide

  118. Here I’ve modified the average function by adding 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 constraining the sorts of values an argument might contain. But in Idris types also
    constrain 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.” (click)

    So when I compile, even though I’m (click) passing a hard-coded, non-empty list, the compiler tells me I haven’t proven it’s non-empty, because (click) I could potentially
    call formatAverage with any old list.

    How can we check the non-emptiness of a variable at compile time?

    View Slide

  119. Here I’ve modified the average function by adding 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 constraining the sorts of values an argument might contain. But in Idris types also
    constrain 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.” (click)

    So when I compile, even though I’m (click) passing a hard-coded, non-empty list, the compiler tells me I haven’t proven it’s non-empty, because (click) I could potentially
    call formatAverage with any old list.

    How can we check the non-emptiness of a variable at compile time?

    View Slide

  120. Here I’ve modified the average function by adding 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 constraining the sorts of values an argument might contain. But in Idris types also
    constrain 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.” (click)

    So when I compile, even though I’m (click) passing a hard-coded, non-empty list, the compiler tells me I haven’t proven it’s non-empty, because (click) I could potentially
    call formatAverage with any old list.

    How can we check the non-emptiness of a variable at compile time?

    View Slide

  121. Here I’ve modified the average function by adding 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 constraining the sorts of values an argument might contain. But in Idris types also
    constrain 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.” (click)

    So when I compile, even though I’m (click) passing a hard-coded, non-empty list, the compiler tells me I haven’t proven it’s non-empty, because (click) I could potentially
    call formatAverage with any old list.

    How can we check the non-emptiness of a variable at compile time?

    View Slide

  122. Well, I have to take that potentially empty list, check it for emptiness, and only call average if it’s non-empty. This allows the compiler to synthesize a proof of non-
    emptiness which it can pass to the implicit argument in the first method. (click)

    And now the compiler is satisfied with my code

    View Slide

  123. Well, I have to take that potentially empty list, check it for emptiness, and only call average if it’s non-empty. This allows the compiler to synthesize a proof of non-
    emptiness which it can pass to the implicit argument in the first method. (click)

    And now the compiler is satisfied with my code

    View Slide

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

    View Slide

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

    View Slide

  126. View Slide

  127. View Slide

  128. View Slide

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

    View Slide

  130. Very simple. Vigil deletes the offending method from the source code. It fixed that problem automatically!

    Of course, now our innocent_fn which calls the now-nonexistent say_hello isn’t so innocent anymore….

    View Slide

  131. Soooo…..

    Can anyone guess what just happened?

    View Slide

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

    View Slide

  133. What could there possibly be left to delete?

    View Slide

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

    View Slide

  135. Best place to learn about Vigil is GitHub.

    View Slide

  136. What If Future
    Computers
    Aren’t Silicon?

    View Slide

  137. 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 Slide

  138. 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 Slide

  139. We can simulate the hardware and run quantum algorithms (albeit much, much slower) on classical hardware.

    View Slide

  140. We can simulate the hardware and run quantum algorithms (albeit much, much slower) on classical hardware.

    View Slide

  141. So we can learn how to program quantum computers in parallel with learning how to build them.

    View Slide

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

    View Slide

  143. 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 Slide

  144. Rule-based modeling 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.

    Give examples

    View Slide

  145. Rule-based modeling 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.

    Give examples

    View Slide

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

    View Slide

  147. This
    Begs the Question:
    There you have it: A bunch of programming languages, each of which having a new and interesting idea for expressing computational logic. So…

    View Slide

  148. Why Don’t We Make a
    Lazy, Dependently Typed,
    Domain-Specific, Secure,
    Quantum Biological,
    Failsafe Language
    in Arabic?
    (pause) Who amongst us has not wondered this? We could call it… I dunno, Perl 6?

    Many languages go down the road of “a little of this, a little of that.”

    Sometimes it works out, at least partially. Elixir borrowed syntax from Ruby and F#, process and error handling model from Erlang, macros from LISP, works pretty well.
    But it doesn’t do everything!

    Sometimes the features fight each other.

    View Slide

  149. View Slide

  150. Craig Stuntz
    @craigstuntz
    [email protected]
    http://www.craigstuntz.com
    http://www.meetup.com/Papers-We-Love-Columbus/
    https://speakerdeck.com/craigstuntz
    If you found any of this interesting, you’re my kind of developer, and I’d really enjoy sitting down and talking with you. Here are lots of different ways of reaching out. I’ll
    pay for lunch. Also, if you want to work for a company which encourages this kind of research… (click)

    View Slide