News for hackers. Stuff that matters.
Re:Advent of Code 2022 by discmonkey on Wednesday November 30, 2022 @11:21PM (#33812293)
Time for my yearly tradition of making it to day 4 in Haskell and feeling very smart before completely giving up on the first hard problem that needs regular arrays :)
Re:Advent of Code 2022 by jinwoo68 on Wednesday November 30, 2022 @11:31PM (#33812358)
Try Ocaml instead :)
Re:Advent of Code 2022 by cglong on Thursday December 01, 2022 @12:29AM (#33812709)
Or F# for that .NET ecosystem goodness ;)
Re:Advent of Code 2022 by MrJohz on Thursday December 01, 2022 @02:24AM (#33813348)
I tried that last year, and got worn down by how often I'd Google how to do something and get an answer explaining how recursion works from first principles as opposed to just pointing at the deciding standard library function that did what I needed.

I want to try again this year, do you have any advice for how to get going with Ocaml as someone who has programmed long enough to understand how recursion, linked lists, and all that jazz works, and just wants to figure out how to be productive in the language?

Re:Advent of Code 2022 by bmitc on Thursday December 01, 2022 @02:39AM (#33813448)
I’d recommend using F# maybe. Easier cross-platform story and well documented in the F# guide and reference.

Guide: https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...

Reference: https://fsharp.github.io/fsharp-core-docs/

Also you can use F# notebooks with .NET Interactive and the Polyglot Notebooks Visual Studio Code extension, which is great for something like Advent of Code.

Re:Advent of Code 2022 by jinwoo68 on Thursday December 01, 2022 @11:00AM (#33818030)
I'm not an OCaml expert either. I've used Haskell professionally a little bit and also know OCaml. I find OCaml more practical because you don't have to fight with "pure" functional programming when you really want an imperative algorithm. For example, OCaml provides mutable arrays even though it encourages functional style whenever possible.

One downside of OCaml is that its standard library is not very powerful and there are multiple third party replacements that are popular. Jane Street's base/core, Containers, Batteries Included, to name a few. So you have to make a choice.

Having said that, I think you can live with the built in standard library to solve most of the AOC problems.

Re:Advent of Code 2022 by cdaringe on Friday December 02, 2022 @11:46AM (#33832922)
I did OCaml the passed two years. GPL productivity in OCaml is easily accessible, but you need opam packages. Its not a deeply batteries-included language at all. With the exception of eio, my goto set of base packages are: https://github.com/cdaringe/protohacks/blob/main/dune-projec...

containers is my preferred “add batteries” std lib extension. Also, the ocaml discord chat and discuss forums are very active and welcome to questions

Re:Advent of Code 2022 by kodwx on Monday December 05, 2022 @02:03AM (#33862431)
As a reference, my solutions to advent of code in OCaml (without any external libraries) are here https://github.com/kodwx/advent-of-code
Re:Advent of Code 2022 by stochastastic on Wednesday November 30, 2022 @11:49PM (#33812474)
I’ll be joining you for “see how far I can Haskell (for great good)” this year!

Then I’ll probably fall back on Python. :)

Re:Advent of Code 2022 by drc500free on Wednesday November 30, 2022 @11:52PM (#33812487)
Ditto, but MS Excel. Some problems are much easier, some are... pretty hairy.
Re:Advent of Code 2022 by keyle on Thursday December 01, 2022 @12:00AM (#33812529)
Yeah... Day 1 woohoo C, Zig, etc.

Day 8... Screw it... Python onwards...

Re:Advent of Code 2022 by apple4ever on Thursday December 01, 2022 @12:19AM (#33812641)
Yup but Objective-C for me
Re:Advent of Code 2022 by yakshaving_jgt on Thursday December 01, 2022 @02:23AM (#33813332)
At that point, reach for regular arrays in Haskell :)
Re:Advent of Code 2022 by remify on Thursday December 01, 2022 @04:01AM (#33813966)
That's me but with F# :')
Re:Advent of Code 2022 by mhitza on Thursday December 01, 2022 @06:01AM (#33814776)
I know exactly what you mean. I'm going to try AoC this year again with Haskell, but this time around I'm just going to cheat and use it as an imperative language.

    {-# LANGUAGE BlockArguments #-}
    {-# LANGUAGE Strict #-}

    stateful s' f = runState f s'

    forEach xs state' f = foldM f state' xs

    solve input = forEach input initial_state $ \st current_value -> stateful st do
        ...