
Modules Matter Most - ottbot
http://existentialtype.wordpress.com/2011/04/16/modules-matter-most/
======
6ren
His linked article says of the popularity of dynamic language: " _From what I
can tell, it’s largely a matter of marketing._ ", that _dynamic_ means fun,
and that they are subversive.
[http://existentialtype.wordpress.com/2011/03/19/dynamic-
lang...](http://existentialtype.wordpress.com/2011/03/19/dynamic-languages-
are-static-languages/)

Dynamic languages are popular because you don't need to make decisions about
types up-front, nor specify the types, nor change them when you change those
decisions. In terms of the act of coding, it's more flexible when you begin,
and more flexible when you maintain. He's right of course that static types
are more flexible in terms of carving out a particular subset of the space of
possible programs (as context free grammars are more flexible that regular
expressions).

That is, some simple and well-known facts are unknown to him. I still think he
has something interesting to say, it just takes some extra work to get to it,
and you have to take it with a grain of salt because although he's supremely
confident, he's coming from quite a limited perspective.

 _EDIT_ There's some hints in his conclusion and a comment that he does see
real benefits to dynamic languages (without articulating them) - so perhaps he
was just trolling or being ironic.

~~~
chc
It sounds to me like you're coming at the question without understanding all
the facts either. Strong static typing doesn't mean you need to specify all
your types. That's an orthogonal issue. There was actually a variant of
Smalltalk, called Strongtalk, which turned it into a statically typed language
but allowed existing Smalltalk programs to run unaltered.

~~~
6ren
Yes, that's part of static types carving out a subspace - just as context free
grammars can represent any regular language.

I was saying that, as a question of fact about the world today, one of the
reasons that today's dynamic languages are popular is that you don't need to
specify types (within the competitive set of mainstream statically typed
languages). Not marketing.

\---

But maybe I see where he's coming from now: he's saying that statically typed
languages are a superset of dynamic languages. So, therefore, they should be
more popular than dynamic languages. But they're not... so, thinks he, it must
be for some other reason... like marketing.

This perspective would explain his attitude; but I deeply disagree with it.
It's a mistake to expect popularity to measure technical quality. Sometimes
they coincide, but not always. I don't agree with the common idea that
"marketing" always causes the difference, as in promotion and advertising and
advertising a technically inferior product leading to widespread adoption. I
do think it is due to marketing, _but not that kind_. It's that the popularity
of a product is due to how well it meets the needs of users, compared with the
alternatives; it is not technical quality _per se_ , but technical qualities
that are needed.

Needs are often ranked, in that users won't worry much about their second need
until their first need is met. And after their first need is fully met, they
don't really appreciate getting even more of whatever met it. Like being
thirsty - a glass of water is great, two, maybe even a litre... but increase
the amount enough, and pretty soon, you're just not that excited about
drinking all that water.

In other words, popularity is more about users than products - so it can be
misleading to measure products by popularity.

To bring it back to the article: the lack of mainstream popularity of his
favourite languages is less to do with static vs. dynamic typing, and more to
do with the reasons why lisp is not popular (e.g. libraries, familiarity,
community, toolchain, intutiveness, etc).

For example, abstraction is a great thing, but if it's more than a user
_needs_ to do the tasks they have in mind, then they start to judge it by
other factors, like how easy it is to learn. If they absolutely need that
level of abstraction, then they may go to the trouble of learning it -
researchers and compiler writers (for example) sometimes need this; the
mainstream simply doesn't. Of course, some people just love abstraction for
itself, above all else - that's their first need.

\---

BTW: I can imagine a static/dynamic combination (like Strongtalk) taking off
in the mainstream, provided it didn't get in the way. You just have to ask
what needs it meets. One thought I've had is to have dynamic typing within
modules, but static typing between modules (think: python with static types in
library interfaces). I realize this is a subset in power of optional static
typing; but I'm thinking more about the needs of users than the capabilities
of technology. Interface documentation gets cleaner, bugs are found more
easily; yet within modules, it's still easy to create code quickly and change
it. It becomes _harder_ to change interfaces (which are hard to change anyway,
when other people depend on them). This is the use of it; the needs it meets.

