Hacker News new | ask | show | jobs
by bashbjorn 1671 days ago
I highly recommend it to explore new programming styles in general. As some others, I use it as an excuse to learn a new language each year.

While I think python is a really great language for advent of code, I'm not sure I'd recommend going for an OOP-heavy style. Although that might just be a matter of personal taste - I think OOP is a poor strategy for most problems.

3 comments

You can go one further - last year I tried to solve every problem in a different language!

I first heard of people doing this for codejam, and it works just as well for AoC

My 2c from the experience,

* I hated Go for this style of programming, but I could see it being good for some production-ready code

* Rust should be renamed to Rustcargo. Even for the most basic of tasks it seems like these two are welded together.

* I still really like Nim as a replacement for Python in my toolbox

> Rust should be renamed to Rustcargo

I much prefer RustCargo to C++BringYourOwnShittyBuildSystem! Cargo definitely one of the bright spots in Rust imho.

Yup. Very much a chance to learn a new (for me) language. Looking to do Golang this year - brushing up on the basics of the language as we roll into a long turkey weekend.
I'm torn between Clojure (totally n00b) or Elixir (mostly to force myself to use it rather than defaulting to Python)
I'm something of an elixir zealot, but I have to say that Clojure has the most pleasurable syntax for this kind of thing out of any programming language.
Being an elixir zealot have you ever considered lisp flavored erlang? If so, what are your thoughts in comparing it to clojure?

https://lfe.io/

I actually have played around with it! I think Clojure feels a lot more polished, but it's also a lot more rigid, which I could definitely see someone disliking. LFE almost feels a little more like Common Lisp, although that's more to do with Erlang and the BEAM than any specific syntax choice. Plus, of course, you get to work with all that OTP goodness. If had to choose between LFE and Clojure as the only language I ever programmed in again, it would be a really hard tossup. Clojure might have a relatively larger community, but I don't want to give up the BEAM!

The reason LFE didn't do it for me was that Elixir is relatively painless syntax-wise, and has really nice high-level libraries like Phoenix and Ecto that simplify a lot of work. If I don't need the BEAM, than I'd rather have a more strictly functional language like Clojure, or something more low-level like Common Lisp. LFE doesn't occupy a niche in my personal ecosystem. That being said, I'd definitely give it another try sometime, and I'd recommend it to anyone else who wants to feel the power of the BEAM.

That's good to know. What is it about the AoC that makes it play into Clojure syntax so well?
Clojure is the most practically expressive language I've ever had the pleasure of working with. For some reason the example that immediately comes to mind is how you can use a collection as an accesser for itself, so ({:a 2 :b 3} :a) returns 2. Just a neat bit of syntactic sugar, but now if 'blacklist' is a set, you can just do (remove blacklist guests) to remove everything in blacklist from guests. There's a hundred little things like that which combine to make it a really fun and concise language to work with.
This year I'm going to try it with Babashka, the native Clojure scripting runtime. See how far it can take me.
Babashka is fast-starting but slow-running (compared to JVM Clojure). AOC puzzles typically contain a lot of loops so you will likely run into the slow-running-ness. But it shouldn't be much trouble to move to Clojure when you hit this.
Clojure is fun to try out. I tried it last year and had a lot of fun combining and finding the right function from its huge expressive vocabulary. It inspires you to treat code as data.
I've had a couple of Clojure books I've meant to work through over the past year. Where I'd get stuck is in the development workflow more so than in the language features or syntax. Clojure (and lisp-like languages in general) seem like my usual edit, save, run loop isn't the most effective way (especially if it's Clojure and the JVM needs to start each time if you run cold).
I can't possibly sing the praises of Cider loudly enough. Emacs is a hard sell, I get that, but Cider is such a nice way of working with Clojure.
I suppose Cider in Doom Emacs means I can keep using the vim keys I already know.
I like OOP approaches a fair bit, but only for relatively large, long-lived systems, especially when working with a team. E.g., the Domain-Driven Design approach can provide a ton of shared clarity.

For something like Advent of Code, though, I'd avoid it. It's just me and it's not for long; there's no need for me to be explicit about how I'm thinking about the problem.