News for hackers. Stuff that matters.
Re:"100% of our production system is now running Go" by draven on Friday August 31, 2012 @04:19AM (#4458793)
Go has interfaces, which can be used to write generic code. Go performance is not on par with optimized C++ but for me it's fast enough and the performance / dev_time ratio is higher.
Re:"100% of our production system is now running Go" by qznc on Friday August 31, 2012 @04:57AM (#4458883)
http://golang.org/pkg/container/list/

Casting every list element to "interface{}" is not generic.

Re:"100% of our production system is now running Go" by luriel on Friday August 31, 2012 @05:27AM (#4458935)
Use slices.

Really, maybe we should remove container/* completely, so we don't have to answer this stuff over and over again.

Re:"100% of our production system is now running Go" by qznc on Friday August 31, 2012 @06:43AM (#4459087)
Slice still restricts you to an array data structure (a continuous block of memory). How would you implement a sorted set in Go? It should be generic and type safe and efficient, please. Compare with the C++ solution.
Re:"100% of our production system is now running Go" by draven on Friday August 31, 2012 @07:51AM (#4459235)
I think the problem with saying that Go can be used as a C++ replacement is that the statement is too vague. The problem space in which Go is a great tool and the one in which C++ is a great solution have a big overlap. But that does not mean that you will solve a given problem in this overlapping space the same way. Both languages have a different set of trade-offs.

If you need a typesafe, generic sorted set with strict efficiency needs (or things like precise control over memory layout and such) then by all means go for C++, it's been designed for that kind of constraints.

Re:"100% of our production system is now running Go" by luriel on Friday August 31, 2012 @10:47AM (#4459927)
> If you need a typesafe, generic sorted set with strict efficiency needs

When people ask for things like this, I can't help to think that what they want is not generic at all, they want something very specific to the problem they are solving, in those cases just writing custom data structures is the way to go in any language anyway.

It is the way it has been done in C for decades too.

Re:"100% of our production system is now running Go" by kragen on Saturday September 01, 2012 @11:50AM (#4464041)
You may be able to write the custom data structures more easily with the STL than in C.
Re:"100% of our production system is now running Go" by draven on Friday August 31, 2012 @05:43AM (#4458972)
Go does not have generics per se but that container looks pretty generic to me.

What's your definition of generic programming BTW? I'm looking at several definition right now and cannot find out if, for example, a generic list container in C using void pointers to data would be considered generic programming.

Wikipedia states generic programming is "a computer programming paradigm based on method/functions or classes defined irrespective of the concrete data types used upon instantiation". That reads like "templates" to me.

Re:"100% of our production system is now running Go" by microtherion on Friday August 31, 2012 @06:37AM (#4459076)
To me, generic programming implies preserving all type information, which is something the above Go container does not do (when you get an element out of the container, you cannot tell statically what type it is).

Templates are generic, but so is, e.g. the type inference used in functional languages.

Re:"100% of our production system is now running Go" by qznc on Friday August 31, 2012 @06:44AM (#4459093)
In some sense, you can do generic programming with C by using void*, but this throws out type safety.
Re:"100% of our production system is now running Go" by sixbrx on Friday August 31, 2012 @08:55AM (#4459445)
I'd say void pointers are more untyped programming than generic programming.