------
tomp
Judging by the first paragraph, the author has a very biased, even aggressive
preference for static languages and a contempt for anyone that disagrees with
him. I don't like that, and I find that the best and most convincing arguments
are those that show understanding of the opposite side. People using
aggression or logical fallacies in their arguments are usually the people who
can't use logic to convince others.

" ... types (static types, of course, there being no other kind) ... "

This is the statement I'm referring to above. It strikes me as completely
misguided and wrong. Most languages that I know of, even most statically typed
languages, know dynamic types. Java has instanceof. C++ has virtual dispatch
(which is based on an objects dynamic type). Even C (untagged) unions usually
have some (bit)field that allows the running program distinguish the type of
data in the union.

I believe that in general, types are properties of data, which rarely exists
at compile time. Thus, almost all types are dynamic. Statically typed
languages simply restrict the data that can be stored in variables to a
particular type and subtypes thereof.

~~~
Darmani
The author is not talking with the snide condescension of an Internet troll
who, after reading the first chapter of a book, feels he's been clued into a
grand truth. He's talking with the snide condescension of one of the world's
top researchers in the field. Or, rather, he's not putting effort into
communicating to people who don't have some background in PL theory and some
familiarity with many of these arguments.

Professor Harper typically spends two lectures in his undergraduate PL class
developing the idea of dynamic typing, and then demolishing it. If you turn to
the section on 'Static "Versus" Dynamic Typing' in his book
(<http://www.cs.cmu.edu/~rwh/plbook/book.pdf> \-- currently section 22.3, but
subject to change), you'll find a summary of his argument. Basically, what
dynamically-typed languages do is not really "type-checking" but "run-time tag
checking."

You brought up a really good point though -- C and Java aren't really
statically-typed languages. Getting a null-pointer error is just not possible
in a type-safe language.

~~~
_delirium
He may be one of the world's top researchers in the field, but on this point
his view is not the consensus view of PLs researchers; _other_ top researchers
in the field think that Harper is wrong on the subject. On the other hand it's
mostly a semantic dispute over who owns the word "type", which has
historically come from multiple sources in mathematics and engineering. The C
view of types is closer to the comp-arch view of "typed registers", which
isn't really a proof so much as a statement about data-representation
capabilities ("this register can hold floats").

It's unsurprising Harper doesn't like that view, because he objects to the
entire line of machine-oriented CS thinking, on both the engineering and the
theory sides. For example, he thinks computational complexity theory should
ditch Turing machines and be refounded on the basis of functional programming.

~~~
gtani
Hmm, yes "type" can mean a lot of things, but would many dispute that the
languages with the most evolved type systems are those discussed in the
post(ML, ocaml, haskell, F#) plus scala? (Leaving aside coq, agda which I'm
not familiar with

<http://blog.tmorris.net/a-brief-point-on-static-typing/>

<http://james-iry.blogspot.com/2010/05/types-la-chart.html>

------
cageface
I've been reading eloquent advocacy of FP for over a decade now but
significant real-world applications written in FP langs are still very thin on
the ground. It's clear that FP languages are good research vehicles and
teaching tools but the burden of proof of their general suitability lies
squarely on the shoulders of the advocates at this point.

Five years ago people were telling me Haskell was the greatest thing since
sliced bread but now more often than not people discuss the tradeoffs of its
design, much like most other languages.

------
Roboprog
I'm sorry, that was too hard to follow. First give me the qualitative rundown
of what you are trying to say, then give the the quantitative formula. And use
symbols that a blub programmer can recognize in the formula, please.

There's something in there about wanting a more flexible type system, but
without completely hiding it in an implicit / dynamic system, but I'm not
quite getting it as presented. Too bad.

~~~
toadstone
Sometimes articles are over my head too. Sometimes I work on figuring them out
and learn something. Sometimes I give up because I don't have the time or
energy. However, I don't blame the author for my ignorance.

~~~
jdp23
It's not blaming the author to notice that he doesn't appear very interested
in this essay with communicating with most people in terms they'll understand.
Sure, it's just his style, but it's hard to be optimistic about how much buy-
in he'll get for his plan "to re-do the introductory curriculum in Computer
Science to modernize it".

~~~
happy4crazy
I guess I'm not disagreeing with you, but I personally find his style
exhilarating. I mean, come on:

 _Dijkstra used to say “beauty is our business”, to which I would add that
life is too short, and bright minds too precious, to waste on ugly things. And
if you take this point of view seriously, the best and the brightest are drawn
to, rather than repulsed by, the field. Pace some of my colleagues at a Major
Institute of Technology, students absolutely do love to program and do love
the beauty of code, provided that the code you ask them to write is, in fact,
beautiful. There is nothing more dreary than the corporate bureaucracy of OOP,
and few things more lovely than the mathematical elegance of FP._

~~~
mattmcknight
Perhaps I would find it more exhilarating if it didn't directly contradict my
own experience, and that of many others.

------
j_baker
Urgh...

I love static typing and the type safety that languages like Haskell provide
me. And I think they have practical benefit too. But I would give my right
testicle if static typing advocates would _stop encouraging the criticism that
this is all academic nonsense_.

~~~
jganetsk
I agree with you, we need to frame this in an accessible way. The OP is one of
the most eminent academics in the world on static typing. I've taken a class
with him, and I learned a lot from him.

His post can be rewritten in non-academic lingo. He is saying this: the module
system in SML is better than any form of OOP out there. It solves the right
problem in the right way. OOP conflates a lot of problems together and a lot
of solutions together.

And I think he's right, so let me start on a non-academic way to phrase this.
SML modules require less programmer cognitive load, fewer lines of code,
compile into tighter machine code, do not have the fragile base class problem,
and can express complex relationships in a cleaner way.

------
happy4crazy
I just have to say, I love Robert Harper's blog. He writes like I imagine Paul
Graham would, if he were a slightly pedantic college professor--with crisp
sentences that make points, dammit.

His book on Standard ML is wonderful:
<http://www.cs.cmu.edu/~rwh/smlbook/book.pdf>

------
szany
I've always wondered why Haskell doesn't support named instances:

[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.87....](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.87.6674&rep=rep1&type=pdf)

------
jordohx
I'm sensing that we're on the verge of an SML renaissance. Over the last month
I've been building web tools with SML and I have to say, that I'm moving
faster than I ever have in any other language, when looking holistically at my
project timeline. Dynamic languages give you the illusion that you're quickly
developing, but when taking into account bug fixes that you have to exhaust
hours of energy on _after your product is deployed_ , they don't seem as "fun"
and "free spirited" anymore. Loose(Dynamic) typing costs lives and billions of
dollars. If you don't understand your data enough to describe the their types,
then you should take a moment and sketch out your understanding. Otherwise,
you're not developing quickly - you're spinning your wheels senselessly
whether or not you believe it, and demonstrating that you're not the type of
developer who has a deep understanding of the systems you build.

Software engineering is not a bunch of sequential statements that _happen_ to
deliver results that we desire. Software engineering is artfully encoding your
human _understanding_. But that being said, SML is insanely practical if you
care about the results as much as you do about the design.

------
jtregunna
I'm sorry, but there's something to be said for a good article. A good article
isn't one whose first two sentences are flame bait. As such, I couldn't read
the rest of the article.

~~~
toadstone
I'm sure the author wouldn't mind especially if you copied the article into
notepad and deleted the first two sentences before reading it.

