News for hackers. Stuff that matters.
Re:Go is Google's language, not ours by pjmlp on Wednesday May 22, 2019 @04:36AM (#19979134)
Not really, that is the hand waving when the issue ever pops up.

Rob Pike already stated publicly that he is against the proposed idea for Go 2.0.

"Rob Pike - Go 2 Draft Specifications" - https://www.youtube.com/watch?v=RIvL2ONhFBI

Re:Go is Google's language, not ours by civility on Wednesday May 22, 2019 @05:25AM (#19979378)
I wonder if they'd ever consider adding hygienic macros instead of templates/generics. To me, that solves the problem of needing to write the same code for float32+float64 and so on. And it doesn't require so much careful thought about the type system, accidentally creating an awkward metalanguage like happened in C++.
Re:Go is Google's language, not ours by marcosdumay on Wednesday May 22, 2019 @06:29PM (#19986237)
Rust people are very glad that Rust brought high-kinded types to replace the most common uses of hygienic macros. Using macros for everything is a nightmare.

About using them as generics, how do you enforce constraints? Unconstrained generics won't lead you far (or better, will lead you far into JS's Wat territory).

Re:Go is Google's language, not ours by civility on Thursday May 23, 2019 @02:40AM (#19989112)
IMO, Rust has a very nice macro system, and this is a good thing (although I'm not familiar with any changes they've made in the last year or two). It's a bad thing that sometimes one needs to resort to the macro system because other features in Rust don't play well together, but that's a long topic with no solution in sight.

> About using them as generics, how do you enforce constraints?

I'm really thinking about the case for numerical algorithms where the exact same code works for different types (say float32 and float64 in Go). It sucks to copy and paste hundreds of lines of code and it sucks to have a separate code generator write your file for you (essentially an external macro processor). Imagine something like the C preprocessor for Go, but without the well known flaws of the C preprocessor:

    #define IMPLEMENT_FOOBAR(NAME, TYPE) \
        void NAME(TYPE* ptr, long len) { \
           hundred lines of implementation here \
        }

    IMPLEMENT_FOOBAR(foobar32, float32)
    IMPLEMENT_FOOBAR(foobar64, float64)
That parametric polymorphic enough for a lot of use cases, and this could work with data structures too.

As for constraints, you can pass function names as arguments too. For instance:

    IMPLEMENT_SORT(sort_baz, baz, bazcompare)
Other proposed features in go, such as the "check" statement for error handling, are probably implementable as a nice macro if you had a good macro language. This means the core language wouldn't have to grow, and features like "check" could be imported from a library. Including features like this in a library means the core language isn't bound by backwards compatibility when a better idea comes along. Old code used the old library, new code uses the new one, and the language stays clean and compatible with both.
Re:Go is Google's language, not ours by pjmlp on Thursday May 23, 2019 @03:15AM (#19989312)
This is how Borland C++ provided support for generics before they got into the ongoing ANSI/ISO standardisation process.

For their first implementation of BIDS, initially provided with Borland C++ 2.0 for MS-DOS.

Finding out the release date is left as exercise for the reader.

Re:Go is Google's language, not ours by iopq on Thursday May 23, 2019 @04:43AM (#19989730)
I see you're reinventing C++
Re:Go is Google's language, not ours by civility on Thursday May 23, 2019 @07:17AM (#19990617)
I guess you missed the part above where I mentioned C++ templates as a cautionary tale about accidentally creating an awkward metalanguage. Besides, Go and Rust are both clearly responses to C++, so it makes sense they would try to provide (reinvent) similar capabilities while avoiding the flaws.
Re:Go is Google's language, not ours by steveklabnik on Wednesday May 22, 2019 @07:46PM (#19986831)
Rust does not have higher kinded types.
Re:Go is Google's language, not ours by chimeracoder on Wednesday May 22, 2019 @10:47AM (#19981750)
> Rob Pike already stated publicly that he is against the proposed idea for Go 2.0.

Rob Pike is not a member of the Go team anymore, and he has not been for several years.

Re:Go is Google's language, not ours by hwj on Thursday May 23, 2019 @01:20PM (#19993738)
That's sad. Was it because of disagreements?
Re:Go is Google's language, not ours by chimeracoder on Thursday May 23, 2019 @01:30PM (#19993855)
> That's sad. Was it because of disagreements?

No, he moved to work full-time on Upspin: https://github.com/upspin/upspin

Re:Go is Google's language, not ours by baby on Wednesday May 22, 2019 @11:02AM (#19981934)
Wow. That makes me happy. The last thing we need in Golang are generics.