News for hackers. Stuff that matters.
Re:Go 1.11 and Beyond by coldtea on Saturday August 25, 2018 @02:24PM (#17841858)
Stability is good is what's stable meets your needs.

The more they stall adding stuff like generics the more painful (and more work for the tools and ecosystem to catch up) will be when they eventually cave in and do it...

And there will always be all the workarounds, third party solutions, and wasted efforts that would could have been avoided if something that could have been delivered early on (like e.g. package management) didn't come a decade late for no good reason.

At least now they've come up with a module/dependency system, which, even though a decade late, doesn't bring anything extraordinary to the table compared to what other platforms already had for ages.

Generics and error management remain before it makes sense to make it stable and boring for eternity...

Re:Go 1.11 and Beyond by dilatedmind on Saturday August 25, 2018 @03:25PM (#17842142)
When I think of generics i think custom data structures. Currently you are stuck with interfaces, but you can also wrap a library returning interfaces with methods operating on a specific type.

I would be interested to hear about use cases that couldn't be solved in this manner

Re:Go 1.11 and Beyond by tree_of_item on Saturday August 25, 2018 @03:27PM (#17842153)
"Solved" by having lots of meaningless unsafe glue code. That's not a solution.

It sounds like you're going to reject proposals for generics on the grounds that "you could just cast values of type `interface{}`" unless someone can show you a situation where you can't do that. The problem is that the people who want this sort of feature don't think that's even a solution.

Re:Go 1.11 and Beyond by dilatedmind on Saturday August 25, 2018 @03:31PM (#17842175)
I am legitimately asking, it's not something I have personally had much issue with. If you have some compelling example, please share your experience
Re:Go 1.11 and Beyond by lederhosen on Saturday August 25, 2018 @03:54PM (#17842297)
You can not have a custom collection class containing objects _only_ of a certain type. For example ConcurrentHashTable<Int, String>. That is something that is used every single day. It is used so frequently that Go has generic slice and map built into the language. That is, they created a language with lots of special datatypes that can not be created in normal Go because of its lack of generics instead of creating generics.

It is a bit like asking a Java-programmer to use Java 1.4.

When you ask a Java programmer, or C# programmer or Haskell programmer or Swift programmer or... what they would change in the language you do not get the answer: remove generics.

Re:Go 1.11 and Beyond by dilatedmind on Saturday August 25, 2018 @05:01PM (#17842547)
Not without either implementing it yourself or wrapping interface methods.

Go generate is like a manual step for having generics, I imagine one day soon its functionality or something similar will be part of go build.

In response to your particular example, a map plus a mutex seems sufficient.

I dig that it's a few extra lines of code, but I guess I'm looking for a really mean example.

Re:Go 1.11 and Beyond by coldtea on Saturday August 25, 2018 @09:21PM (#17843649)
>I dig that it's a few extra lines of code, but I guess I'm looking for a really mean example.

Well, if you don't care about repeating yourself, mistakes by omission, needless boilerplate, and/or loss of type safety, then, sure, everything is possible in "a few extra lines of code" in a turing complete language...

Re:Go 1.11 and Beyond by lederhosen on Saturday August 25, 2018 @05:44PM (#17842733)
I can not create a really mean example because Go is Turing complete. That means that everything can (with a few extra lines) be expressed in Go.

The problem with your mutex solution is at least two:

1) it is more complex

* more lines to type and read and check and thus harder to understand

* you can forget the mutex

* if you have data structures of hastables, you will have to pass mutexes around or store them together with the tables.

2) it is not nearly as performent as a lock free hash table

(edit indentation)

Re:Go 1.11 and Beyond by pjmlp on Sunday August 26, 2018 @03:21AM (#17844730)
Back when Borland C++ 2.0 came out for MS-DOS, templates were still being designed.

So the first version of BIDS, Borland's C++ data structures library, used pre-processor tricks where one defined the types before including the respective data structure.

So go generate as workaround feels quite old.

Re:Go 1.11 and Beyond by taeric on Saturday August 25, 2018 @05:16PM (#17842617)
Oddly, I have pushed back on many devs introducing generic interfaces. For library writers, they can be nice. For everyone else, they typically just get you in trouble.

So, I don't want to remove them from the language. However, I do question a large percentage is their use in everyday programming.

Re:Go 1.11 and Beyond by lederhosen on Saturday August 25, 2018 @05:59PM (#17842811)
Generics are useful all the time. That is why Go has generic Maps and slices. The question is why I am not allowed to use other generic collections.
Re:Go 1.11 and Beyond by taeric on Saturday August 25, 2018 @07:34PM (#17843180)
No, generic collections are pretty much useful all of the time. Other generic things are useful when done well.
Re:Go 1.11 and Beyond by nordsieck on Saturday August 25, 2018 @04:22PM (#17842407)
> You can not have a custom collection class containing objects _only_ of a certain type. For example ConcurrentHashTable<Int, String>.

I'll start by saying - I largely agree with you. Libraries, particularly of data structures, are the biggest weakness of Go as a language.

However, this bit is not really fair:

> When you ask a Java programmer, or C# programmer or Haskell programmer or Swift programmer or... what they would change in the language you do not get the answer: remove generics.

Much like values, language features need to be compared to each other, not evaluated in isolation.

Everyone likes loyalty, but some people value it over honesty and some value the reverse.

Everyone likes generics, but some people value faster compile times, a more simple language implementation and a lower learning curve more. Some people value it less.

Re:Go 1.11 and Beyond by lederhosen on Saturday August 25, 2018 @05:15PM (#17842609)
If you value compile times (and you actually think generics make a difference, I do not) you would not make slices and hash tables generic like in Go, would you?

If you wanted a simpler language, you would not make slices and hash tables generic, would you?

If you wanted lower learning curve, you would not make special case generics would you?

If you wanted to wait, to get the perfect generic solution because a sub-optimal one is not good enough, you would not create a sub-optimal non-perfect temporal solution with special-cased generics for certain data types would you?

If you argue that I am loyal and not honest, and therefore like generics because it is used in my favorite language, I think you are wrong.

The languages I use most of the time have a huge design flaw. It is called null. But when they created Go they chose to (except in special cases) get rid of (useful) generics instead of the disaster that is null.

The problem is that Go has not learnt from other languages. It is too imperative, not expressive enough, lacking in static typing and horrible at fault handling.

Re:Go 1.11 and Beyond by foldr on Saturday August 25, 2018 @06:01PM (#17842823)
>(and you actually think generics make a difference, I do not)

It's pretty difficult for generics not to adversely affect compile times. This is especially so if you actually emit specialized code for each type.

Re:Go 1.11 and Beyond by coldtea on Saturday August 25, 2018 @09:23PM (#17843662)
>It's pretty difficult for generics not to adversely affect compile times.

Compared to what? Non having type-specific code?

Because if you manually write (or use code generation madness as some propose) that type specific code you need yourself, then the compiler will take the same time to compile it as if generics were a language feature.

Re:Go 1.11 and Beyond by foldr on Sunday August 26, 2018 @06:49AM (#17845290)
The compiler also has to generate the specialized code. But I suspect that the main factor here is just that the presence of generics in a language encourages the use of generic programming to an extent that wouldn't be practical in a language without generics. Take e.g. the boost geometry library (C++). Theoretically you could write a similarly generic library in Go using code generation, and it would probably take ages to build too. Of course, no-one would actually do this.
Re:Go 1.11 and Beyond by pjmlp on Sunday August 26, 2018 @03:25AM (#17844740)
I bet CLU generics as designed in 1971 hardware would compile quite fast on modern hardware.
Re:Go 1.11 and Beyond by foldr on Sunday August 26, 2018 @06:46AM (#17845281)
Maybe. I don't know. It is pretty difficult to find examples of languages with generics that have compile times comparable to those of Go.
Re:Go 1.11 and Beyond by pjmlp on Sunday August 26, 2018 @07:46AM (#17845481)
Easy, CLU (1971), ML (1973), Ada (1983), .NET (2003), Delphi (2007), D (2007).

Not every implementation needs to be turing complete C++ style.

Re:Go 1.11 and Beyond by foldr on Sunday August 26, 2018 @08:39AM (#17845680)
I don't know anything about CLU. ML compilers are a mixed bag. OCaml (which is a different dialect, of course), has an acceptably fast compiler, but it's not near-instant like Go. Ada compilers are famous for being slow, at least historically. C# is, again, acceptably quick to compile, but not as quick as Go. I don't know about D. I've heard good things about Delphi's compile times, but no-one uses it now.
Re:Go 1.11 and Beyond by pjmlp on Sunday August 26, 2018 @10:56AM (#17846180)
In that comparison you forgot the part of turning off optimizations so that the code quality is similar to what Go standard compiler spends time doing.

The compilation speed drop is easily seen when using gccgo instead.

A side note for Delphi, it is still relatively used in European enterprises, with an yearly conference in Germany.

And I could have mentioned other languages like Eiffel, with their mixed JIT for development and AOT via C compilers for final delivery.

Re:Go 1.11 and Beyond by foldr on Sunday August 26, 2018 @01:33PM (#17846852)
The Go compiler is still faster than most of the competition, even when you compare with optimizations turned off.
Re:Go 1.11 and Beyond by pjmlp on Sunday August 26, 2018 @02:19PM (#17847090)
So you hardly know the languages, never used some of them, but Go compiler is faster.

Very scientific.

Re:Go 1.11 and Beyond by foldr on Sunday August 26, 2018 @04:58PM (#17847874)
>So you hardly know the languages

No, I know all of the languages that you mentioned except CLU. And since I don't think there are even any practical CLU implementations available for modern hardware, I'm not sure how you are able to compare CLU compile times to Go compile times. Are you maintaining a legacy CLU codebase or something?

Now, if there are scientific comparisons available, I'll happily defer to those. But unless you spend inordinate amounts of your time comparing compile times between languages, I doubt that you have any scientific info to go on either.

Re:Go 1.11 and Beyond by pjmlp on Sunday August 26, 2018 @05:26PM (#17848013)
> I don't know about D. I've heard good things about Delphi's compile times

Doesn't look like actually knowing them to me.

> Are you maintaining a legacy CLU codebase or something?

No, just you are apparently stating that a CLU compiler developed to be usable in 1971 hardware will run slower than Go on 2018 hardware, which doesn't make much sense.

Talking numbers, D was taking 1.24s to compile its complete standard library in 2010, (too lazy to try out the latest version) including the piles of template code that it has.

https://digitalmars.com/d/archives/digitalmars/D/D_compilati...

Re:Go 1.11 and Beyond by foldr on Monday August 27, 2018 @08:35AM (#17851036)
> Talking numbers, D was taking 1.24s to compile its complete standard library in 2010, (too lazy to try out the latest version) including the piles of template code that it has.

I followed in the instructions for building Phobos on the wiki here at https://wiki.dlang.org/Building_under_Posix:

    real	0m12.269s
    user	0m12.896s
    sys	        0m2.150s
Quite a lot of that time appears to be spent linking. I wonder if the post on the mailing list was reporting the literal compile time, rather than the build time?

It was a bit difficult to find a go project of similar size that was easy to build. The backend component of limetext is about 10k LOC compared to 35k for Phobos. When I do a ‘time go build -o foo’ in go/src/github.com/limetext/backend, I get the following:

    real	0m0.163s
    user	0m0.140s
    sys	0m0.207s
Multiply that by 3 plus a bit to compensate for the LOC difference, and it's still pretty good.

Still no idea what you are on getting with regard to CLU. We don't have any info on how fast it compiled.

Re:Go 1.11 and Beyond by mseepgood on Saturday August 25, 2018 @03:31PM (#17842173)
> At least now they've come up with a module/dependency system, which, even though a decade late, doesn't bring anything extraordinary to the table compared to what other platforms already had for ages.

I don't think you fully grasp the breakthrough that the theory behind Go modules is for dependency management in general. It vastly improves on and simplifies anything that existed in this domain before.

It's like saying Copernican heliocentrism didn't bring anything extraordinary to the table compared to Ptolemaic geocentrism. https://en.wikipedia.org/wiki/Copernican_Revolution#/media/F...

Re:Go 1.11 and Beyond by ghthor on Saturday August 25, 2018 @03:39PM (#17842226)
It really does. Our codebase is very large and I'm a member of the team responsible for the build system and language tooling. Java library resolving in our repo can take 45mins from a clean build. Python is better, and we've managed to lock it down to offline only sources so libraries never update on us out of the blue. I've been a gopher since the the first announcement and I'm so excited that Russ Cox discovered a simple way to declare and resolve dependencies that avoids the SMT solver nightmare that I've seen bog down progress in every major project I've been involved in, from Ocaml and Haskell to python, java, rust and javascript (security nightmares every night here).

One of my greatest hopes is I can convince my teammates that its be worth the time investment to transition all our dependencies management ecosystems into the Minimum Version Selection algorithm.

Re:Go 1.11 and Beyond by etaoins on Saturday August 25, 2018 @04:39PM (#17842471)
It’s a slightly simplified version of Cargo which itself is an evolution of what yarn/npm/sbt/etc are doing. This is explicitly called out in the vgo paper.

It only seems like a revolution because the previous situation in Go was such a mess. As someone that writes a lot of both Rust and Go I’m not nearly as impressed.

Re:Go 1.11 and Beyond by coldtea on Saturday August 25, 2018 @09:28PM (#17843677)
>It vastly improves on and simplifies anything that existed in this domain before.

I've read the specs and justification posts. I don't find it gives anything better (and in some ways it's worse) than what can be achieved with, e.g. cargo.

>It's like saying Copernican heliocentrism didn't bring anything extraordinary to the table compared to Ptolemaic geocentrism

Yeah, it's like saying that, with the only difference that we're actually talking about something that brought nothing extraordinary here (as opposed in the contrived example).

Re:Go 1.11 and Beyond by unethical_ban on Saturday August 25, 2018 @04:15PM (#17842384)
What am I missing? It's a dependency declaration file.