Hacker News new | past | comments | ask | show | jobs | submit login
Modules Matter Most (existentialtype.wordpress.com)
47 points by ottbot on April 16, 2011 | hide | past | favorite | 26 comments



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

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.


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.


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.


Yes he does see the benefits to dynamic languages, but wonders why you would use one considering that those benefits are present in "good" static languages.

Good static languages have pattern matching and sum types, which gives you the ability to work with tagged data in a syntactically clean way. Dynamic languages just tag all the data. OP's point: are you aware of this? You could be as dynamic and as static as you want in a language like ML or Haskell.


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.


There are no dynamic types, but there may be dynamic typing. All those so called dynamic typed languages are actually statically uni-typed and figure out at run time the so called dynamic type. Types are not properties of data, types are proofs about your program. In general type safety provides proofs of preservation of types and that your program won't get stuck due to types. The perception you have about types is exactly the problem that Prof Harper is trying to avoid in his students.


Then maybe all this conflict really is "a problem of grammar", as Harper himself asserts. For me, the word type has a differenn meaning than for you. Maybe we should instead be using the expressions static type (compile-time proof) and dynamic type (runtime properties of data, which Harper calls class, though I prefer not to use this word as its meaning is already too overloaded in CS).


What you're calling a dynamic type is what he'd call a canonical form. If your typing system has product types, then you should be able to prove that anything with a product type evaluates down to an ordered pair.


Harper has somewhat... unorthodox views on the subject (and has had them for a long time). Here's the HN discussion of the essay he links to in that parenthetical: http://news.ycombinator.com/item?id=2346590. Quite a few also-prominent PLs researchers comment negatively in the comments on his post as well.

In general I find Harper's "positive" opinions on the design of ML better than his "negative" opinions on why everything that isn't ML is doing it wrongwrongwrong, but he's definitely quite intelligent and usually has some good points.


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.


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.


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


That chapter doesn't seem to be provide any arguments for redefining what the words "dynamic typing" mean other blind assertions of the same sort that he used in his blog posts. I appreciate that he has a potentially useful mathematical formalism, but thats no reason to go about redefining words in relatively common usage - and especially not to be rude about it.


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.


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.


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.


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


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.


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


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.


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.


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


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

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.87....


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.


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.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: