Live data from Hacker News

Summer of Programming Languages

existentialtype.wordpress.com

41–50 of 78 posts

Re: Summer of Programming Languages

#41
post #35

Earlier quoted context omitted.

> DL people are like...what's the difference The dynamic typing folks don't care to provide a definition of types and overload the term to mean many things, the static typing folks have a rigorous one.

I see no definitions of type in the dictionary that specifically refer to static type theory... Definition of type (n) category or kind: a group made up of individuals or items that have strongly marked and readily defined similarities person or thing: somebody or something regarded as belonging to a group or category by virtue of having the main qualities associated with it particular kind of person: a person regard…

It's a technical term so the colloquial definition has little relevance to it's use in computing. You can read the definition in TAPL or PFPL.

> tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute.

Re: Summer of Programming Languages

#42
post #33
post #32

Earlier quoted context omitted.

> Academics don't care so much about things like programming speed. I don't know. Haskell and OccamL, for one, are much, much faster than Python and Ruby.

Citation needed. The argument for Haskell is usually about correctness; industry perception and my experience is that writing a Haskell version of a program will usually take longer than an "acceptably buggy" Python or Ruby equivalent.

Well, there's the 1994 US Navy experiment that shows Haskell is a serious contender for rapid prototyping: http://cpsc.yale.edu/sites/default/files/files/tr1049.pdf

Of course, there was no Ruby back then. The comparison was against C++, Ada, Awk (!?), something called "relational Lisp" and a variety of in-house languages. Haskell comes just after Lisp in development time, with a mind-boggling 8 hours! (No C++ times were reported... heh heh). The Haskell solution also got top marks in general, not just in development time. As a downside, some of the reviewers didn't understand it because they weren't well-versed in functional programming, and felt some of the Haskell code was "tricky".

Re: Summer of Programming Languages

#43
post #9

Why do programming languages researchers seem so enamored with type-safe languages? It seems to be a given in academia that type-safe languages are not just superior, but significantly superior to type-unsafe languages.

One of Harper's arguments (the author here) is dogmatic and perhaps compelling from a aesthetic point of view. Let me try not to butcher it too badly in what follows.

He believes a few things that in concert arrive at the idea that typed languages are the only interesting point in the design space thus uncovered.

He begins by first rigorously defining what he means by "type". In particular, it's a piece of information computed statically (i.e. using the syntax of a program alone, nothing of its "runtime") which constrains the eventual values the dynamics must take. A "type-safe" program is thus one where the dynamics correspond to the predictions of the statics—in particular, a program respects its type as it operates and the program "does not get stuck" i.e. does not hit an undefined state.

From here he notes the power of union types, types which are "either" A or B. Given a sufficiently large union type, one which reads "either this or that or this or that" for every possible result value of running a program then you can create a "safe" semantics for any language using this type—every program has this giant union type and every choice of dynamics ends up in this giant union type. He then notes that while this genuinely is "type safe" it's kind of boring. Further, all "dynamically typed" languages inherit this boringness since they expose no "interesting" static structure.

(Even if you dislike the argument above, and there's plenty that might cause someone to dislike it, it's worth noting that this line of thought arrives very smoothly at the concept of "hybrid typing" being explored by things like Typescript and Facebook's Hack.)

One of the primary things you could argue with at this point is that having more sophisticated types is interesting and valuable. To this end Harper focuses on what he calls the "Holy Trinity" of logic, type theory, and category theory. The idea is backed by the Curry-Howard-Lambek correspondence which shows that each of these fields is but an image of the other two. In Harper's (paraphrased) words: you know that something is genuine and lasting if you can show it exists in every branch of the Holy Trinity.

So he declares basically by fiat that things which reflect the Holy Trinity are interesting and things which do not are not. Obviously you can levy many arguments to disagree with him here.

But it's hard to declare that the things discovered in the Holy Trinity are boring. This is where cutting edge research on things like Homotopy Type Theory and general Dependent Types live. This produces compelling arguments to back up why "null pointers are a billion dollar mistake" [0] or why if-branching and booleans lack meaningful providence [1]. These ideas, even if they are stripped of their Ivory Tower gleam, are what are slowly percolating into mainstream languages with names like "Enum"++ in Swift and "Optional" in Java.

---

Generally, to finally provide my personal take, I think that Harper is dead right so long as you consider programming languages to be "means of expression". I think that's an interesting POV on languages generally and it's not totally at odds with the more everyday POV that languages are "tools for creation". But they are sometimes at odds since they place the brunt of what they demand of a language at different places. Ultimately, if Harper's program is successful many years from now we'll all use shadows of whatever futuristic grade of dependently typed language gives us maximal expressiveness while nesting it in an ecosystem of tooling and libraries which aid construction of interesting things. I have no idea if Harper's "one true language" exists, but it does seem like increasingly the world is moving that way... thus Harper's enthusiasm about Swift and Rust.

[0] http://qconlondon.com/london-2009/presentation/Null+Referenc...

[1] http://existentialtype.wordpress.com/2011/03/15/boolean-blin...

Re: Summer of Programming Languages

#44
post #41

Earlier quoted context omitted.

I see no definitions of type in the dictionary that specifically refer to static type theory... Definition of type (n) category or kind: a group made up of individuals or items that have strongly marked and readily defined similarities person or thing: somebody or something regarded as belonging to a group or category by virtue of having the main qualities associated with it particular kind of person: a person regard…

It's a technical term so the colloquial definition has little relevance to it's use in computing. You can read the definition in TAPL or PFPL. > tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute.

Type is pretty much used by most programmers to mean "type" as it is stated in the dictionary; so dynamic type checking is not a misnomer to them. Only type theorists are diligent about the colloquial definition, but they can only really use it like that when talking to other type theorists.

Re: Summer of Programming Languages

#45
post #41

Earlier quoted context omitted.

I see no definitions of type in the dictionary that specifically refer to static type theory... Definition of type (n) category or kind: a group made up of individuals or items that have strongly marked and readily defined similarities person or thing: somebody or something regarded as belonging to a group or category by virtue of having the main qualities associated with it particular kind of person: a person regard…

It's a technical term so the colloquial definition has little relevance to it's use in computing. You can read the definition in TAPL or PFPL. > tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute.

> It's a technical term so the colloquial definition has little relevance to it's use in computing. You can read the definition in TAPL or PFPL.

Technical books often define terms in a way convenient for the material and approach they are presenting, not in a way that is general to the field; particularly, if terms are used in different ways within the field at the time they are written, they typically have to choose for consistency within the book -- that doesn't make that definition the right one for the field, it simply means that's what the term means in the context of the work.

And, ultimately, the semantic argument is meaningless. It doesn't really matter whether you have static and dynamic types in different languages or you call the former "types" and the latter "tags" (except that the former terminology actually explains the difference in a way that tells you what the difference is every time you use the terms.) The substance is the same, and getting worked up over line-drawing regarding the boundary of "type" is a distraction from any discussion of substance.

Re: Summer of Programming Languages

#46

> Nowadays serious industrial-strength languages are emerging that are grounded in theory and informed by practice. This seems a bit overly optimistic, but it's nice to see this kind of positive attitude for a change instead of "Why invent yet another language?". I am very excited about Swift and I have some respect for what Rust is trying to accomplish, but none of these languages have much foundation in category th…

> but none of these languages have much foundation in category theory or the ambitious kind of type system that Haskell has been pioneering for a while. Is that a requirement? If so, why?

Bro, do you even liftM? ;)

Re: Summer of Programming Languages

#47
post #24
post #16

Earlier quoted context omitted.

I've never seen a "bolt-on" type system work, and I've used a few (e.g. JSR308). So I think it's something that needs to be built into the language itself. Having used a system with higher-level type constructs I find myself thinking in them. So many complex sequences of operations shake out as something much simpler once you realise the right monad, or arrow, or so on. And it becomes painful to manually expand it ou…

> I need either higher-kinded types or something equivalent to them. FWIW it seems that many of the Rust developers want this for Rust.

Yes, many of us do. Using Option/Result can often lead to a lot of pain without their accompanying monads, and while you can write the specific ones (there's a try macro for using Option), it'd be much, much nicer to just have monads be possible in the language itself.

However, the Rust team is trying to get 1.0 out the door, and higher-kinded types would be backwards compatible, so I don't think we'll be seeing them for a while. There's also questions about the overhead and syntax that would need to be resolved for them to make it in.

Re: Summer of Programming Languages

#48
post #17

Earlier quoted context omitted.

Any property that you can actually be confident about, you can encode into the type system. If you care that x ^ (y - z) is an integer, you'd better have some reason to believe that y > z. If you don't care or can't be sure, let x ^ (y - z) return Integer | Rational, and pattern-match for the cases (or treat them as some supertype, Numeric or some such). Or if you really can't figure out the proof but still think it'…

Right, but it's also much simpler and faster for the programmer to write one function with one return type, and later modify it to add a return type if the requirements change. I think this is obviously why dynamic languages rose in prominence coincidentally with the rise in rapid prototyping and agile development. That said, this is also why large companies with codebases that need to be maintained over multiple dec…

> it's also much simpler and faster for the programmer to write one function with one return type, and later modify it to add a return type if the requirements change.

How is this different? When you compile, your compiler will say "Hey, the requirements have changed, your code is wrong here, here, here, and here," and you modify those things, and you're done.

Re: Summer of Programming Languages

#49
post #9

Why do programming languages researchers seem so enamored with type-safe languages? It seems to be a given in academia that type-safe languages are not just superior, but significantly superior to type-unsafe languages.

In the case of Robert Harper in particular, see this blog post: http://existentialtype.wordpress.com/2011/03/19/dynamic-lang...

Meh, he's making a mathematical argument that dynamic languages are a special case of static languages. That has nothing to do with whether a language is good/productive for writing programs in.

I forget who said this, but programming language design is basically "applied psychology", and if you admit that, your language will go further. For example, the difference between Python and many similar languages is that it looks nicer and is "intuitive" to read, and that contributes a large part (perhaps the largest part) to its popularity.

Re: Summer of Programming Languages

#50
post #38
post #23

Earlier quoted context omitted.

Types are no silver bullet, however one important point missed by all the other replies is that static types check all paths through the program, including rare/untested/error paths. You can sometimes make up for this with lots of testing and detailed code coverage analysis, but that can be a huge amount of effort, and might be impossible in some cases (for example: how do you easily test that your program behaves we…

There are cases you cannot really exclude by testing. For example, guaranteeing that certain function never receives a null value.

Sure you can! Just search exhaustively over your ultimately finite programs. There's a really simple algorithm for that, though the performance is a little wanting.

/s

(On a more serious sarcastic note, searching over your impure state space is somewhat more challenging. It's unclear how very finite it is, but I'm sure some reasonable spherical user assumptions will trim it to feasible exhaustiveness)

Post reply on HN