News for hackers. Stuff that matters.
Re:Go Is a Shop-Built Jig by nl on Thursday September 18, 2014 @05:11AM (#8334351)
Hang on - you are coming from Python and complaining about the lack of generics?

Why? Go types (without generics) are much stronger than in Python aren't they?

Re:Go Is a Shop-Built Jig by spion on Thursday September 18, 2014 @07:04AM (#8334609)
No, they make the language weaker. For example, its impossible to write the `map` function in Go because of type restrictions.

In python, every function is as generic as it can be.

Re:Go Is a Shop-Built Jig by lukasm on Thursday September 18, 2014 @07:34AM (#8334674)
You can write map but it's a lot of boilerplate and you loose types

Map func(interface{}, func(interface{}) interface{}) []interface{}

Re:Go Is a Shop-Built Jig by spion on Thursday September 18, 2014 @08:29AM (#8334826)
You also loose the ability to pass existing functions with your implementation of Map

  Map([]string{"a", "b", "c", "d"}, ToUpper)
Re:Go Is a Shop-Built Jig by nl on Thursday September 18, 2014 @07:39AM (#8334685)
That isn't the case at all. The problem is that the types restrict your functions, so you either have to write a Mao function for every type you want to support, or drop the types altogether.

The situation where you drop the types is the equivalent to Python isn't it?

Re:Go Is a Shop-Built Jig by spion on Thursday September 18, 2014 @08:26AM (#8334814)
Its not because in Go you cannot reuse existing functions that you've written if you drop the types. In python, you can.
Re:Go Is a Shop-Built Jig by mwcampbell on Thursday September 18, 2014 @08:52AM (#8334902)
So, you don't write the map function in Go; you use a plain for loop. Again, Go only focuses on solving real problems, and does so in a mostly imperative style.
Re:Go Is a Shop-Built Jig by polux on Thursday September 18, 2014 @10:24AM (#8335336)
Map is solving the real problem of code duplication for the scenario "create a new list whose elements are the elements of the original list to which f was applied". Not only does it reduce boilerplate but when you read map(f, list) you know that the result is gonna be a new list of the same size, that if f = id you're gonna get the same list, etc. In other words, map has invariants. It captures a tiny subset of all the for loops you can write.

Saying "we don't need map, we have for", is akin to saying "we don't need toUpper, we have for loops" or "we don't need functions, we have goto".