Stream: show and tell

Topic: syntax evolution in Rocci Bird


view this post on Zulip Richard Feldman (Jun 08 2026 at 03:28):

I'm looking through rocci bird updates (to the new compiler), and wow...the gap between this original function and the new one is really dramatic!

view this post on Zulip Richard Feldman (Jun 08 2026 at 03:29):

original function:

startingPlants : Task (List Plant) []
startingPlants =
    List.range { start: At 0, end: At 14 }
    |> List.walk (Task.ok (List.withCapacity 20)) \task, i ->
        plant <- randomPlant (i * 12) |> Task.await
        current <- task |> Task.await

        current
        |> List.append plant
        |> Task.ok

view this post on Zulip Richard Feldman (Jun 08 2026 at 03:31):

new one:

starting_plants! : () => List(Plant)
starting_plants! = || {
    0.to(15).map!(|i| random_plant!(i * 12)).collect()
}

view this post on Zulip Richard Feldman (Jun 08 2026 at 03:37):

(related: I have now found a motivating use case for map! :joy:)

view this post on Zulip Richard Feldman (Jun 08 2026 at 03:39):

also this will be faster at runtime because it's not instantiating a list at runtime like the old one (since 0.to(15) returns an Iter, not a List) - not to mention no Task data structures

view this post on Zulip Luke Boswell (Jun 08 2026 at 03:43):

So much clearer too


Last updated: Jun 16 2026 at 16:19 UTC