7 ms·
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 ar
by discmonkey 4y ago
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 :)
- jinwoo68 4y agoTry Ocaml instead :)
- cglong 4y agoOr F# for that .NET ecosystem goodness ;)
- MrJohz 4y agoI 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?
- cdaringe 4y agoI 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-project#L24 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
- kodwx 4y agoAs a reference, my solutions to advent of code in OCaml (without any external libraries) are here https://github.com/kodwx/advent-of-code https://github.com/kodwx/advent-of-code
- bmitc 4y agoI’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-reference/ https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref... Reference: https://fsharp.github.io/fsharp-core-docs/ 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.
- jinwoo68 4y agoI'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.
- stochastastic 4y agoI’ll be joining you for “see how far I can Haskell (for great good)” this year! Then I’ll probably fall back on Python. :)
- drc500free 4y agoDitto, but MS Excel. Some problems are much easier, some are... pretty hairy.
- keyle 4y agoYeah... Day 1 woohoo C, Zig, etc. Day 8... Screw it... Python onwards...
- apple4ever 4y agoYup but Objective-C for me
- yakshaving_jgt 4y agoAt that point, reach for regular arrays in Haskell :)
- remify 4y agoThat's me but with F# :')
- mhitza 4y agoI 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 ...