I tried to create a small util that would read unknown beforehand amount of lines from stdin. It reads, checks that the line is not a stop marker, and adds a line to a list.
Not only was it agonizingly slow (about 470 lines per second), but it ran out of stack memory on line 3330.
Was something wrong with my implementation?
Here is my code:
app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.6/2BfGn4M9uWJNhDVeMghGeXNVDFijMfPsmmVeo6M4QjKX.tar.zst" }
import pf.Stdout
read_stdin_until! : Str, List(Str) => List(Str)
read_stdin_until! = |break_str, buffer| {
new_line = Stdin.line!()
if new_line == break_str {
buffer
} else {
read_stdin_until!(break_str, buffer.append(new_line))
}
}
Run result: Roc crashed: This Roc program overflowed its stack memory. This usually means there is infinite recursion somewhere in the code.
P.S. The file that I piped into my Roc app was small: about 25 Kb in total, ~4500 lines with 3-5 chars
Probably an interpretter bug in my opinion.
The interpretter needs to be smart enough to do tail call optimization and avoid these kinds of stack overflows
We dont have any TCO yet I believe
yeah TCO has not been ported over yet
I would normally start porting it, but I've already hit my Claude Max weekly limit halfway through the week, and rather than get a second account (which I did consider) I'm going to use this as a forcing function to spend my time on langref instead :laughing:
Do you guys maybe have any ideas on how to smuggle a file into Roc? I don't want to bring it as a list into the source .roc files because it's a matter of principle now.
I assume that old file import syntax doesn't work on new compiler and since platform doesn't have files API, my only option is stdin. Is that correct? At this point I am considering concatenating all input into one huge line :sweat_smile:. Or maybe read it in chunks to avoid stack growth
But I was curious, of course, about exotic and silly hacks
I think the old file import syntax works but I wouldn't swear to it :smile:
I'm on mobile but I recommend giving it a try!
Yeah I'm pretty sure we haven't implemented the import file stuff yet
Btw you can use basic-cli if you're happy to build the platform from source
Use this branch https://github.com/roc-lang/basic-cli/pull/413
I've just been working through some issues preventing us from completing the other effects, but I think I just solved it -- so hopefully those can migrate now too
Richard Feldman said:
I would normally start porting it, but I've already hit my Claude Max weekly limit halfway through the week, and rather than get a second account (which I did consider) I'm going to use this as a forcing function to spend my time on langref instead :laughing:
I use opus with copilot because copilot doesn't have usage limits, its not a horrible agent either
How does that work? like Opus does the thinking/reasoning and copilot does the tasks?
yeah it's like claude code but its a copilot binary instead of a claude code binary https://github.com/github/copilot-cli
Cool, I'll give that a try when I hit my daily usage limit :smile:
There is a monthly limit and then they charge you but I've hit the monthly multiple months in a row and it just keeps going without ending I dunno if a bug or what. I'm trying not to publicize it too much in case they decide to fix it heh
I've got it up to over 400% last month
turns out their billing UX is just bad, lol got charged 100 bucks for last month usage. Not horrible but still not what I was wanting lol.
Last updated: Jan 12 2026 at 12:19 UTC