News for hackers. Stuff that matters.
Re:A conversation with the Go team by galaktor on Thursday June 06, 2013 @03:14AM (#5830953)
"What surprises me is that almost nobody complains about the lack of generics."

Strange. Lack of generics is probably the single most common thing I read/hear people complain about.

(Btw, I like and use Go)

Re:A conversation with the Go team by jbarham on Thursday June 06, 2013 @06:17AM (#5831521)
It's almost certainly a joke since complaints about the lack of generics in Go probably generate the most heat on the mailing list.

For example here is a recent thread on the list that quickly degenerated into an epic flamewar: https://groups.google.com/forum/?fromgroups=#!topic/golang-n.... (Most amusingly the OP's chosen handle is "Sod Almightly", a pretty strong signal that the guy is a troll, although props to Ian Taylor in particular for keeping civil throughout.)

Re:A conversation with the Go team by _pmf_ on Thursday June 06, 2013 @09:15AM (#5832183)
Masterfully executed. Especially delightful is that the first response is "No one is likely to debate this with you", which is promptly followed by 9 pages of discussion.
Re:A conversation with the Go team by unoti on Thursday June 06, 2013 @03:19AM (#5830976)
I noticed that too. That quote starts with him saying "A lot of developers that seriously tried Go are very happy with it." I imagine that Robert hears about generics an awful lot, so he seems to be saying that the people who complain about generics are not people who have seriously tried Go. Very likely, he's right. There's some selection bias, though, because the people who can't live without generics generally perform a flaming exorcism on the language before long.
Re:A conversation with the Go team by coldtea on Thursday June 06, 2013 @09:22AM (#5832225)
His is an extreme case of "no true Scotchman" ("no guy that truly tried Go complains about Generics...") and confirmation bias (since those that stick to it, are happy with the status quo) together...

Lots of people have both tried Go, legitimately, and are still concerned about lack of Generics. I've read several that have done so, and have tried it myself and would like Generics. But sure, I could use it, and even enjoy it, even without Generics. That doesn't mean I'm perfectly happy with the situation.

Re:A conversation with the Go team by tcard on Thursday June 06, 2013 @06:25AM (#5831537)
As I understand it, he is pointing out that people who really get deep into using the language with a constructive purpose don't complain about such perceived issue. Also a pun against early judges.

He wrote more about this here: http://commandcenter.blogspot.com.es/2011/12/esmereldas-imag...

EDIT: Well, the answerer of that question was Robert (Griesemer), not Rob (Pike), but I suppose the same applies.

Re:A conversation with the Go team by BenDaglish on Thursday June 06, 2013 @04:17AM (#5831153)
That's the problem with reported conversation - I suspect there was a smile on his face as he was saying that, and I for one was expecting an "(audience laughter)" at the end of the sentence.
Re:A conversation with the Go team by galaktor on Thursday June 06, 2013 @05:19AM (#5831351)
True, Rob's jokes can be very dry and subtle. If he ever looks at the golang-nuts Google group [1] (which he evidently does) there's no way this couldn't have been sarcasm. Many questions from newbies touch on the topic of generics.

[1] https://groups.google.com/forum/?fromgroups#!forum/golang-nu...

Re:A conversation with the Go team by tocomment on Thursday June 06, 2013 @08:10AM (#5831866)
Sorry what's a generic? Can you explain it in Delphi 6 terms? er actually Python terms would be even better.
Re:A conversation with the Go team by hugorodgerbrown on Thursday June 06, 2013 @08:41AM (#5832004)
Generics are used to defer type setting from compile time to run time, allowing for flexible, yet type-safe constructs.

The classic example is a list (in a strongly-typed language) - without generics you would create specialised strongly-typed list classes - you could have a StringList (only strings), an IntList (only ints), etc.

Using generics you can define a single list class of type <T>, where <T> is any type. Then at runtime you would create a List<String> or a List<Int>. Same outcome, less code, easier to maintain.

MSDN has a good intro to C# generics - http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).as...

They are less appropriate in dynamic languages, as type-safety isn't a compile time concern.

Re:A conversation with the Go team by throwit1979 on Thursday June 06, 2013 @09:10AM (#5832158)
Runtime? Huh?

Whether it's static or dynamic is language-dependent. Example: Java in particular does erasure on parameterized types, so generics are only compile-time.

Re:A conversation with the Go team by zwieback on Thursday June 06, 2013 @11:13AM (#5832882)
Here's another good paper from MS on generics in .NET and C#: http://research.microsoft.com/pubs/64031/designandimplementa...

What's interesting is that the .NET CLR directly supports parametric polymorphism. I think the .NET design is nicer than type erasure in Java but Java's approach is more applicable to situations where the runtime can't be modified. No idea how Go fits into that picture.

Re:A conversation with the Go team by papsosouid on Thursday June 06, 2013 @10:24AM (#5832574)
>Generics are used to defer type setting from compile time to run time, allowing for flexible, yet type-safe constructs.

No. Some languages implement it that way, but nothing about the concept involves moving anything to run time. In languages with reasonable type systems, there is no run time involvement at all.

Re:A conversation with the Go team by lobster_johnson on Thursday June 06, 2013 @10:12AM (#5832503)
Example of generics: In Delphi, you have TList. It stores any TObject, but it's not type safe, so if you store something like TPerson in it, you have to cast it every time:

    List := TList.Create();
    Person := TPerson(List[0]);
With generics, you would have something like:

    List := TList<TPerson>.Create();
    Person := List[0];
The TList<TPerson> class would be compiled at compile time and offer the same kind of type safety as, say, an array.

In C++ it would be something like (simplified):

    template <class T>
      class TList {
        private:
          T[] elements;
        public:
          void add(T value);
          void remove(T value);
          T operator[](int index);
      };
This extends to other declarations. For example, in C++ you can have generic functions. So you can have a functon max(a, b) which works on any type, for example.

Generics is essentially about enhancing compile-time type safety and reusing code. By giving the type system more intelligence, more checks can be performed at compile time, and code can use the same logic across multiple types instead of having to be reimplemented for each type.

Incidentally, Delphi has had generics since 2007 [1]. I haven't used Delphi since version 5, so I haven't tried it out, but it looks fairly similar to the generics in C#.

[1] http://en.wikipedia.org/wiki/Generic_programming#Genericity_...

[deleted]
Re:A conversation with the Go team by tocomment on Thursday June 06, 2013 @08:36AM (#5831978)
What's so good about that? Isn't it more convenient to be able to store different types together in the same collection?
Re:A conversation with the Go team by coldtea on Thursday June 06, 2013 @09:26AM (#5832247)
No. You typically want different types of the same kind, or of the same family (e.g numeric types or types that extend some interface, etc), not every random thing thrown in.

If it was truly whatever type, how would you know what to do with it when you got it out of the collection?

E.g

foo = myColection.get(2);

foo.?????? (what operations can foo afford?)

Re:A conversation with the Go team by sluukkonen on Thursday June 06, 2013 @08:57AM (#5832081)
It can be more convenient, but the added type safety prevents the programmer from doing many kinds of common mistakes. It's a trade-off.
Re:A conversation with the Go team by ilSignorCarlo on Thursday June 06, 2013 @04:33AM (#5831209)
It was so disappointing when I realized it was not referred to the band
Re:A conversation with the Go team by skinofstars on Thursday June 06, 2013 @05:18AM (#5831347)
Yep, but at least it's a good reminder to listen to them.