--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
False or not, that's a trichotomy.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Is this like the CAP theorem then, impossible to provide the three options simultaneously?Which option(s) will be favoured in the design of generics for go, according to the goals?
http://www.digitalmars.com/d/archives/digitalmars/D/D_compilation_speed_vs._go_108831.html
go build -a ./... inside src compiles roughly 340K lines of code on my mac
i found all go files inside $GOROOT/src which did not have a different
operating system than the one I'm on as a target
it's easy to count total number of non-test Go source lines in the std library, just an exercise of go list -f:
$ go list -f $'{{range $x := .GoFiles}}{{$.Dir}}/{{$x}}\n{{end}}' std | xargs wc -l | grep total
190780 total
i'm using tip.
right! thank you. xargs is redundant in this case.
i think the main purpose of xargs is to handle extremely long arguments. (I remembered that you critized modern unix for unable to handle arbitrarily long arguments. :))
On Feb 15, 2014 12:48 AM, "Benjamin Measures" <saint....@gmail.com> wrote:
>
> On Saturday, 15 February 2014 05:16:13 UTC, minux wrote:
>>
>> On Feb 14, 2014 11:17 PM, "Benjamin Measures" <saint....@gmail.com> wrote:
>> > That's not all go build does. You should find out what it actually does (-n) before making up comparisons.
>> it's easy to count total number of non-test Go source lines in the std library, just an exercise of go list -f:
>> $ go list -f $'{{range $x := .GoFiles}}{{$.Dir}}/{{$x}}\n{{end}}' std | xargs wc -l | grep total
>> 190780 total
> Doesn't that forget the c files compiled as part of pkg/runtime?
we are talking about the speed of the Go compiler, not C compiler.
> Further, whilst correlated, can you really measure compile kloc/s by measuring build time without taking into account what else the build tool might be doing?
the problem is inherently subtle.
before Go 1.3, the compiler generates some kind of pseudo assembly instructions, which are not actually machine instructions, people might argue that it's not doing the full job of compiler as the code generation is not yet finished. Go 1.3 changes this aspect, so counting the time used by 6g makes sense.
how to only counting the time used by 6g is left as an exercise.
On Feb 15, 2014 12:48 AM, "Benjamin Measures" <saint....@gmail.com> wrote:
> Doesn't that forget the c files compiled as part of pkg/runtime?
we are talking about the speed of the Go compiler, not C compiler.
I measured it. go build -a ./... inside src compiles roughly 340K
lines of code on my mac in 6.1 seconds, ~53K LOC/s.
> Further, whilst correlated, can you really measure compile kloc/s by
> measuring build time without taking into account what else the build tool
> might be doing?
that is the only comparison that has been made: old Go "make.bash" vs
whatever D uses.
"build the standard library as it's usually done".
that comparison is fair vis-à-vis the claim Russ made in the video.
the go build that I posted was only to illustrate that things have not
changed many orders of magnitude since then. they might soon, but have
not yet.
as a community we shouldn't feel threatened, act defensive or question
assumptions as a knee-jerk reaction to someone calling us out on our
claims. D is a fine language, it may compile with speeds within the
same order of magnitude as 6g, it may be even faster. that's OK, I can
live with it. compilation speed isn't the only thing I'm here for.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Since different languages represent more and less in a line of code, how is the metric meaningful?I wrote the fast string output routines for math/big; base 2 and 8 are faster in digits/sec than base 10, but they also need more digits to express the same number. Seems related to the KLOC/sec race. Better might be "compiling programs that do ${X/sec} "/per second, for X = sort 1M ints or invert 100x100 matrix, or ...
On Feb 15, 2014 8:51 PM, "Jonathan Amsterdam" <jbams...@gmail.com> wrote:
> Aren't we splitting hairs at this point? Whatever the exact relative speeds of dmd and 6g, it seems as if D doesn't pay too much of a compilation penalty for its generics, which is an existence proof that you can have generics and fast compilation.
the point is not that generics will necessarily slow down compilation. It's that you can't get all these:
1. fast compilation,
2. non-bloated binary,
3. efficient runtime
along with generics.
for example, we can just add generics as syntax sugar for a reflection-based solution, and that won't affect compilation speed much, but do you want that kind of generics?
Potentially unbounded compilation times are unacceptable for Go.
On Sunday, February 16, 2014 11:03:38 AM UTC+1, Aram Hăvărneanu wrote:Potentially unbounded compilation times are unacceptable for Go.Potentially unbounded run times are also unacceptable for Go. So, Go shouldn't be Turing complete.Not true, of course. The potential is desired, even necessary. What's undesired are actual unbounded run times (ignoring, of course, programs that are meant to run forever).The same should hold true for compilation times.
Anyone that used languages with module support in the early 80's has experienced fast compilation times.
Let's not forget Ada, Eiffel, Modula-3 and many other languages that enjoy generics, modules and have/had fast compilers available, even
if they are not well known to most blue collar developers.
Hi all,I came across a set of recent slides about Go, given by Russ Cox. This one in particular stood out: http://talks.golang.org/2014/research.slide#24I feel the options being presented are a sort of false dichotomy -- either (1) slow down the programmer, (2) slow down the compiler and bloat the binary, or (3) slow down the runtime.There are many languages other than the ones presented that successfully employ generics. The D language authors claim that it compiles as fast -- or faster -- than Go. D is a very meta-programming heavy language. So clearly a solution is available; though with statements like the ones in the slide above, I keep getting the feeling other language implementations are being overlooked.
How about this: do people want generics, or no-cost generics? I don't imagine it'd be too difficult to just give Go 2.0 syntactic sugar for the reflection-based generic programming that is currently possible.
That would stop all the 'Go doesn't have generics' complaints, and if people complained about the speed it'd be a simple matter of pointing out that even reflection-based generics in Go are still faster than Python, Ruby and Scheme's generics (and maybe faster than C# Mono's and naive Haskell's) since the language as a whole is faster.
The reason people [should] want generics in Go is because it provides compiler-verifiable safety to type-agnostic algorithms; Java-style type erasure provides that. The reason that Go doesn't already have Java-style generics is because they're slow and memory inefficient, and the Java approach is even strictly better than what you're describing (which is merely syntactic sugar -- no stated implications in regards to safety).
.From the testing I did about a year ago, heavy reflection-based generic algorithms in Go are much slower than equivalents in Python. Further, languages themselves aren't slow or fast -- their implementations are.
How about this: do people want generics, or no-cost generics?
I don't imagine it'd be too difficult to just give Go 2.0 syntactic sugar for the reflection-based generic programming that is currently possible.
> Going back to the original question, "Do you want slow programmers, slow compilers and bloated binaries, or slow execution?"
Just my personal feeling: If the percent change in each of the four options is the same (it really isn’t, is it?), then my first choice would be bloated binary. I don’t much care if a 3M binary becomes 6M, for example.
My second choice would be slower compiles. If I can save half the programmer time at the cost of doubling the compile time, then my development cycle would be much faster.
The last thing I would want is slow programmers, so unless I was up against the wall I’d sacrifice execution time next.
John
John Souvestre - New Orleans LA
--
> Going back to the original question, "Do you want slow programmers, slow compilers and bloated binaries, or slow execution?"
Follow-up question: If Go were to have Generics, would the above four ailments exist in all Go programs, or just those which chose to use Generics?
John
John Souvestre - New Orleans LA
> Going back to the original question, "Do you want slow programmers, slow compilers and bloated binaries, or slow execution?"
Just my personal feeling: If the percent change in each of the four options is the same (it really isn’t, is it?), then my first choice would be bloated binary. I don’t much care if a 3M binary becomes 6M, for example.
My second choice would be slower compiles.
Why runtime checks? Seems to me it would be faster and much safer for the compiler to implicitly detect types and error check at compile time. That way, in your example, if I tried to add say, structs, it would fail to compile rather than panic at runtime. It should also be faster at runtime on account of no reflection. I'm not really a huge proponent of generics, nor really well versed in design, so am ready to be educated on why this is a bad idea...
I don't know if "easy of implementation" is an official requirement for Go, but that is very important in the long run. If the final choice is that Go isn't going to support templates just to keep compilers simple and easy to implement, I have no problem with that.
cbrt(x)
translates to cbrtl(x)
, cbrt(x)
or cbrtf(x)
depending on the type of x
:
#define cbrt(X) _Generic((X), long double: cbrtl, \
default: cbrt, \
float: cbrtf)(X)
On Monday, 17 February 2014 21:26:04 UTC+11, Benjamin Measures wrote:The sort package is "generic" but doesn't use reflection. What "syntactic sugar" do you suggest to make this package better?I don't have any problem with the sort package, actually, rather I meant syntactic sugar for when people want to make their own generic functions. For instance, so that someone can write:
func addThree(a, b, c Box) Box{
return a + b + c
}
func max(a, b T) T {if a > b {return a} else {return b}}
How I wish we can do something like this:import "fmt"type T genericfunc max(a, b T) T {if a > b {return a} else {return b}}func main(){mi := max(10, 20) `where:"T(int)"`mf := max(20.5, 30.5) `where:"T(float)"`fmt.Println(mi, mf)}
On the original issue of it being basically impossible to have generics and fast compilation
D compiles fast enough forhttp://d.puremagic.com/issues/show_bug.cgi?id=10693 this to be a moot point.
On Monday, 17 February 2014 21:41:31 UTC, atila...@gmail.com wrote:D compiles fast enough forhttp://d.puremagic.com/issues/show_bug.cgi?id=10693 this to be a moot point.
On Monday, 17 February 2014 21:41:31 UTC, atila...@gmail.com wrote:
D compiles fast enough for this to be a moot point.
To achieve native speed for a generic algorithm, Go would need to opt for an interface/indirection based design and/or several specialized implementations. In the first case, compilation stays fast but siphons runtime speed away. In the second case, compilation is as fast as generics but it siphons away developer time spent on duplicated code.
On Monday, February 17, 2014 8:01:57 AM UTC+2, Andrei Alexandrescu wrote:To achieve native speed for a generic algorithm, Go would need to opt for an interface/indirection based design and/or several specialized implementations. In the first case, compilation stays fast but siphons runtime speed away. In the second case, compilation is as fast as generics but it siphons away developer time spent on duplicated code.
Wouldn't it be possible to offer a "specialize me" option for generic types and methods? The system would be using interface based implementation except if asked to specialize. Executable bloat would be minimal, yet there would be no developer time spent on duplicated code. The coder just needs to declare which specializations are needed. If the profiler could tell time spent in generic methods for each different type, it would be easy to spot when you might need a specialized version.
The system would be something like:
type HeapItem generic Comparable
None of the creators of Go either overlooks the value of generics nor that an implementation one day may exist.
The original statements about generics as I interpret them is just that there are these potential trade offs and until we find a good compromise we will not add it.
They have stated repeatedly on and off this list that they (to a varying degree i am sure) don't dismiss generics but want to find a good solution that fits the spirit of the language. That last was my ad-lib but probably not far from the truth.
Who is actively researching generics for Go? I have no idea, surely there someone?
On Tuesday, February 18, 2014 4:56:39 PM UTC+8, Henrik Johansson wrote:None of the creators of Go either overlooks the value of generics nor that an implementation one day may exist.How do you know this?
The original statements about generics as I interpret them is just that there are these potential trade offs and until we find a good compromise we will not add it.So who's actively looking for that good compromise?
And are the tradefoffs real and absolutely necessary? We just know for sure that some people -- including Go core team-- think yes, and other people --including designers of other languages like Andrei-- think it's an invalid trichotomy.