I would like to do Advent of Code with Roc again this year.
I plan to use the built-in echo platform. I really like the idea that all the code for a single day is contained in one file.
A template could look like this:
template file
My repo will be here
Are you also doing Advent of Code this year, or has it lost its appeal in the age of AI?
It might be fun to use Roclet
https://ageron.github.io/roclet/
I will 100% be doing AoC this year :grinning_face_with_smiling_eyes:
Its good fun.
or has it lost its appeal in the age of AI?
I don't think so, I suspect most participants will be doing it the old fashioned way for the challenge.
Any chance of getting the https://roc-lang.github.io/roc-playground/ to the latest and greatest for aoc? Could be cool also with "share link", being able to easily share the solutions.
Good idea @Tobias Steckenborn! I'll update it
@Tobias Steckenborn have you tried Roclet?
not yet
Playground is up to date now :)
@Luke Boswell Roclet looks great! The Roc Playground, too! I'm missing autocomplete for functions name though, so I prefer to code in my IDE for now.
This lead me to creating a harness for solving AoC. If anyone finds it useful, just clone the repo and hack away: https://github.com/j-maas/roc-aoc?tab=readme-ov-file
I'm also planning to do this, and I've been doing some old problems with the echo platform here:
https://github.com/Giesch/advent-2015
My impression is that there's fewer people interested in AoC, but the people interested in it are doing weirder stuff with their solutions. Like solving problems in the gnu calculator or whatever.
I do AoC to learn a new language every year. This time it's Roc. I'm confused though, what do you mean by "echo platform"? I thought basic-cli and basic-webserver are platforms, and I don't see any platform import in your repos. Also, I don't see why a platform is needed for AOC-style problems.
Roc has a default or builtin platform that is very simple and has only a single effect, echo! which prints to stdout. It's available without a URL to download or reference a platform -- like a platform-less (or even headerless if you want) app.
This is a complete file... example.roc
main! = |_args| {
echo!("Hello world")
Ok({})
}
$ ~/roc-macos_apple_silicon-0.1.0_RC1/roc example.roc
Hello world
You could use this for AoC if you wanted... pair it with import for your input file https://www.roc-lang.org/examples/IngestFiles/README and you should be off to the races
Understood, thanks! I know I could do echo! without a platform, in my mind that was the "platform-less" setup. Thanks for the clarification.
And btw, this import is a cool feature!
import "some-file.txt" as some_str : Str
import "some-file" as some_bytes : List(U8)
Interesting, can one do this?
import "some-file.txt" as some_lines : List(Str)
I think it needs to be Str or List(U8)
Sincen roc has comptime evaluation, you can import the file as str and then write
as_lines = some_str.split_on("\n")
haha, if you're not careful the whole solution might be ran at compile time :sweat_smile:
Interesting point. I'm curious, any hints what would stop the compiler from evaluating everything at compile time. i.e. when the input got imported it is hardcoded and by the nature of aoc I would suspect that the result is determenistic from its input so what should stop compile time evaluation?
if you make it a thunk then call it at runtime, so I think something like this
import ... as some_str : Str
my_runtime_calc = || { ... # do something with some_str }
main! = || { ...
my_runtime_calc is a lambda/function .. so it wont be evaluated until runtime when you call it
I'm not sure though... the semantics around these features as evolved a lot. I would probably test it out using basic-cli and some clock measurements. But its getting late here.
Ah, yes I might should have guessed that.
No need to try I guess 1 Dez will give us the chance to find out.
Basically who can get all aoc solutiouns run with the same max time which is technically only printing the result :joy:
I'm also looking forward to trying out Roc for AoC this year (it will be my first time using the language)!
I do have several questions though, namely:
Str class is still a bit of a mystery to me -- would it be best to just use List(U8) for AoC things?I guess these questions may be better(?) suited for the #beginners channel... let me know if I should post there instead.
In regards to 1: It's definitely not needed. The only reason I used the basic-cli platform in my AoC harness is to have access to the Utc module for measuring time. Otherwise it only uses Stdout, which is what echo does.
Hi @Jake Keller,
- The
Strclass is still a bit of a mystery to me -- would it be best to just useList(U8)for AoC things?
That should work fine :)
Are there any good repos/projects/whatever to reference to get a feel of Roc?
We have a nice selection of examples here and the Roc Exercism track is an excellent way to get learning by doing.
- How do people manage Roc versions? With the impending 0.1.0 release (and patches leading up to it) this is something I want to be conscious of.
rocup is a community tool for this. It may not support release candidate releases yet @Ian McLerran
Thanks @Johannes Maas and @Anton for the responses, they're very helpful!
I forgot to mention, but the possibility of solving the whole puzzle at comptime is pretty cool. My friends and I sometimes compete on solution speed as well... so that could be quite a fun party trick :smile:
Last updated: Nov 26 2026 at 20:35 UTC