Fun with Go Iterators

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • go

    The Go programming language

    It is a consequence of (a) Go's implicit relationship between a concrete type and the interfaces it implements and (b) Go's "heterogenous" translation of generics (like C++, unlike Java). Together, this means you can't know which methods you need a priori. All proposed solutions to date essentially compromise on (a) by limiting the generic "implements" relation to things known at build time, or on (b) by making generic methods "homegenous" (aka boxed) and thus slow.

    See https://github.com/golang/go/issues/49085#issuecomment-23163... for an example of the latter.

  • CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  • lo

    💥 A Lodash-style Go library based on Go 1.18+ Generics (map, filter, contains, find...)

    Might be interesting to make a library that competes with https://github.com/samber/lo?

  • go-extlib

    Go Extended Lib

    Back when the Go team announced generics, I had a go (pun intended) at it: https://github.com/gtramontina/go-extlib -- might resurrect it one day. `lo` is pretty comprehensive though.

  • glinq

    Go port of DotNet LINQ using generics introduced in Go 1.18

    Here's one: https://github.com/szmcdull/glinq It doesn't do function chaining though.

  • it

    iterator library for go using a rangefunc experiment (by gomoni)

    Shameless plug. I had experimented with Go iterators a while ago and did a https://github.com/gomoni/it

    It was updated to 1.23, so it is as idiomatic as I can get. And yes it has a map method between two types. Just a single simple trick used.

  • project-anvil

    The argument types for lambdas need to be provided to work around C# lacking full Hindler-Milner type inference, but this iterator expression is fully statically dispatched and monomorphized save for the lambdas themselves. Luckily, JIT can profile the exact method types passed to Funcs and perform further guarded devirtualization, putting this code painfully close to the way Rust's iterators are compiled.

    [0]: https://github.com/neon-sunset/project-anvil/blob/master/Sou...

  • pubsub

    A generic pubsub implementation for Go (by picosh)

    We just released a go pkg that uses the new iter pkg. We were so excited by the interface in large part because of how simple iterators are to use.

    https://github.com/picosh/pubsub/blob/main/pubsub.go#L18

    We have seen in other languages like JS and python the power of iterators and we are happy to see it in Go

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  • ply

    Painless polymorphism (by lukechampine)

    ah, that's what it's called! I did this in my compile-to-Go language, but I didn't know the name for it: https://github.com/lukechampine/ply?tab=readme-ov-file#suppo...

  • rust-playground

    The Rust Playground

    Funny enough, the iterator version is much faster in rust because the compiler can more easily optimize iterator chains than custom for loops:

    https://play.rust-lang.org/?version=stable&mode=release&edit...

    (I'd recommend running it on your own machine as the rust playground limits memory and will likely kill this program)

    Output from my machine:

        $ cargo run --release

  • RxJS

    A reactive programming library for JavaScript

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Go is not an easy language (2021)

    1 project | news.ycombinator.com | 14 Jan 2024
  • Functional Programming Library for Golang by IBM

    8 projects | news.ycombinator.com | 17 Aug 2023
  • A lightweight Golang generics library that provides Map, Reduce and more

    1 project | /r/golang | 17 Aug 2023
  • A lightweight Golang generics library that provides Map, Reduce and more

    1 project | news.ycombinator.com | 14 Aug 2023
  • A lightweight Golang generics library that provides Map, Reduce and more

    1 project | news.ycombinator.com | 12 Aug 2023

Did you konow that Go is
the 4th most popular programming language
based on number of metions?