Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
valyala
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
20 ms
·
331.
▲
Replacing snappy with ZSTD may reduce data transfer costs by 4x
(victoriametrics.com)
3 points
by
valyala
4y ago
|
0 comments
332.
▲
by
valyala
4y ago
In theory the compiler can inline interface method calls without the need to introduce generics. For example, it can detect that the customStruct is passed to the sort.Sort() in the code below, and then instantiate the sort.Sort() code for
333.
▲
by
valyala
4y ago
Agreed with most arguments. A few remarks: > Like strings.Index is an easy loop to write, but it comes up so often Actually, strings.Index() is very non-trivial function partially written in assembly in order to achieve high performance
334.
▲
by
valyala
4y ago
The container/list and container/ring is one of the least useful packages included in the standard Go library, since they aren't used widely in Go programs. It is better from performance and readability PoV to use an ordinary
335.
▲
by
valyala
4y ago
The question is whether the Flags() should return the concrete type instead of FlagSet interface? Another question is whether the additional complexity related to generics worth the ability to get the concrete type from Flags()? In fact, th
336.
▲
by
valyala
4y ago
The sync.Map is a good example , which could benefit from switching to generics. The problem is that this is the only useful case for generics. This case could be implemented in the way similar to built-in map[k]v generic type, which is ava
337.
▲
by
valyala
4y ago
Go is about productivity. It allows writing, extending and maintaining big codebases with lower efforts comparing to assembly or some other programming language out there. This is because of simple "what you read is what you get"
338.
▲
by
valyala
4y ago
Thanks for very strong argument :)
339.
▲
by
valyala
4y ago
Could you provide links to a few Go packages, which implement useful generic-based data structures?
340.
▲
by
valyala
4y ago
Agreed, it's my fault that I didn't explain why maps.DeleteFunc() can be slower than a simple loop with "if" statement inside. The reasons for the slowdown are: - Go compiler may fail to inline the callback passed to the
341.
▲
by
valyala
4y ago
That would be a mistake :(
342.
▲
by
valyala
4y ago
The bytes.Clone() uses non-trivial trick under the hood - `append([]byte{}, b...)`. Compare it to a trivial loop behind maps.Clone(). The strings.Split() implementation is non-trivial because of performance optimizations. The bytes.Equal()
343.
▲
by
valyala
4y ago
Try substituting F generic type with the FlagSet interface - and the code will become more clear without the need to use generics.
344.
▲
by
valyala
4y ago
That's a good example of using generics-based sorting! I think it would be more beneficial to work on compiler optimizations, which could optimize the standard interface-based sort.Slice and sort.Sort to the same level. This shouldn&#
345.
▲
by
valyala
4y ago
Unfortunately, the Go team was misguided by vocal minority who was using the "missing generics" argument as an excuse why they do not switch to Go from their favorite programming languages. The majority of working Go developers we
346.
▲
by
valyala
4y ago
This sounds good in theory. What about practice? Could you provide a few links to popular Go packages, which benefit from using generics?
347.
▲
by
valyala
4y ago
I doubt this library is useful. Some of the provided functions such as Clone(), Clear(), Copy() and Equal() are substituted by simple and readable three-line loops. Others are plain harmful. For example, Keys() and Values() may lead to huge
348.
▲
by
valyala
4y ago
No. I suppose, maintainers of popular open source projects couldn't justify introducing generics into their code. This is exactly my story - I was actively seeking places in VictoriaMetrics codebase, which could benefit from switching
349.
▲
by
valyala
4y ago
But the time spent on designing, implementing and then optimizing the generics is lost. This time could be spent on more valuable things for Go ecosystem.
350.
▲
by
valyala
4y ago
Why to spend time and efforts for adding useless generics in the first place? Maybe it would be better spending this time on performance optimizations, compile times optimizations and binary size optimizations instead.
351.
▲
by
valyala
4y ago
That link admits that the compiler performance was lower than needed in Go1.18 and Go1.19, because of generics, even when compiling Go code without generics. I can confirm this based on my own open source projects written in Go [1]. [1] ht
352.
▲
by
valyala
4y ago
Could you provide a few links to popular open source projects, which switched to generics and got better code because of this?
353.
▲
by
valyala
4y ago
Go1.18 and Go1.19 have slower compile times comparing to Go1.17 even for codebases, which do not use generics. For example, VictoriaMetrics [1] - the project I work on, which is written in Go without generics. [1] https://github.
354.
▲
by
valyala
4y ago
BTW, it is great to see that Go1.20 and the upcoming Go1.21 [1] return to good things instead of generics: - Performance optimizations (profile-guided optimization, GC optimizations, etc.) - Reducing compile times - Reducing binary sizes (i
355.
▲
by
valyala
4y ago
I'm sorry, but I don't get this comment. Go is a great programming language! It is great because it is easy to write, read and maintain programs written in Go. This is because of the following features: - Simple syntax - Fast comp
356.
▲
by
valyala
4y ago
Except that these people now pollute the Internet with freaky packages, which use generics in esoteric ways :)
357.
▲
by
valyala
4y ago
It is great that Go1.20 improves compile times after generics were added in Go1.18 [1]! Overall, I think adding generics to Go was a big mistake. It brings the following drawbacks: - Slower compile times, even if generics aren't used.
358.
▲
Rules Backfilling in Vmalert
(victoriametrics.com)
1 points
by
valyala
4y ago
|
0 comments
359.
▲
by
valyala
4y ago
VictoriaMetrics core developer here. VictoriaMetrics can be used as a drop-in replacement for Prometheus in most cases. It has the following advantages over Prometheus: - Better data compression, so more data can be stored to the same persi
360.
▲
Monitoring benchmark: how to generate 100M samples/s of production-like data
(victoriametrics.com)
1 points
by
valyala
4y ago
|
0 comments
More ›