Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Advent of Code 2024 - Using Cppfront #1354

Lathentar started this conversation in Show and tell
Discussion options

Hello all! I'm not very active on Github, but have been following Cpp2/Cppfront for about a year now and decided to try 2024's Advent of Code using Cpp2 after doing it in Rust the previous few years. I saw at least one other person sharing their repository as well so I thought it might be worth sharing mine and seeing if others also participated.

You can find my solution to all 25 days here: https://github.com/Lathentar/aoc_2024

This was my first time using Cpp2/Cppfront even though I've been following along for most of 2024. I've been working professionally in C++ for nearly 20 years, though I've been limited to using C++17 due to the constraints of my work environment (video games).

I used Visual Studio 2022 but ran into a few difficulties in the initial setup. I found that I needed to use /std:c++latest and set Build ISO C++ 23 Standard Library Modules to Yes to get anything to compile. Once, I got through that however the experience was pretty great outside of fighting the IDE a bit with the unrecognized syntax. I set up a simple one cpp2 file project that was a template I could copy for each day with some simple code to read in the passed in filename to be parsed.

After just a couple of days I started to feel much more comfortable with the new syntax and started to use the metafunctions (wonderful!), primarily @value and @enum (love it), as well as some C++ functionality I haven't used professionally such as the ranges and views APIs. I did miss having access to switch statements, but I see there is something called inspect (I guess it's just not documented yet). Additionally, I ran into a few annoyances where the last time an object was used it would be compiles to std::move( object ) even though it was being passed into a function that expected it to be in the inout format. This causes some compile errors where I worked around it by doing a _ = object on the next line.

Overall, there is potentially a wonderful future here for C++ with Cpp2 and I look forward to it developing further. I will want to spend some time with future releases building more complex programs with multiple files and trying out Visual Studio Code to see if that development environment is more friendly. If many of the above frictions were significantly improved with a 1.0.0 release, I would strongly consider using this professionally.

Thank you for all the great work all of you have done in this community!

You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

@Lathentar The creator of AoC has asked people not to share their personal inputs.
https://adventofcode.com/2024/about

Can I copy/redistribute part of Advent of Code?
Please don't. Advent of Code is free to use, not free to copy. If you're posting a code repository somewhere, please don't include parts of Advent of Code like the puzzle text or your inputs.

You must be logged in to vote
2 replies
Comment options

Thanks for the heads up. I'll take care of that tonight.

Comment options

You're welcome.

Comment options

2017 was my first year doing it, and I did it in C++. I've done all the other ones since then (and went back and did the two years before that) in Go, mainly for the library and faster cycle time.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /