News for hackers. Stuff that matters.
Re:What Golang Is and Is Not by Gankro on Sunday August 21, 2016 @12:04PM (#12331363)
Honestly parametric polymorphism is a big slippery slope feature. There's always Just One More Thing -- higher rank/order/kinded types, where clauses, dependent types, specialization... or else you force people to use dynamic checks/allocations/casts that reduce your type-safety and bog the code down relative to the "optimal" design.

Don't get me wrong, I love me some parametric polymorphism, but it's by no means a simple thing as far as I've seen. Especially if you care about the effeciency of things (you can fudge a lot more wih lots of indirection/allocation, like Java does).

Re:What Golang Is and Is Not by pcwalton on Sunday August 21, 2016 @01:36PM (#12331798)
> Don't get me wrong, I love me some parametric polymorphism, but it's by no means a simple thing as far as I've seen.

I disagree. You should look at OCaml (and Standard ML, though the eqtypes in SML are a botch): generics are dead simple there. Much simpler than Go interfaces, in fact.

Sure, there's always "one more thing" you could add, but that's always true for anything in any language. Slippery slope is a fallacy for this reason.

> or else you force people to use dynamic checks/allocations/casts that reduce your type-safety and bog the code down relative to the "optimal" design

Which is what happens even more if you don't have generics!

Re:What Golang Is and Is Not by catnaroek on Monday August 22, 2016 @05:23PM (#12339554)
> eqtypes in SML are a botch

Standard ML's `eqtypes` aren't a bad idea at all:

(0) They ensure that `op=` can only be used on things that actually have decidable equality.

(1) If SML were to be equipped with dependent types in the future, it would make sense to only allow `eqtypes` as type indices. First-order unification can be used on syntactic values of `eqtypes`, so the basic architecture of a Damas-Milner type checker can be retained, in spite of having dependent types.

OTOH, equality and comparisons in OCaml are completely broken.

Re:What Golang Is and Is Not by catnaroek on Sunday August 21, 2016 @12:12PM (#12331395)
> higher rank

A language designer can provide let polymorphism, refuse to add more, and call it a day.

> (higher) order/kinded types,

This is orthogonal to parametric polymorphism. Higher-kinded types are problematic for inference, and the way Haskell has implemented them has unfortunate consequences for modularity.

> where clauses,

This is just syntactic sugar. (FWIW, what I think Rust needs is better inference, rather than ways to make type signatures less verbose.)

> dependent types,

This is unrelated to parametric polymorphism.

> specialization

This is antithetical to parametric polymorphism.

> or else you force people to use dynamic checks/allocations/casts that reduce your type-safety and bog the code down relative to the "optimal" design.

Standard ML doesn't have dynamic checks or unsafe casts, and I don't find myself longing for them.

Re:What Golang Is and Is Not by mafribe on Sunday August 21, 2016 @01:05PM (#12331645)

   This is orthogonal to 
   parametric polymorphism
Higher-rank types are not orthogonal to parametric polymorphism, instead they are a special case. You can see this when you realise that rank-k polymorphism is a subsystem of System F (the paradigmatic typing system for parametric polymorphism) for any k. The let-polymorphism of the ML-family is just rank-1. See Chapters 22 and 23 of Pierce's great "Types and Programming Languages".

   Higher-kinded types are 
   problematic for inference
That is true, but already type inference for rank-3 polymorphism is undeciable, and the same is true for System F polymorphism.

In practise, Haskell needs only few kind-annotations to make kind inference possible. This is helped by unannotated kind variables having kind * in Haskell (IIRC).

Re:What Golang Is and Is Not by catnaroek on Sunday August 21, 2016 @01:07PM (#12331655)
> Higher-rank types are not orthogonal to parametric polymorphism, instead it's a special case.

Errr, sorry, I only saw “higher-kinded”, not “higher-ranked”. But, of course, you are right.

> That is true, but already type inference for rank-3 polymorphism is undeciable, hence also System F polymorphism.

Let polymorphism covers 95% of what most programmers need. So if a language designer feels particularly risk-averse (a perfectly legitimate position), they can provide just let polymorphism and ML-style type inference, and then call it a day.

Of course, higher-ranked polymorphism is a nice thing to have, and you can require type annotations when you use more (as Haskell does).

> In practise, Haskell needs only few kind-annotations to make kind inference possible.

A more serious problem with higher-kinded types IMO is that they wouldn't interact very well with an ML-style module system, where you can define an abstract type whose internal implementation is a synonym. `newtype` is an ugly hack.

Re:What Golang Is and Is Not by mafribe on Sunday August 21, 2016 @01:16PM (#12331701)

   provide just let polymorphism 
   and ML-style type inference
I mostly agree with this, and this should be the default starting point for any new programming language. If B. Eich had built Javascript on this basis, the world would have been a better place.

My main caveat would be that even a basic language needs a mechanism to glue related code together, objects, modules, structs with row-typing, existentials, not sure. But something.

Re:What Golang Is and Is Not by catnaroek on Sunday August 21, 2016 @01:23PM (#12331731)
> My main caveat would be that even a basic language needs a mechanism to glue related code together, objects, modules, structs with row-typing, existentials, not sure. But something.

While not perfect, I think ML's solution is pretty reasonable: a separate module language, whose complexity doesn't infect the core language.

Re:What Golang Is and Is Not by snaky on Sunday August 21, 2016 @02:04PM (#12331947)
There's 1ML where those languages are are unified into one language.

http://www.mpi-sws.org/~rossberg/1ml/

Re:What Golang Is and Is Not by catnaroek on Sunday August 21, 2016 @02:08PM (#12331970)
I'm aware of it. But my previous suggestions were in part shaped by the stated goals of Go's designers: to keep the language simple and easy to learn for non-language geeks. 1ML is really cool, but its type system can be intimidating: small vs. large types, incomplete inference, type-checking as elaboration into System F-omega, etc. OTOH, plain Damas-Milner is dead simple.
Re:What Golang Is and Is Not by mafribe on Sunday August 21, 2016 @02:24PM (#12332051)
Another problem with 1ML is that it's only a research prototype for now, so we can't take it "for a spin". Given the 1ML inventor's main job, this is unlikely to change any time soon, unless some kind soul takes on the 1ML project lead.
Re:What Golang Is and Is Not by snaky on Sunday August 21, 2016 @02:58PM (#12332192)
OTOH maybe we will be surprised by the name of first language with working compiler to web assembly.
Re:What Golang Is and Is Not by mafribe on Monday August 22, 2016 @04:03AM (#12334782)
Ohhh that would be amazing, have you got inside information that you can share?
Re:What Golang Is and Is Not by snaky on Monday August 22, 2016 @08:00AM (#12335652)
No, it was just wishful thinking, based on "given the 1ML inventor's main job".
Re:What Golang Is and Is Not by tome on Sunday August 21, 2016 @01:57PM (#12331905)
> A more serious problem with higher-kinded types IMO is that they wouldn't interact very well with an ML-style module system

That's interesting. Why is that?

Re:What Golang Is and Is Not by catnaroek on Sunday August 21, 2016 @02:00PM (#12331926)
Because, in ML, a type-level function that one module views as an abstract type constructor might be viewed by another module as a type synonym. Haskell's type language allows type constructors to appear partially applied, but requires type synonyms to appear fully applied, so it can't deal with this discrepancy.