Strange Loop 2012
bearophile
bearophileHUGS at lycos.com
Mon Oct 15 16:39:07 PDT 2012
They have released the many slides packs of the "Strange Loop
2012" conference:
https://github.com/strangeloop/strangeloop2012/tree/master/slides/sessions
(Some of those files are too much large for the normal GitHub
interface, so to download them you need to download the zip of
the whole conference.)
I have appreciated some of those slides packs. Two of them are:
---------------------
"Wolfe-Graph.pdf":
Programs written in functional languages are essentially written
as many little functions (sometimes one line long in Haskell)
that call each other. To better organize things, they have
invented a way to define at high level such call graph, using a
simple associative array, in Clojure language. I don't know if
this is a good idea, but it's a simple and easy to understand
idea, and it allows for some less simple usages, shown near the
end of the slides pack.
---------------------
"LaucherSnively-TypesVsTests.pdf":
This pack compares strong static typing against writing
unittests. What is the best of the two? The expected answer is
that they are two different things, they help the programmer on
different things, so they are both useful.
The comparison is done studing different solutions to this kata
(a coding kata is a programming problem, it's a shape problem,
its main purpose is not to find one solution, but to find many
different solutions, and compare them. You are supposed to solve
many times the same kata). They solve only the first three parts
("stories") of this kata:
http://codingdojo.org/cgi-bin/wiki.pl?KataBankOCR
The things said in this slides pack are well know, but they are
collected and presented nicely in a small space.
At the beginning there is a well know quotation, that is a pillar
of functional programming (and it's widely useful in D/Rust/Scala
code too!):
>Make illegal states unrepresentable -- Yaron Minsky<
A woman has solved the kata in a mostly functional language (F#)
and concluded saying:
- Types save me from having to even think about certain
categories of tests.
- Tests help me out when I get stuck but I mostly run them in the
REPL and delete.
- Code is structured differently with REPL.
- Most modern languages don't have a strong enough type system to
make illegal states un representable.
- It's easy to get lost in a space where you never deliver.
- Test verify when types can't prove.
Another person has used a probably less functional approach, in
Scala, using more unittests, and he concludes that:
- Even for such a small problem spelling out unit tests made me
want to gouge out my eyeballs with a rusty
spoon.
- When developing property based tests every forAll made me think
"could/should that be a type?".
- For some use cases having examples of correct input/output gave
no real guidance whatsoever.
- Test code is still code with its own correctness, maintenance
etc. burden.
I think such notes are about equally valid for functional and OOP
languages.
Bye,
bearophile
More information about the Digitalmars-d
mailing list