News for hackers. Stuff that matters.
Re:Everyday hassles in Go by mrweasel on Tuesday December 30, 2014 @08:11AM (#8814419)
Are generics really that important? Java didn't have generics for 9 or 10 years, C# only got them in version 2. C still doesn't have generics and I never heard anyone complain.

As a former C# developer I would agree that life got easier with the introduction of generics, but you can develop the exact same software with and without generics.

Re:Everyday hassles in Go by kasey_junk on Tuesday December 30, 2014 @08:15AM (#8814433)
You can say the same thing about every language feature there is. Of course it is possible to develop software without some particular feature, it's whether the benefits of the feature out way it's costs. With generics, most of the world has decided to land on the side of wanting them. Even golang has them, just not for users.
Re:Everyday hassles in Go by TazeTSchnitzel on Tuesday December 30, 2014 @08:16AM (#8814438)
Java would be a lot nicer to work with had it had generics from the beginning.
Re:Everyday hassles in Go by protomyth on Tuesday December 30, 2014 @01:25PM (#8815859)
That's one of the big problems with adding major features later, the standard libraries don't get rewritten to fully use the new feature.
Re:Everyday hassles in Go by danieldk on Tuesday December 30, 2014 @02:24PM (#8816192)
That's not Java's major problem. It's that generics were implemented using type erasure to stay source and binary compatible with older libraries.
Re:Everyday hassles in Go by Iftheshoefits on Tuesday December 30, 2014 @08:37AM (#8814517)
Depends on what you mean by "important." You noted yourself that "life got easier" once the language you used introduced generics.

Generics can drastically reduce the time required to implement features because less time is spent on re-implementing (nearly) identical algorithms for different data structures and more on simply using them to write something that works.

The cost paid for this is usually in the form of minor efficiency hits because data-specific efficiencies aren't exploited.

Also, consider me complaining about C's lack of generics. It is in fact the primary reason I prefer C++. If C had robust generics with reasonable syntax I'd strongly consider using it instead of C++.

Re:Everyday hassles in Go by dalke on Tuesday December 30, 2014 @08:45AM (#8814543)
C11 added the _Generic keyword, so someone must have complained. A common complaint is the desire to have, say, cos(x) work on floats, doubles, and long doubles rather than calling respectively cosf(), cos(), cosl().
Re:Everyday hassles in Go by stephencanon on Tuesday December 30, 2014 @09:34AM (#8814693)
Huh? C has had the <tgmath.h> header for 15 years, which lets cos(x) do exactly that, and work on complex types besides.
Re:Everyday hassles in Go by dalke on Tuesday December 30, 2014 @09:59AM (#8814816)
_Generic makes it easy to implement things like tgmath yourself.
Re:Everyday hassles in Go by Pxtl on Tuesday December 30, 2014 @02:04PM (#8816070)
C has macros, which allow you to create something close-enough to generics.

And as somebody who developed in Java and C# before generics, those languages were awful before those features were added.

Re:Everyday hassles in Go by coldtea on Tuesday December 30, 2014 @11:30AM (#8815234)
>Are generics really that important?

For the kind of work we do in 2014, yes.

Re:Everyday hassles in Go by AnimalMuppet on Tuesday December 30, 2014 @02:51PM (#8816343)
For some of the kinds of work we do in 2014, yes. For others, not really; for still others, not at all.
Re:Everyday hassles in Go by NateDad on Tuesday December 30, 2014 @02:54PM (#8816365)
I've been working on juju (http://jujucharms.com) for 18 months and have not missed generics. I have 16 years of development experience in C++ and C#, so it's not like I don't know what they're good for.
Re:Everyday hassles in Go by jbooth on Tuesday December 30, 2014 @09:39AM (#8814716)
If you read the article, he puts forth a few examples where generics make code re-use possible, where it was impossible before. This not only means less effort, it means fewer bugs.
Re:Everyday hassles in Go by Retra on Tuesday December 30, 2014 @12:38PM (#8815634)
> C still doesn't have generics and I never heard anyone complain.

People who would complain already know not to bother using C.

Re:Everyday hassles in Go by sacado2 on Tuesday December 30, 2014 @05:35PM (#8817125)
To be more fair, I'd say people using C are not people solving abstract problems that can profit from a generic approach.