Conference: PolyConf 2015
This year's PolyConf, a "polyglot conference", had a slightly lower insight-per-hour rate for me than the last one, but still turned out to be pretty good - especially since it was one day longer this year. Here are some of the interesting things that I heard about:
The conference started with a short workshop on miniKanren, a relational engine that is sort of like Prolog but simpler and more pure - there are no cuts, and the search algorithm guarantees that as long as the result exists, the program will find it in finite time. We wrote a Scheme interpreter in it (which is easier than it sounds! Just define variables, lambda and application, and you're all set) and that made possible all kinds of fun with running programs backwards.
For instance, if
(append q '(c d e))returns
(a b c d e), then what is
q? Given a list like
(I love you), what are all possible programs that return this list? The most impressive example was running a proof checker backwards. Given a Scheme function that checks whether a (logical) proof is correct, and a statement like
p & (p -> q) & (q -> r) -> r, miniKanren is able to find the proof for that statement.
You can define schemas for your XML or JSON messages, but there are also several libraries for defining a protocol as you would define a set of data types. For instance, ASN.1, Protocol Buffers, Thrift, Cap'n proto, Avro…
Being able to define a binary protocol and have an easy way of serializing and deserializing messages in various languages for free sounds pretty useful. And I guess these might do much better when you really care about performance, for instance you have constrained processing resources or high throughput, and you don't want the text parsing overhead.
OFFSETare a bad way of handling pagination. Don't count on Postgres to fetch that last page quickly!
Well, to be fair, the point of the talk was not to come up with convoluted schemes for efficient pagination in SQL, but to use a right tool for the job (in this case you could cache your data in something like Redis). And more generally - learn the technology you're using, push it to its limits, but don't be afraid to reach for something else if it might be better for your use case. Who knows - maybe adding a new technology to your stack will unlock some other possibilities you do not yet know about.
Also, if you want to introduce a new technology to the team, don't rewrite a mission critical component - you will reduce the bus factor, it will break and people will hate you. Start with something smaller like one-off scripts.
Cello is a fun little library that allows you to use high-level features in C, such as inheritance, polymorphism, GC and exceptions. Maybe not very useful, and somewhat abusive, but still pretty cool.
An interesting talk about WebSocket internals. I learned that the protocol is pretty simple but still provides some useful features like splitting the messages into frames (convenient when you're streaming) and specifying them either as UTF-8 or binary. It also tries really hard to prevent over-eager caching by various proxies - initial HTTP requests and responses contain random numbers, and frames sent by client must be XORed with a random mask.
Good metaphor for program correctness as science: type systems are a logical proof that your program does the right thing, and automated tests are experimental evidence. Testing manually is just an anecdote - all it proves is that the program worked once on your machine…
Also, type systems are like the universal quantifier, and tests are like the existential one.
MirageOS is a whole operating system written in OCaml. Thanks to static linking, you can write your server using MirageOS as a library, compile it, and generate an image with only the code that it uses. If your site is simple, the whole virtual machine that serves it can take up something like 20 megabytes - pretty impressive compared to hundreds of megabytes for a Linux server.
This is not only convenient but also pretty safe, as you're reducing the attack surface of your system. As a proof of concept, there's the Bitcoin Piñata, a "hack me" website that knows the key to about 10 Bitcoins - nobody was able to smash it yet.
Julia is a nice language for scientific computing that compiles itself to native code. What impressed me is that it has powerful macros - for instance, you can define a generic way of looping through multi-dimensional arrays, and it will generate as many nested loops (
for i = ..., for j = ..., for k = ...) as necessary.
Emoji Lisp! I really like the