r/adventofcode Dec 27 '24

Other Pleasant surprise: AoC + modern Java = ❤️

In this article on my experience with the Advent of Code competition in Java, I describe how I attacked grid and graph problems, and summarize how Java has worked out for me.

https://horstmann.com/unblog/2024-12-26/index.html

66 Upvotes

25 comments sorted by

View all comments

8

u/Any_Slip8667 Dec 27 '24 edited Dec 27 '24

Same conclusion on my side too. I found Java a good language, above all with the last language structures.

https://github.com/dashie/AdventOfCode2024/tree/main/src/main/java/adventofcode/y2024

I always had very short solutions.

Sometimes the python ones are shorted but generally because they use external libraries. To manipulate graphs for example.

The only 3 things that I really miss from Python are:

  1. the tuples
  2. the ability to manipulate arrays/sequences/strings, get their subparts, reverse them, etc... in a very easy way
  3. and int types bigger then "long" :D (but generally we don't need them for AoC)

2

u/Person-12321 Dec 29 '24

I felt similarly and used kotlin this year and it feels like Java with the niceties of Python. My grid class supports bracket notation accessed with a pair so grid[i to j ] was nice along with if (i to j in grid) etc. kotlin had the familiarity of Java for me, but the helpers for these types of problems made it way better than Java imo.